BCDevOps / bcdk

BC Developer Kit
Apache License 2.0
6 stars 15 forks source link

Statefulset Storages are not removed when PR is closed #83

Closed kuanfandevops closed 4 years ago

kuanfandevops commented 4 years ago

I added the following scripts to clean up rabbitmq storage for statefulset. By definition of statefulset, the storage of it needs to be remove specifically. So the clean up could be or could not be part of BCDK cleanup process.

  let rabbitmqPVCs = oc.get("pvc", {
    selector: `statefulset=${phase.instance}-rabbitmq-cluster`,
    namespace: phase.namespace
  });
  rabbitmqPVCs.forEach(pvc => {
    console.log(pvc.metadata.name);
    oc.delete([`pvc/${pvc.metadata.name}`], {
      "ignore-not-found": "true",
      wait: "true",
      namespace: phase.namespace,
    });
  })
patricksimonian commented 4 years ago

@cvarjao ^^^

cvarjao commented 4 years ago

@kuanfandevops, you can use similar strategy we are using for deleting ImageStreamTag: https://github.com/BCDevOps/bcdk/blob/master/generators/pipeline/templates/.pipeline/lib/clean.js#L28 Get all StatefulSet related to the deployment/instance labels, and then delete all PVC related to that Statefulset using the statefulset label as you already have it.

A Pull request would be very much appreciated!

kuanfandevops commented 4 years ago

@cvarjao received, will seek a spot in our newly started sprint to work on this

kuanfandevops commented 4 years ago

Create PR #86 for the code change

patricksimonian commented 4 years ago

86