Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fixes #160] Bug: Error in tasks.py when initiating GeoNode container #161

Merged
5 changes: 3 additions & 2 deletions charts/geonode/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ Helm Chart for Geonode. Supported versions: Geonode: 4.1.3, Geoserver: 2.23.0, p
| geoserver.resources.limits.memory | string | `"4Gi"` | limits memory as in resource.limits.memory (https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/) |
| geoserver.resources.requests.cpu | int | `1` | requested cpu as in resource.requests.cpu (https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/) |
| geoserver.resources.requests.memory | string | `"1Gi"` | requested memory as in resource.requests.memory (https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/) |
| geoserver.secret.admin_password | string | `"geoserver"` | geoserver admin password only gets only changed when the previous username/password combination is the default one (admin/geoserver) |
| geoserver.secret.admin_factory_password | string | `"geoserver"` | geoserver factory/previous password. This password is used to change the current password for the geoserver admin_user |
| geoserver.secret.admin_password | string | `"geoserver"` | geoserver admin password, respect admin_factory_password, if you gonna change the password from not factory password |
| geoserver.secret.admin_username | string | `"admin"` | geoserver admin username |
| geoserver.secret.existingSecretName | string | `""` | name of an existing Secret to use. Set, if you want to separately maintain the Secret. |
| geoserver_data.container_name | string | `"geoserver-data-dir"` | |
Expand Down Expand Up @@ -217,4 +218,4 @@ Helm Chart for Geonode. Supported versions: Geonode: 4.1.3, Geoserver: 2.23.0, p
| rabbitmq.requests.memory | string | `"1Gi"` | requested memory as in resource.requests.memory (https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/) |

----------------------------------------------
Autogenerated from chart metadata using [helm-docs v1.11.0](https://github.com/norwoodj/helm-docs/releases/v1.11.0)
Autogenerated from chart metadata using [helm-docs v1.13.1](https://github.com/norwoodj/helm-docs/releases/v1.13.1)
25 changes: 1 addition & 24 deletions charts/geonode/templates/geonode/geonode-tasks-py-conf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,6 @@ data:
@task
def geoserverfixture(ctx):
print("********************geoserver fixture********************************")
_geoserver_info_provision(f"{os.environ['GEOSERVER_LOCATION']}rest/")
_set_geoserver_database_store()

@task
Expand Down Expand Up @@ -467,28 +466,6 @@ data:
return True


def _geoserver_info_provision(url):
from django.conf import settings
from geoserver.catalog import Catalog

geoserver_default_username = "admin"
geoserver_default_password = "geoserver"

print("Trying to changing default GeoServer Admin Password to defined password in values.yaml ...")
cat = Catalog(url, username=geoserver_default_username, password=geoserver_default_password)
headers = {"Content-type": "application/xml", "Accept": "application/xml"}
data = f"""<?xml version="1.0" encoding="UTF-8"?>
<userPassword>
<newPassword>{(os.getenv('GEOSERVER_ADMIN_PASSWORD', 'geoserver'))}</newPassword>
</userPassword>"""

response = cat.http_request(f"{cat.service_url}/security/self/password", method="PUT", data=data, headers=headers)
if response.status_code == 200:
print("GeoServer admin password updated SUCCESSFULLY!")
else:
print("WARNING: GeoServer admin password *NOT* updated: code {}, this would can only work if the previous password is the default password ...".format(response.status_code))


def _prepare_oauth_fixture():
upurl = urlparse(os.environ["SITEURL"])
default_fixture = [
Expand Down Expand Up @@ -640,7 +617,7 @@ data:
print("Check if geoserver store is already set up ...")
url = '{}rest/workspaces/{}/datastores/'.format(os.getenv('GEOSERVER_LOCATION'), GEOSERVER_WORKSPACE_NAME)
headers = {'Content-Type': 'text/xml'}
auth = (os.environ.get("GEOSERVER_ADMIN_USER"), os.getenv('GEOSERVER_ADMIN_PASSWORD')
auth = (os.environ.get("GEOSERVER_ADMIN_USER"), os.getenv('GEOSERVER_ADMIN_PASSWORD'))

try:
r = requests.get(url, headers=headers, auth=auth)
Expand Down
1 change: 1 addition & 0 deletions charts/geonode/templates/geoserver/geoserver-env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ data:
DATABASE_PORT: "{{ include "database_port" . }}"
GEONODE_GEODATABASE: {{ .Values.postgres.geodata_databasename_and_username | quote }}
GEONODE_GEODATABASE_SCHEMA: {{ .Values.postgres.schema | quote }}
FORCE_REINIT: 'true'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if you really want to reconfigure GeoServer always .. TBH I do not know how geonode-k8s handles that flag on the other containers. It is used in the entrypoint.sh of geonode/celery containers at least.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ridoo for geoserver I don't think its a big deal. atm it only updates the password of the geoserver admin and updates the timestamp of the .lock file. And for celery its kind of the same, updating fixtures, updating the timestamp of the .lock file and updating the geonode admin password if it has changed.

In my opinion, except the .lock update everything is required at each pod start anyway, or at least dosn't destroys anything. Building a switch arround this variable would bring another layer of complexity into this chart. What i could image is to add an values.yaml parameter which is enabled by default but can be disabled like:

geonode:
  force_reinit: true

geoserver:
  force_reinit: true

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Completely fine with me 👍

2 changes: 1 addition & 1 deletion charts/geonode/templates/geoserver/geoserver-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ data:
# geoserver admin credentials
GEOSERVER_ADMIN_USER: {{ .Values.geoserver.secret.admin_username | b64enc }}
GEOSERVER_ADMIN_PASSWORD: {{ .Values.geoserver.secret.admin_password | b64enc }}

GEOSERVER_FACTORY_PASSWORD: {{ .Values.geoserver.secret.admin_factory_password | b64enc }}
# geonode oauth2
OAUTH2_API_KEY: ""
OAUTH2_CLIENT_ID: {{ .Values.geonode.secret.oauth2.clientId | b64enc}}
Expand Down
6 changes: 4 additions & 2 deletions charts/geonode/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -337,10 +337,12 @@ geoserver:
secret:
# -- name of an existing Secret to use. Set, if you want to separately maintain the Secret.
existingSecretName: ""
# -- geoserver factory/previous password. This password is used to change the current password for the geoserver admin_user
admin_factory_password: geoserver
# -- geoserver admin username
admin_username: admin
# -- geoserver admin password only gets only changed when the previous username/password combination is the default one (admin/geoserver)
admin_password: "geoserver"
# -- geoserver admin password, respect admin_factory_password, if you gonna change the password from not factory password
admin_password: geoserver

resources:
requests:
Expand Down
Loading