kappnav / issues

kAppNav global issues
0 stars 0 forks source link

Application auto-creation not working as expected with more than one deploy/sts with auto-create labels #157

Closed navidsh closed 4 years ago

navidsh commented 4 years ago

Bug Report

What did you do?

  1. I created two deployments (named app-1 and app-2) in the same namespace and added the following labels and annotations to both deployments:
  labels:
    kappnav.app.auto-create: 'true'
  annotations:
    kappnav.app.auto-create.kinds: 'Deployment, StatefulSet, Service, Route, Ingress, ConfigMap'
    kappnav.app.auto-create.label: app.kubernetes.io/part-of
    kappnav.app.auto-create.labels-values: mega-app
    kappnav.app.auto-create.name: mega-app
  1. kAppNav create an Application CR with the following annotations:

    annotations:
    kappnav.app.auto-created.from.kind: Deployment
    kappnav.app.auto-created.from.name: app-1
  2. I deleted app-1 and the automatically generated Application CR got deleted.

What did you expect to see?

I expected an Application CR to be available.

What did you see instead?

The automatically generated Application CR got deleted and never got recreated.

Environment

cvignola commented 4 years ago

We need a way to track "claims" on an Application CR. Each resource that specifies to auto-create an Application of a given name, places a claim on that Application. The claims must be tracked such that the Application is deleted only after the final claimant is deleted.

Implementationally:

"kappnav.app.auto-created.from.name" needs to essentially be array .

E.g. after first claim, made by Deployment dep-1:

  kappnav.app.auto-created.from.name: [ dep-1 ] 

After second claim, made by Deployment dep-2:

  kappnav.app.auto-created.from.name: [ dep-1, dep-2 ]

After dep-1 is deleted:

  kappnav.app.auto-created.from.name: [ dep-2 ]

After dep-2 is deleted:

  kappnav.app.auto-created.from.name:     ---> delete Application CR