Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP Add delete script task #144

Closed
wants to merge 5 commits into from
Closed

Conversation

liyanwei93
Copy link
Contributor

@liyanwei93 liyanwei93 commented May 10, 2022

Add delete script task:

  • check-object-prereqs job: After Installation CR deployed successfully, check whether Crossplane has been deployed by common services.
  • Object: Create a deployment containing a delete script, which will not be controlled by Gitops.
  • The check-object-prereqs job and Object will be deleted by Argocd when the argocd application is deleted. The left deployment will check the Installation CR for a deletionTimestamp, and if so will start the delete script.
  • Add finalizers to avoid deleting deployments when argocd deleting AIManager namespace. When the script finishes running, it removes these "finalizers"
  • The uninstall process is often blocked by installation CR because it cannot be removed successfully, which is the biggest problem facing now. (Even if run the delete script manually)

Copy link
Contributor

@morningspace morningspace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@liyanwei93 I did a round of review and added some comments. Generally, I can understand this is a very hacky resolution, which can be working as an experimental feature, but is error-prone if that goes to be an official feature.

Essentially, we are simulating what a Kubernetes controller or an operator is supposed to do, but using a very tricky way.

After considering this carefully, I think we can leave it as an experimental feature for now. Long termly, we should seek ways to create a real operator which has to be co-located w/ the deployment w/ additional workload and footprint, or using seed cluster to remotely control it by pipeline as example.

cc @gyliu513

Comment on lines 42 to 43
# Use management policy ObserveDelete to observe or delete k8s resource,
# but leave to third party to create or update the resource
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment seems misleading.

echo "end"

while true; do
echo "Waitting to be deleted......"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
echo "Waitting to be deleted......"
echo "Waiting to be deleted ..."

echo "INFO: Crossplane kubernetes provider available."
exit 0
fi
echo "INFO: Crossplane kubernetes provider not available, waiting."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
echo "INFO: Crossplane kubernetes provider not available, waiting."
echo "INFO: Crossplane provider kubernetes not available, waiting ..."

@morningspace
Copy link
Contributor

More thoughts on the long term solution:

The clean up job is essentially very similar to a regular procedure, so that can be nicely modeled as a pipeline task, which can be triggered either manually or automatically. It's easy to encapsulate the clean up shell script into a Tekton task.

The drawback of the above idea is that it is a one-time off job, which can not be used to regularly monitoring the system for an uninstall need. This goes to 2nd option which is a real Kubernetes controller that has reconciliation logic to keep monitoring the system status. As an example, I think maybe the Crossplane provider ansible is a good choice in this case, because it is working as a controller inside a Kubernetes cluster w/ all the native Kubernetes behavior including the reconciliation, as well as the ability to call Ansible roles and playbooks remotely, e.g.: some shell scripts wrapped as Ansible playbook and hosted in a remote git repo. This can nicely handle our case.

@gyliu513
Copy link
Member

Opened a github issue for argoCD at argoproj/argo-cd#9351 to discuss post uninstall

@gyliu513
Copy link
Member

@morningspace @liyanwei93 as we are using helm chart, can we leverage helm chart hooks for uninstall https://helm.sh/docs/topics/charts_hooks/#writing-a-hook ?

@morningspace
Copy link
Contributor

Some similar discussions here at: argoproj/argo-cd#7575, as I remember, we couldn't rely on helm hook when combing w/ Argo CD, because there's no such mapping between helm hook and Argo CD sync phase for now, which means the hook will not be triggered when we delete Argo application.

@gyliu513 gyliu513 changed the title Add delete script task WIP Add delete script task May 11, 2022
@gyliu513 gyliu513 marked this pull request as draft May 11, 2022 02:47
@liyanwei93 liyanwei93 deleted the branch IBM:release-3.4 June 24, 2022 03:31
@liyanwei93 liyanwei93 closed this Jun 24, 2022
@liyanwei93 liyanwei93 deleted the release-3.4 branch June 24, 2022 03:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants