From 6f396dc5d924c03c8e722aa183acc6da4f5d2ae5 Mon Sep 17 00:00:00 2001 From: Dean Roehrich Date: Mon, 29 Jan 2024 14:29:49 -0600 Subject: [PATCH] Preserve the service namespace during undeploy (#117) If a pod is on a host that cannot be reached, then any attempt to delete the namespace will hang. So change this to preserve the namespace and leave that pod for k8s to cleanup when it can. Add getopts to collect-manifests.sh, and update the tool to filter the namespace out of the manifests it collects for ArgoCD. Make the tool all-in-one so it collects the manifests and also makes the tarball; that should make it less cumbersome in a manual situation. Signed-off-by: Dean Roehrich --- .github/workflows/handle_release_tag.yaml | 4 +- Makefile | 8 ++++ dws | 2 +- lustre-csi-driver | 2 +- lustre-fs-operator | 2 +- nnf-dm | 2 +- nnf-sos | 2 +- tools/collect-manifests.sh | 47 ++++++++++++++++++++--- 8 files changed, 55 insertions(+), 14 deletions(-) diff --git a/.github/workflows/handle_release_tag.yaml b/.github/workflows/handle_release_tag.yaml index 8c3c19d2..41474e86 100644 --- a/.github/workflows/handle_release_tag.yaml +++ b/.github/workflows/handle_release_tag.yaml @@ -22,9 +22,7 @@ jobs: - name: Submodule status run: git submodule status - name: Collect manifests - run: tools/collect-manifests.sh ~+/release-manifests - - name: Make tarball - run: cd release-manifests && tar cvf ../manifests.tar * + run: tools/collect-manifests.sh -d ~+/release-manifests -t ~+/manifests.tar - name: Release uses: softprops/action-gh-release@v1 with: diff --git a/Makefile b/Makefile index 14761d38..53d72215 100644 --- a/Makefile +++ b/Makefile @@ -16,3 +16,11 @@ vet: test: ginkgo run -p --vv ./config/... +.PHONY: manifests +manifests: + tools/collect-manifests.sh -d ~+/release-manifests -t ~+/manifests.tar + +.PHONY: clean-manifests +clean-manifests: + rm -rf ~+/release-manifests ~+/manifests.tar + diff --git a/dws b/dws index 4b67213e..411a5715 160000 --- a/dws +++ b/dws @@ -1 +1 @@ -Subproject commit 4b67213ec79a885df815e9ba5fac6a0379db839b +Subproject commit 411a5715f4579a97a2865e45ef870bf3899609ba diff --git a/lustre-csi-driver b/lustre-csi-driver index e58b06cb..51493fff 160000 --- a/lustre-csi-driver +++ b/lustre-csi-driver @@ -1 +1 @@ -Subproject commit e58b06cb55bc91e756ccbb4d9e60abbb8a40a8b6 +Subproject commit 51493fff59d04e72e721f07c65c895d5f94d6023 diff --git a/lustre-fs-operator b/lustre-fs-operator index eb84599f..91980e28 160000 --- a/lustre-fs-operator +++ b/lustre-fs-operator @@ -1 +1 @@ -Subproject commit eb84599f9630780c902190a281a70564e5221638 +Subproject commit 91980e28b8adb359519879f598a944ac9a8f075d diff --git a/nnf-dm b/nnf-dm index 67f89bd4..38bf0e22 160000 --- a/nnf-dm +++ b/nnf-dm @@ -1 +1 @@ -Subproject commit 67f89bd426d1f47799043fe4eea27fca68b16b89 +Subproject commit 38bf0e22a266f912db150b6ae1cc48378ce717fc diff --git a/nnf-sos b/nnf-sos index 871b2caa..ee3c637d 160000 --- a/nnf-sos +++ b/nnf-sos @@ -1 +1 @@ -Subproject commit 871b2caa8c9c45e206fc3728ecc0e993d7a2e362 +Subproject commit ee3c637d1b03fd375ca3b9a1c8e49a54a0c963d5 diff --git a/tools/collect-manifests.sh b/tools/collect-manifests.sh index 9867cba2..7596a016 100755 --- a/tools/collect-manifests.sh +++ b/tools/collect-manifests.sh @@ -17,16 +17,41 @@ # See the License for the specific language governing permissions and # limitations under the License. -TREEDIR="$1" +while getopts 'd:t:h' opt; do +case "$opt" in +d) TREEDIR="$OPTARG" ;; +t) TARFILE="$OPTARG" ;; +\?|h) + echo "Usage: $0 -d NEW_DIR -t TARFILE_NAME" + echo + echo " NEW_DIR Directory to create tree of manifests. This directory" + echo " must not exist and must begin with a slash." + echo " TARFILE_NAME Name to give to the tarfile of manifests. This name" + echo " must begin with a slash." + exit 1 + ;; +esac +done +shift "$((OPTIND - 1))" if [[ -z $TREEDIR ]]; then - echo "specify a tree dir" + echo "You must specify -d" exit 1 elif [[ $TREEDIR != /* ]]; then - echo "must begin with a slash" + echo "The directory must begin with a slash" exit 1 elif [[ -d $TREEDIR ]]; then - echo "the dir already exists" + echo "The directory $TREEDIR already exists" + exit 1 +fi +if [[ -z $TARFILE ]]; then + echo "You must specify -t" + exit 1 +elif [[ $TARFILE != /* ]]; then + echo "The tarfile name must begin with a slash" + exit 1 +elif [[ -f $TARFILE ]]; then + echo "The tarfile must not already exist" exit 1 fi @@ -51,7 +76,11 @@ for SUBMODULE in $DO_MODULES; do mkdir "$TREEDIR/$SUBMODULE" (cd "$SUBMODULE" || exit 1 if [[ -d config/begin ]]; then - bin/kustomize build config/begin > "$TREEDIR/$SUBMODULE/$SUBMODULE.yaml" + # Remove the namespace from the manifest, because this manifest is + # used not only to deploy but also to undeploy. + # The namespace will be created by the ArgoCD Application resource, + # and nothing will delete it. + bin/kustomize build config/begin | yq eval 'select(.kind != "Namespace")' > "$TREEDIR/$SUBMODULE/$SUBMODULE.yaml" fi if [[ -d config/begin-examples ]]; then bin/kustomize build config/begin-examples > "$TREEDIR/$SUBMODULE/$SUBMODULE-examples.yaml" @@ -60,7 +89,11 @@ for SUBMODULE in $DO_MODULES; do bin/kustomize build config/prometheus > "$TREEDIR/$SUBMODULE/$SUBMODULE-prometheus.yaml" fi if [[ -d deploy/kubernetes/begin ]]; then - bin/kustomize build deploy/kubernetes/begin > "$TREEDIR/$SUBMODULE/$SUBMODULE.yaml" + # Remove the namespace from the manifest, because this manifest is + # used not only to deploy but also to undeploy. + # The namespace will be created by the ArgoCD Application resource, + # and nothing will delete it. + bin/kustomize build deploy/kubernetes/begin | yq eval 'select(.kind != "Namespace")' > "$TREEDIR/$SUBMODULE/$SUBMODULE.yaml" fi ) done @@ -73,4 +106,6 @@ mkdir "$TREEDIR/mpi-operator" MPIOP_URL=$(yq -M '.thirdPartyServices[] | select(.name == "mpi-operator") | .url' config/repositories.yaml) wget -O "$TREEDIR"/mpi-operator/mpi-operator.yaml "$MPIOP_URL" +(cd "$TREEDIR" && tar cf "$TARFILE" ./*) +exit $?