From 2d110362e6040caead91b2f93d0dcd7f26d1791b Mon Sep 17 00:00:00 2001 From: Jian Wang Date: Thu, 23 Jan 2025 12:23:21 +0100 Subject: [PATCH 1/4] Add snapshot-validation-webhook related resources to diff Signed-off-by: Jian Wang --- pkg/config/templates/rancherd-10-harvester.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkg/config/templates/rancherd-10-harvester.yaml b/pkg/config/templates/rancherd-10-harvester.yaml index 3d99eda3c..df212e7e8 100644 --- a/pkg/config/templates/rancherd-10-harvester.yaml +++ b/pkg/config/templates/rancherd-10-harvester.yaml @@ -132,6 +132,16 @@ resources: - /status/storedVersions kind: CustomResourceDefinition name: engines.longhorn.io + - apiVersion: v1 + jsonPointers: + - /data + kind: Secret + name: snapshot-validation-webhook-tls + - apiVersion: admissionregistration.k8s.io/v1 + jsonPointers: + - /webhooks/admissionReviewVersions/clientConfig/caBundle + kind: ValidatingWebhookConfiguration + name: harvester-snapshot-validation-webhook repoName: harvester-charts targets: - clusterName: local From 2eec8f8b0a299b97335489f2185b380250cf1299 Mon Sep 17 00:00:00 2001 From: Jian Wang Date: Thu, 23 Jan 2025 14:12:10 +0100 Subject: [PATCH 2/4] Drop longhorn chart post-upgrade hook Signed-off-by: Jian Wang --- scripts/build-bundle | 9 ++++++- scripts/hack/patch-harvester-sub-chart | 31 +++++++++++++++++++++++ scripts/hack/patch-rancher-logging | 2 +- scripts/hack/patch-rancher-monitoring | 2 +- scripts/hack/patch-rancher-monitoring-crd | 2 +- 5 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 scripts/hack/patch-harvester-sub-chart diff --git a/scripts/build-bundle b/scripts/build-bundle index 55d2fff84..5741c4aa1 100755 --- a/scripts/build-bundle +++ b/scripts/build-bundle @@ -79,6 +79,7 @@ source ${SCRIPTS_DIR}/hack/patch-rancher-monitoring source ${SCRIPTS_DIR}/hack/patch-rancher-logging source ${SCRIPTS_DIR}/hack/patch-rancher-monitoring-crd source ${SCRIPTS_DIR}/hack/patch-harvester-chart +source ${SCRIPTS_DIR}/hack/patch-harvester-sub-chart source ${addons_path}/version_info BUNDLE_DIR="${PACKAGE_HARVESTER_OS_DIR}/iso/bundle" @@ -125,6 +126,12 @@ fi helm package ${harvester_chart_path} -d ${CHARTS_DIR} helm package ${harvester_crd_chart_path} -d ${CHARTS_DIR} +# patch harvester sub chart to remove longhorn post-upgrade hook +patch_harvester_sub_chart ${CHARTS_DIR} ${HARVESTER_CHART_VERSION} + +# make chart sanity check again after patch +tar zxvf ${CHARTS_DIR}/harvester-${HARVESTER_CHART_VERSION}.tgz >/dev/null --warning=no-timestamp + # Prepare monitoring chart helm pull https://charts.rancher.io/assets/rancher-monitoring-crd/rancher-monitoring-crd-${MONITORING_VERSION}.tgz -d ${CHARTS_DIR} helm pull https://charts.rancher.io/assets/rancher-monitoring/rancher-monitoring-${MONITORING_VERSION}.tgz -d ${CHARTS_DIR} @@ -149,7 +156,7 @@ helm pull https://charts.rancher.io/assets/rancher-logging/rancher-logging-${LOG tar zxvf ${CHARTS_DIR}/rancher-logging-crd-${LOGGING_VERSION}.tgz >/dev/null --warning=no-timestamp tar zxvf ${CHARTS_DIR}/rancher-logging-${LOGGING_VERSION}.tgz >/dev/null --warning=no-timestamp -# patch rancher-logging chart to collect more logs" +# patch rancher-logging chart to collect more logs PKG_PATCH_LOGGING_PATH="${TOP_DIR}/pkg/config/templates/patch/rancher-logging" patch_rancher_logging_chart ${CHARTS_DIR} ${LOGGING_VERSION} ${PKG_PATCH_LOGGING_PATH} diff --git a/scripts/hack/patch-harvester-sub-chart b/scripts/hack/patch-harvester-sub-chart new file mode 100644 index 000000000..b2b18a4e8 --- /dev/null +++ b/scripts/hack/patch-harvester-sub-chart @@ -0,0 +1,31 @@ +#!/bin/bash + +patch_harvester_sub_chart() +{ + local chart_dir=$1 #${CHARTS_DIR} + local harvester_version=$2 # harvester chart version + local cwd=$(pwd) + + cd ${chart_dir} + local chartfile=harvester-${harvester_version}.tgz + ls -alth ${chartfile} || (echo "not found the chart ${chartfile}" && exit 1) + tar zxf ${chartfile} --warning=no-timestamp + + local posthook="./harvester/charts/longhorn/templates/postupgrade-job.yaml" + echo "patch the sub chart longhorn" + + ls -alth ${posthook} || (echo "not found the to-be-removed file ${posthook}, skip patch" && rm -rf harvester && return) + echo "remove ${posthook}" + rm -r ${posthook} + ls -alth ./harvester/charts/longhorn/templates/ + + echo "remove exiting chart ${chartfile}" + rm -r ${chartfile} + # helm pack new + helm package harvester + ls -alth ${chartfile} || (echo "not found the new chart ${chartfile}, check" && exit 1) + rm -rf harvester + echo "finish patch harvester sub chart" + cd $cwd +} + diff --git a/scripts/hack/patch-rancher-logging b/scripts/hack/patch-rancher-logging index 147af516c..d3d593428 100755 --- a/scripts/hack/patch-rancher-logging +++ b/scripts/hack/patch-rancher-logging @@ -45,7 +45,7 @@ patch_rancher_logging_chart() # helm pack new helm package rancher-logging rm -rf rancher-logging - echo "finish patch ranch-logging chart" + echo "finish patch rancher-logging chart" cd $cwd } diff --git a/scripts/hack/patch-rancher-monitoring b/scripts/hack/patch-rancher-monitoring index a132184ce..0a0750ba9 100755 --- a/scripts/hack/patch-rancher-monitoring +++ b/scripts/hack/patch-rancher-monitoring @@ -53,7 +53,7 @@ patch_rancher_monitoring_chart() # helm pack new helm package rancher-monitoring rm -rf rancher-monitoring - echo "finish patch ranch-monitoring chart" + echo "finish patch rancher-monitoring chart" cd $cwd } diff --git a/scripts/hack/patch-rancher-monitoring-crd b/scripts/hack/patch-rancher-monitoring-crd index 12f32fee0..bfe853ace 100755 --- a/scripts/hack/patch-rancher-monitoring-crd +++ b/scripts/hack/patch-rancher-monitoring-crd @@ -36,7 +36,7 @@ patch_rancher_monitoring_crd_chart() # helm pack new helm package rancher-monitoring-crd rm -rf rancher-monitoring-crd - echo "finish patch ranch-monitoring-crd chart" + echo "finish patch rancher-monitoring-crd chart" cd $cwd } From c9b5a281286e95fdfe2df9e0255c5f257b2ef01f Mon Sep 17 00:00:00 2001 From: Jian Wang Date: Thu, 23 Jan 2025 15:08:33 +0100 Subject: [PATCH 3/4] temp adoption of PR7421 Signed-off-by: Jian Wang --- scripts/hack/patch-harvester-sub-chart | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/scripts/hack/patch-harvester-sub-chart b/scripts/hack/patch-harvester-sub-chart index b2b18a4e8..424b12a6b 100644 --- a/scripts/hack/patch-harvester-sub-chart +++ b/scripts/hack/patch-harvester-sub-chart @@ -19,6 +19,8 @@ patch_harvester_sub_chart() rm -r ${posthook} ls -alth ./harvester/charts/longhorn/templates/ + pr7421 + echo "remove exiting chart ${chartfile}" rm -r ${chartfile} # helm pack new @@ -29,3 +31,19 @@ patch_harvester_sub_chart() cd $cwd } +pr7421() +{ + # temp adoption of PR https://github.com/harvester/harvester/pull/7421 + cd harvester/templates + echo "get PR https://github.com/harvester/harvester/pull/7421 files for issue 7375" + echo "remove current _helpers.tpl, harvester-storageclass.yaml" + rm -r _helpers.tpl + rm -r harvester-storageclass.yaml + echo "wget new files" + wget --no-check-certificate --content-disposition https://raw.githubusercontent.com/w13915984028/harvester/refs/heads/fix7375-chart/deploy/charts/harvester/templates/harvester-storageclass.yaml + wget --no-check-certificate --content-disposition https://raw.githubusercontent.com/w13915984028/harvester/refs/heads/fix7375-chart/deploy/charts/harvester/templates/_helpers.tpl + echo "new files" + cat _helpers.tpl + cat harvester-storageclass.yaml + cd ../.. +} From 8560ec485a15a46dbc01f6b12fef5d78310c46cb Mon Sep 17 00:00:00 2001 From: Jian Wang Date: Thu, 23 Jan 2025 12:23:21 +0100 Subject: [PATCH 4/4] Add snapshot-validation-webhook related resources to diff Signed-off-by: Jian Wang --- pkg/config/templates/rancherd-10-harvester.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/templates/rancherd-10-harvester.yaml b/pkg/config/templates/rancherd-10-harvester.yaml index df212e7e8..c750615ba 100644 --- a/pkg/config/templates/rancherd-10-harvester.yaml +++ b/pkg/config/templates/rancherd-10-harvester.yaml @@ -139,7 +139,7 @@ resources: name: snapshot-validation-webhook-tls - apiVersion: admissionregistration.k8s.io/v1 jsonPointers: - - /webhooks/admissionReviewVersions/clientConfig/caBundle + - /webhooks kind: ValidatingWebhookConfiguration name: harvester-snapshot-validation-webhook repoName: harvester-charts