From 43bb4685d3805edbe3ea37a950adaaa21010ce20 Mon Sep 17 00:00:00 2001 From: elweyn Date: Tue, 21 Feb 2023 05:26:25 +0100 Subject: [PATCH 01/10] Check that about !== 'null' cause the resolver has an undefinedToNull. --- webapp/pages/map.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/pages/map.vue b/webapp/pages/map.vue index 424061203..a1cdceff4 100644 --- a/webapp/pages/map.vue +++ b/webapp/pages/map.vue @@ -257,7 +257,7 @@ export default { ` description += - e.features[0].properties.about && e.features[0].properties.about.length > 0 + e.features[0].properties.about && e.features[0].properties.about !== 'null' && e.features[0].properties.about.length > 0 ? `
From f104bdcdd001afe4e2c3bf6b3e0127cb1dd72e36 Mon Sep 17 00:00:00 2001 From: elweyn Date: Tue, 21 Feb 2023 05:59:11 +0100 Subject: [PATCH 02/10] Correct linting. --- webapp/pages/map.vue | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/webapp/pages/map.vue b/webapp/pages/map.vue index a1cdceff4..9473606e6 100644 --- a/webapp/pages/map.vue +++ b/webapp/pages/map.vue @@ -257,7 +257,9 @@ export default {
` description += - e.features[0].properties.about && e.features[0].properties.about !== 'null' && e.features[0].properties.about.length > 0 + e.features[0].properties.about && + e.features[0].properties.about !== 'null' && + e.features[0].properties.about.length > 0 ? `
From df078f18d8663cfc79c61b5ac8298f7bec6fcae3 Mon Sep 17 00:00:00 2001 From: elweyn Date: Tue, 21 Feb 2023 06:01:42 +0100 Subject: [PATCH 03/10] Correct order of tests. --- webapp/pages/map.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webapp/pages/map.vue b/webapp/pages/map.vue index 9473606e6..c0f052961 100644 --- a/webapp/pages/map.vue +++ b/webapp/pages/map.vue @@ -258,8 +258,8 @@ export default { ` description += e.features[0].properties.about && - e.features[0].properties.about !== 'null' && - e.features[0].properties.about.length > 0 + e.features[0].properties.about.length > 0 && + e.features[0].properties.about !== 'null' ? `
From c3b2379af0156a6ebeb80d375d25ad47721e1f47 Mon Sep 17 00:00:00 2001 From: elweyn Date: Tue, 21 Feb 2023 10:22:16 +0100 Subject: [PATCH 04/10] markers.geoJSON made 'null' out of a property that had null in it. So added a check on the value and set undefined if value is null. --- webapp/pages/map.vue | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/webapp/pages/map.vue b/webapp/pages/map.vue index c0f052961..753ace576 100644 --- a/webapp/pages/map.vue +++ b/webapp/pages/map.vue @@ -258,8 +258,7 @@ export default { ` description += e.features[0].properties.about && - e.features[0].properties.about.length > 0 && - e.features[0].properties.about !== 'null' + e.features[0].properties.about.length > 0 ? `
@@ -338,7 +337,7 @@ export default { id: user.id, slug: user.slug, name: user.name, - about: user.about, + about: user.about ? user.about : undefined, }, geometry: { type: 'Point', @@ -359,7 +358,7 @@ export default { id: group.id, slug: group.slug, name: group.name, - about: group.about, + about: group.about ? group.about : undefined, }, geometry: { type: 'Point', @@ -379,7 +378,7 @@ export default { id: this.currentUser.id, slug: this.currentUser.slug, name: this.currentUser.name, - about: this.currentUser.about, + about: this.currentUser.about ? this.currentUser.about : undefined, }, geometry: { type: 'Point', From b5de63f43f60d53bd9019e12f4cdbe20db2a7d11 Mon Sep 17 00:00:00 2001 From: elweyn Date: Tue, 21 Feb 2023 10:23:49 +0100 Subject: [PATCH 05/10] Remove lint fixe that isn't needed anymore. --- webapp/pages/map.vue | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/webapp/pages/map.vue b/webapp/pages/map.vue index 753ace576..3779d4f18 100644 --- a/webapp/pages/map.vue +++ b/webapp/pages/map.vue @@ -257,8 +257,7 @@ export default {
` description += - e.features[0].properties.about && - e.features[0].properties.about.length > 0 + e.features[0].properties.about && e.features[0].properties.about.length > 0 ? `
From 5cd3725a0df32324c316bc003d816964b781d409 Mon Sep 17 00:00:00 2001 From: elweyn Date: Tue, 21 Feb 2023 11:39:51 +0100 Subject: [PATCH 06/10] Withdrew space. --- webapp/pages/map.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/pages/map.vue b/webapp/pages/map.vue index 3779d4f18..6f663b6b1 100644 --- a/webapp/pages/map.vue +++ b/webapp/pages/map.vue @@ -357,7 +357,7 @@ export default { id: group.id, slug: group.slug, name: group.name, - about: group.about ? group.about : undefined, + about: group.about ? group.about : undefined, }, geometry: { type: 'Point', From b5bbf5164d2220eb9697bd3d54b39e4939b7817d Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Mon, 27 Feb 2023 10:52:34 +0100 Subject: [PATCH 07/10] script to set a cluster in maintenance mode --- deployment/scripts/cluster.maintenance.sh | 22 +++++++++++++++++++ .../patch.ingress.maintenance.off.yaml | 12 ++++++++++ .../patches/patch.ingress.maintenance.on.yaml | 12 ++++++++++ 3 files changed, 46 insertions(+) create mode 100755 deployment/scripts/cluster.maintenance.sh create mode 100644 deployment/src/kubernetes/patches/patch.ingress.maintenance.off.yaml create mode 100644 deployment/src/kubernetes/patches/patch.ingress.maintenance.on.yaml diff --git a/deployment/scripts/cluster.maintenance.sh b/deployment/scripts/cluster.maintenance.sh new file mode 100755 index 000000000..3a558d7bb --- /dev/null +++ b/deployment/scripts/cluster.maintenance.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +# base setup +SCRIPT_PATH=$(realpath $0) +SCRIPT_DIR=$(dirname $SCRIPT_PATH) + +# configuration +CONFIGURATION=${CONFIGURATION:-"example"} +KUBECONFIG=${KUBECONFIG:-${SCRIPT_DIR}/../configurations/${CONFIGURATION}/kubeconfig.yaml} + +case $1 in + on) + kubectl --kubeconfig=${KUBECONFIG} patch ingress ingress-ocelot-webapp --type merge --patch-file ${SCRIPT_DIR}/../src/kubernetes/patches/patch.ingress.maintenance.on.yaml + ;; + off) + kubectl --kubeconfig=${KUBECONFIG} patch ingress ingress-ocelot-webapp --type merge --patch-file ${SCRIPT_DIR}/../src/kubernetes/patches/patch.ingress.maintenance.off.yaml + ;; + *) + echo -e "Run this script with first argument either 'on' or 'off'" + exit + ;; +esac diff --git a/deployment/src/kubernetes/patches/patch.ingress.maintenance.off.yaml b/deployment/src/kubernetes/patches/patch.ingress.maintenance.off.yaml new file mode 100644 index 000000000..c01745d0a --- /dev/null +++ b/deployment/src/kubernetes/patches/patch.ingress.maintenance.off.yaml @@ -0,0 +1,12 @@ +spec: + rules: + - host: + http: + paths: + - path: / + pathType: ImplementationSpecific + backend: + service: + name: ocelot-webapp + port: + number: 3000 \ No newline at end of file diff --git a/deployment/src/kubernetes/patches/patch.ingress.maintenance.on.yaml b/deployment/src/kubernetes/patches/patch.ingress.maintenance.on.yaml new file mode 100644 index 000000000..8a2c5d45f --- /dev/null +++ b/deployment/src/kubernetes/patches/patch.ingress.maintenance.on.yaml @@ -0,0 +1,12 @@ +spec: + rules: + - host: + http: + paths: + - path: / + pathType: ImplementationSpecific + backend: + service: + name: ocelot-maintenance + port: + number: 80 \ No newline at end of file From 51f6469119e46ca82c52b6c972880f8f3538f2dd Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Mon, 27 Feb 2023 12:49:36 +0100 Subject: [PATCH 08/10] backup script working - initial commit --- deployment/scripts/cluster.backup.sh | 45 ++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100755 deployment/scripts/cluster.backup.sh diff --git a/deployment/scripts/cluster.backup.sh b/deployment/scripts/cluster.backup.sh new file mode 100755 index 000000000..a09b6d65f --- /dev/null +++ b/deployment/scripts/cluster.backup.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +# base setup +SCRIPT_PATH=$(realpath $0) +SCRIPT_DIR=$(dirname $SCRIPT_PATH) + +# configuration +CONFIGURATION=${CONFIGURATION:-"example"} +KUBECONFIG=${KUBECONFIG:-${SCRIPT_DIR}/../configurations/${CONFIGURATION}/kubeconfig.yaml} +BACKUP_DATE=$(date "+%F_%H-%M-%S") +BACKUP_FOLDER=${BACKUP_FOLDER:-${SCRIPT_DIR}/../configurations/${CONFIGURATION}/backup/${BACKUP_DATE}} + +# create backup fodler +mkdir -p ${BACKUP_FOLDER} + +# maintenance mode on +# TODO +# ${SCRIPT_DIR}/cluster.maintenance.sh on + +# shutdown database +kubectl --kubeconfig=${KUBECONFIG} get deployment ocelot-neo4j -o json \ + | jq '.spec.template.spec.containers[] += {"command": ["tail", "-f", "/dev/null"]}' \ + | kubectl --kubeconfig=${KUBECONFIG} apply -f - + +# wait for the container to restart +sleep 60 + +# database backup +kubectl --kubeconfig=${KUBECONFIG} -n default exec -it $(kubectl --kubeconfig=${KUBECONFIG} -n default get pods | grep ocelot-neo4j | awk '{ print $1 }') -- neo4j-admin dump --to=/var/lib/neo4j/$BACKUP_DATE-neo4j-dump +# copy neo4j backup to local drive +kubectl --kubeconfig=${KUBECONFIG} cp default/$(kubectl --kubeconfig=${KUBECONFIG} -n default get pods | grep ocelot-neo4j |awk '{ print $1 }'):/var/lib/neo4j/$BACKUP_DATE-neo4j-dump $BACKUP_FOLDER/neo4j-dump +# copy image data +kubectl --kubeconfig=${KUBECONFIG} cp default/$(kubectl --kubeconfig=${KUBECONFIG} -n default get pods | grep ocelot-backend |awk '{ print $1 }'):/app/public/uploads $BACKUP_FOLDER/public-uploads + +# restart database +kubectl --kubeconfig=${KUBECONFIG} get deployment ocelot-neo4j -o json \ + | jq 'del(.spec.template.spec.containers[].command)' \ + | kubectl --kubeconfig=${KUBECONFIG} apply -f - + +# wait for the container to restart +sleep 60 + +# maintenance mode off +# TODO +# ${SCRIPT_DIR}/cluster.maintenance.sh on \ No newline at end of file From 799ea1fbe64659734d973917f67ce1c84d2543ef Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Mon, 27 Feb 2023 13:01:27 +0100 Subject: [PATCH 09/10] finish backup script --- deployment/scripts/cluster.backup.sh | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/deployment/scripts/cluster.backup.sh b/deployment/scripts/cluster.backup.sh index a09b6d65f..b83bab198 100755 --- a/deployment/scripts/cluster.backup.sh +++ b/deployment/scripts/cluster.backup.sh @@ -14,8 +14,7 @@ BACKUP_FOLDER=${BACKUP_FOLDER:-${SCRIPT_DIR}/../configurations/${CONFIGURATION}/ mkdir -p ${BACKUP_FOLDER} # maintenance mode on -# TODO -# ${SCRIPT_DIR}/cluster.maintenance.sh on +${SCRIPT_DIR}/cluster.maintenance.sh on # shutdown database kubectl --kubeconfig=${KUBECONFIG} get deployment ocelot-neo4j -o json \ @@ -26,11 +25,15 @@ kubectl --kubeconfig=${KUBECONFIG} get deployment ocelot-neo4j -o json \ sleep 60 # database backup -kubectl --kubeconfig=${KUBECONFIG} -n default exec -it $(kubectl --kubeconfig=${KUBECONFIG} -n default get pods | grep ocelot-neo4j | awk '{ print $1 }') -- neo4j-admin dump --to=/var/lib/neo4j/$BACKUP_DATE-neo4j-dump +kubectl --kubeconfig=${KUBECONFIG} -n default exec -it \ + $(kubectl --kubeconfig=${KUBECONFIG} -n default get pods | grep ocelot-neo4j | awk '{ print $1 }') \ + -- neo4j-admin dump --to=/var/lib/neo4j/$BACKUP_DATE-neo4j-dump # copy neo4j backup to local drive -kubectl --kubeconfig=${KUBECONFIG} cp default/$(kubectl --kubeconfig=${KUBECONFIG} -n default get pods | grep ocelot-neo4j |awk '{ print $1 }'):/var/lib/neo4j/$BACKUP_DATE-neo4j-dump $BACKUP_FOLDER/neo4j-dump +kubectl --kubeconfig=${KUBECONFIG} cp \ + default/$(kubectl --kubeconfig=${KUBECONFIG} -n default get pods | grep ocelot-neo4j |awk '{ print $1 }'):/var/lib/neo4j/$BACKUP_DATE-neo4j-dump $BACKUP_FOLDER/neo4j-dump # copy image data -kubectl --kubeconfig=${KUBECONFIG} cp default/$(kubectl --kubeconfig=${KUBECONFIG} -n default get pods | grep ocelot-backend |awk '{ print $1 }'):/app/public/uploads $BACKUP_FOLDER/public-uploads +kubectl --kubeconfig=${KUBECONFIG} cp \ + default/$(kubectl --kubeconfig=${KUBECONFIG} -n default get pods | grep ocelot-backend |awk '{ print $1 }'):/app/public/uploads $BACKUP_FOLDER/public-uploads # restart database kubectl --kubeconfig=${KUBECONFIG} get deployment ocelot-neo4j -o json \ @@ -41,5 +44,4 @@ kubectl --kubeconfig=${KUBECONFIG} get deployment ocelot-neo4j -o json \ sleep 60 # maintenance mode off -# TODO -# ${SCRIPT_DIR}/cluster.maintenance.sh on \ No newline at end of file +${SCRIPT_DIR}/cluster.maintenance.sh off \ No newline at end of file From b45e4b5990dc418ecc1712a95f79d70679819372 Mon Sep 17 00:00:00 2001 From: elweyn Date: Tue, 28 Feb 2023 09:55:34 +0100 Subject: [PATCH 10/10] Refactor create user with defined about --- backend/src/db/factories.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/backend/src/db/factories.js b/backend/src/db/factories.js index 3e164d51b..ecc792736 100644 --- a/backend/src/db/factories.js +++ b/backend/src/db/factories.js @@ -65,7 +65,6 @@ Factory.define('basicUser') name: faker.name.findName, password: '1234', role: 'user', - about: faker.lorem.paragraph, termsAndConditionsAgreedVersion: '0.0.1', termsAndConditionsAgreedAt: '2019-08-01T10:47:19.212Z', allowEmbedIframes: false, @@ -82,12 +81,28 @@ Factory.define('basicUser') Factory.define('userWithoutEmailAddress') .extend('basicUser') + .option('about', faker.lorem.paragraph) + .after(async (buildObject, options) => { + return neode.create('User', buildObject) + }) + +Factory.define('userWithAboutNull') + .extend('basicUser') + .option('about', null) + .after(async (buildObject, options) => { + return neode.create('User', buildObject) + }) + +Factory.define('userWithAboutEmpty') + .extend('basicUser') + .option('about', '') .after(async (buildObject, options) => { return neode.create('User', buildObject) }) Factory.define('user') .extend('basicUser') + .option('about', faker.lorem.paragraph) .option('email', faker.internet.exampleEmail) .option('avatar', () => Factory.build('image', {