From 6a5204445d3550585d19fd8284e618eec7cd509b Mon Sep 17 00:00:00 2001 From: Zoran Sinnema Date: Tue, 8 Mar 2022 11:38:15 +0100 Subject: [PATCH 1/6] #457 feature removed the cached functions from keycloak --- libraries/cloudharness-common/cloudharness/auth/keycloak.py | 5 ----- libraries/cloudharness-common/requirements.txt | 1 - 2 files changed, 6 deletions(-) diff --git a/libraries/cloudharness-common/cloudharness/auth/keycloak.py b/libraries/cloudharness-common/cloudharness/auth/keycloak.py index 4ef77150..84cc9226 100644 --- a/libraries/cloudharness-common/cloudharness/auth/keycloak.py +++ b/libraries/cloudharness-common/cloudharness/auth/keycloak.py @@ -4,7 +4,6 @@ import requests from keycloak import KeycloakAdmin from keycloak.exceptions import KeycloakAuthenticationError -from cachetools import cached, TTLCache from cloudharness import log from cloudharness.middleware import get_authentication_token @@ -237,7 +236,6 @@ def create_client_role(self, client_id, role): ) return True - @cached(cache=TTLCache(maxsize=1024, ttl=30)) @with_refreshtoken def get_group(self, group_id, with_members=False): """ @@ -365,7 +363,6 @@ def get_users(self, query=None): users.append(user) return users - @cached(cache=TTLCache(maxsize=1024, ttl=30)) @with_refreshtoken def get_user(self, user_id): """ @@ -402,7 +399,6 @@ def get_current_user(self): """ return self.get_user(self._get_keycloak_user_id()) - @cached(cache=TTLCache(maxsize=1024, ttl=30)) @with_refreshtoken def get_user_realm_roles(self, user_id): """ @@ -429,7 +425,6 @@ def get_current_user_realm_roles(self): """ return self.get_user_realm_roles(self._get_keycloak_user_id()) - @cached(cache=TTLCache(maxsize=1024, ttl=30)) @with_refreshtoken def get_user_client_roles(self, user_id, client_name): """ diff --git a/libraries/cloudharness-common/requirements.txt b/libraries/cloudharness-common/requirements.txt index 0bcaf554..9ae000c5 100644 --- a/libraries/cloudharness-common/requirements.txt +++ b/libraries/cloudharness-common/requirements.txt @@ -16,4 +16,3 @@ kubernetes sentry-sdk[flask]==0.14.4 python-keycloak==0.24.0 argo-workflows==5.0.0 -cachetools==4.2.2 From 4f18a5a5ee7bb5773b68c0fc753e6c8846a4df3f Mon Sep 17 00:00:00 2001 From: Zoran Sinnema Date: Tue, 22 Mar 2022 15:44:29 +0100 Subject: [PATCH 2/6] #469 feature: enable application volume to be shared across multiple different deployments --- docs/applications/README.md | 1 + docs/applications/volumes.md | 31 +++++++++++++++++++ .../helm/templates/auto-volumes.yaml | 2 ++ 3 files changed, 34 insertions(+) create mode 100644 docs/applications/volumes.md diff --git a/docs/applications/README.md b/docs/applications/README.md index 28d051dd..b8758632 100644 --- a/docs/applications/README.md +++ b/docs/applications/README.md @@ -95,6 +95,7 @@ The most important configuration entries are the following: - `deployment`: creates a deployment - `auto`: if true, creates the deployment automatically - `resources`: define cpu and memory limits + - `volume`: application persistent volume - `service`: - `auto`: if true, creates the service automatically - `dependencies`: lists of applications/images this application depends from diff --git a/docs/applications/volumes.md b/docs/applications/volumes.md new file mode 100644 index 00000000..3dcee74a --- /dev/null +++ b/docs/applications/volumes.md @@ -0,0 +1,31 @@ +# Application Volume + +Application Volumes are defined at `harness.deployment.volume`. +At the time of writing this documentation CloudHarness supports only one volume per deployment. + +The Application Volume will be mounted in the container at a specific path at **deployment** time. + +A Volume can be mounted by one or more pods (shared Volume). Be careful: only one of the deployments +should create the Volume, the other deployment should only mount it. + +This can be established through setting the `auto` attribute (default false) of the Volume object +auto: true --> auto create the volume and mount +auto: false --> only mount the volume + +Shared volumes are handy when you have e.g. 2 deployments for one app: frontend & backend deployment +in such a case it could be helpfull that the frontend can access files stored by the backend. +E.g. user uploaded media files + +**Example** + +```yaml +harness: + ... + deployment: + ... + volume: + name: myFirstVolume + mountpath: /usr/src/app/myvolume + auto: true + size: 5Gi +``` diff --git a/tools/cloudharness_utilities/deployment-configuration/helm/templates/auto-volumes.yaml b/tools/cloudharness_utilities/deployment-configuration/helm/templates/auto-volumes.yaml index 0748002d..69fcd7fb 100644 --- a/tools/cloudharness_utilities/deployment-configuration/helm/templates/auto-volumes.yaml +++ b/tools/cloudharness_utilities/deployment-configuration/helm/templates/auto-volumes.yaml @@ -1,4 +1,5 @@ {{- define "deploy_utils.pvolume" }} +{{- if not .app.harness.deployment.volume.auto }} apiVersion: v1 kind: PersistentVolumeClaim metadata: @@ -12,6 +13,7 @@ spec: resources: requests: storage: {{ .app.harness.deployment.volume.size }} +{{- end }} --- {{- end }} {{- range $app := .Values.apps }} From fe40b3a18444fb92d3fb31bee7e0f68d2b5d1271 Mon Sep 17 00:00:00 2001 From: Zoran Sinnema Date: Tue, 22 Mar 2022 15:50:09 +0100 Subject: [PATCH 3/6] #469 fix volumes auto creation, changed if not to if --- .../deployment-configuration/helm/templates/auto-volumes.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/cloudharness_utilities/deployment-configuration/helm/templates/auto-volumes.yaml b/tools/cloudharness_utilities/deployment-configuration/helm/templates/auto-volumes.yaml index 69fcd7fb..174d695b 100644 --- a/tools/cloudharness_utilities/deployment-configuration/helm/templates/auto-volumes.yaml +++ b/tools/cloudharness_utilities/deployment-configuration/helm/templates/auto-volumes.yaml @@ -1,5 +1,5 @@ {{- define "deploy_utils.pvolume" }} -{{- if not .app.harness.deployment.volume.auto }} +{{- if .app.harness.deployment.volume.auto }} apiVersion: v1 kind: PersistentVolumeClaim metadata: From d566312963413f0ebd2744577ac3d22b4c8aec55 Mon Sep 17 00:00:00 2001 From: Zoran Sinnema Date: Thu, 24 Mar 2022 13:51:53 +0100 Subject: [PATCH 4/6] #471 fixes volume creation for volume objects without the auto key --- .../deployment-configuration/helm/templates/auto-volumes.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/cloudharness_utilities/deployment-configuration/helm/templates/auto-volumes.yaml b/tools/cloudharness_utilities/deployment-configuration/helm/templates/auto-volumes.yaml index 174d695b..3a566025 100644 --- a/tools/cloudharness_utilities/deployment-configuration/helm/templates/auto-volumes.yaml +++ b/tools/cloudharness_utilities/deployment-configuration/helm/templates/auto-volumes.yaml @@ -1,5 +1,6 @@ {{- define "deploy_utils.pvolume" }} -{{- if .app.harness.deployment.volume.auto }} +{{- $auto_create := printf "%s" (.app.harness.deployment.volume.auto|quote) }} +{{- if or (not (hasKey .app.harness.deployment.volume "auto")) (eq $auto_create "true") }} apiVersion: v1 kind: PersistentVolumeClaim metadata: From f670c129f724cd552a38e8051c5fc9f84db8078e Mon Sep 17 00:00:00 2001 From: Zoran Sinnema Date: Thu, 24 Mar 2022 15:53:51 +0100 Subject: [PATCH 5/6] add quotes to true for testing --- .../deployment-configuration/helm/templates/auto-volumes.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/cloudharness_utilities/deployment-configuration/helm/templates/auto-volumes.yaml b/tools/cloudharness_utilities/deployment-configuration/helm/templates/auto-volumes.yaml index 3a566025..5cedbac6 100644 --- a/tools/cloudharness_utilities/deployment-configuration/helm/templates/auto-volumes.yaml +++ b/tools/cloudharness_utilities/deployment-configuration/helm/templates/auto-volumes.yaml @@ -1,6 +1,6 @@ {{- define "deploy_utils.pvolume" }} {{- $auto_create := printf "%s" (.app.harness.deployment.volume.auto|quote) }} -{{- if or (not (hasKey .app.harness.deployment.volume "auto")) (eq $auto_create "true") }} +{{- if or (not (hasKey .app.harness.deployment.volume "auto")) (eq $auto_create (true|quote)) }} apiVersion: v1 kind: PersistentVolumeClaim metadata: From ecc359447744a753c5dfa0d43c1bd2c9b9ba1c8a Mon Sep 17 00:00:00 2001 From: Zoran Sinnema Date: Fri, 25 Mar 2022 16:42:34 +0100 Subject: [PATCH 6/6] refactor check for auto volume creation, more readable check --- .../deployment-configuration/helm/templates/auto-volumes.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/cloudharness_utilities/deployment-configuration/helm/templates/auto-volumes.yaml b/tools/cloudharness_utilities/deployment-configuration/helm/templates/auto-volumes.yaml index 5cedbac6..c6d220e9 100644 --- a/tools/cloudharness_utilities/deployment-configuration/helm/templates/auto-volumes.yaml +++ b/tools/cloudharness_utilities/deployment-configuration/helm/templates/auto-volumes.yaml @@ -1,6 +1,5 @@ {{- define "deploy_utils.pvolume" }} -{{- $auto_create := printf "%s" (.app.harness.deployment.volume.auto|quote) }} -{{- if or (not (hasKey .app.harness.deployment.volume "auto")) (eq $auto_create (true|quote)) }} +{{- if or (not (hasKey .app.harness.deployment.volume "auto")) .app.harness.deployment.volume.auto }} apiVersion: v1 kind: PersistentVolumeClaim metadata: