Skip to content

Refactor KubernetesClient class

Context

The KubernetesClient class is too complex for what it's supposed to accomplish. It's a small technical debt I encounter every time I need to find a bug in it.

From Draft to Ready

What does this MR do?

This MR reduces the technical debt in this class by making it a bit more straightforward.

  • Refactored the specs for the KubernetesClient class 🎉
  • Makes scripts/review_apps/automated_cleanup.rb ready for helm3 (we also added specs for this class in !114270 (merged), so that we are more confident with this refactor)
  • Split cleanup_by_created_at generic method into two more specific methods: cleanup_namespaces_by_created_at and cleanup_pvcs_by_created_at
  • Fix a PVC deletion bug.
    • With helm 2, we created all the PVCs in the review-apps namespace. This has changed in Helm 3, and therefore, we didn't properly delete PVCs anymore in the cluster.
  • Adds the possibility to run review-cleanup in dry-run mode by passing DRY_RUN to the manual job.

Does it work?

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by David Dieulivol

Merge request reports

Loading