Skip to content

Commit

Permalink
Preserve the service namespace during undeploy (#117)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
roehrich-hpe authored Jan 29, 2024
1 parent b286fdd commit 6f396dc
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 14 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/handle_release_tag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

2 changes: 1 addition & 1 deletion dws
Submodule dws updated 1 files
+3 −2 deploy.sh
2 changes: 1 addition & 1 deletion lustre-csi-driver
Submodule lustre-csi-driver updated 2 files
+3 −2 Makefile
+38 −0 deploy.sh
2 changes: 1 addition & 1 deletion lustre-fs-operator
Submodule lustre-fs-operator updated 1 files
+3 −2 deploy.sh
2 changes: 1 addition & 1 deletion nnf-dm
2 changes: 1 addition & 1 deletion nnf-sos
Submodule nnf-sos updated 2 files
+3 −3 Makefile
+3 −2 deploy.sh
47 changes: 41 additions & 6 deletions tools/collect-manifests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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"
Expand All @@ -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
Expand All @@ -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 $?

0 comments on commit 6f396dc

Please sign in to comment.