Delete kubernetes cluster association and resources
What does this MR do?
Migrated from FOSS MR gitlab-foss!32559 (closed) for single codebase purpose.
Relates to the issue: #26815 (closed)
Creates workers to delete not only the cluster association, but also namespaces, gitlab-managed-apps, service-accounts and secrets.
Change clusters destroy endpoint to allow a cleanup: true
parameter to indicate that everything should be removed, not only the cluster association in the database.
Codeflow (success)
-
Clusters::ClustersController#destroy
is called withparams[:cleanup] == true
-
Clusters::DestroyService
is executed and, since the above param istrue
, it callscluster.start_cleanup!
-
cluster.start_cleanup!
will trigger thecleanup_status
state machine transition to:cleanup_uninstalling_applications
- The above transition hook will start a background job to uninstall all apps:
Clusters::Cleanup::AppWorker.perform_async(cluster.id)
- Once completed, the above worker will call
cluster.continue_cleanup!
which moves the state machine to:cleanup_removing_project_namespaces
- The above transition hook will start a backround job to delete all project namespaces:
Clusters::Cleanup::ProjectNamespaceWorker
- Once completed, the above worker will call
cluster.continue_cleanup!
which moves the state machine to:cleanup_removing_service_account
- The above transition hook will start a backround job to delete our service account:
Clusters::Cleanup::ServiceAccountWorker
- Finally the cluster database association is deleted
Dependent MRs (Please merge this list first)
Screenshots
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation created/updated or follow-up review issue created -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Performance and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team
Edited by 🤖 GitLab Bot 🤖