0

After processing of a CRD instance i am trying to patch the status of the CRD via my custom ingress controller in python.

After patch of the status, i am receiving a modify event from kube-api server on the crd instance since resourceversion is getting incremented after the status is updated.

Example of the event:

{'type': 'MODIFIED', 'object': {'apiVersion': '…', 'kind': '…', 'metadata': {'creationTimestamp': '…', 'generation': 1, 'name': 'thro', 'namespace': 'default', 'resourceVersion': '9927551', 'selfLink': '…', 'uid': '…'}, 'spec': {'…}, 'status': {'state': 'Success', 'status_message': 'CRD Activated'}}}

My requirement is to ignore this modify event as there is no change in spec. But only way to do this will be by keeping track of the previous generation value of the CRD instance object and compare if there is an update in the generation. Which i wanted to avoid.

  • Please add more details to the question. Are you developing a new controller for a custom resource? Which language and which framework are you using? – Shashank V Jan 17 '20 at 14:11
  • Please give more practical details so we can reproduce your problem. – Will R.O.F. Jan 17 '20 at 14:57
  • Looks like a duplicate of this question: https://stackoverflow.com/questions/59788734/how-can-i-ignore-crd-modify-event-on-status-update-of-custom-resource-objects which also doesn't have an answer. The goal is to watch a custom resource, have an "update" event trigger some logic, and update the status based on the outcome of the logic. Unfortunately, updating the status will trigger another update event. The OP and the OP for the linked question are asking how to most effectively ignore the "update" event coming from the status update. – Dmitri Gekhtman Jan 27 '21 at 03:39

1 Answers1

0

I think you can use the metadata.generation to ignore the status update, add observedGeneration to the CRD status, just like what the deployment controller does.

Here is the code from deployment controller.

if d.Status.ObservedGeneration < d.Generation {
  d.Status.ObservedGeneration = d.Generation
  dc.client.AppsV1().Deployments(d.Namespace).UpdateStatus(d)
}
return nil