add --resume-suspended option to 'sylvactl watch'

This MR is needed to address issue sylva-projects/sylva-core#1904 (closed) which is breaking CI for current work in main (upgrades from 1.2.1 to main).

This MR adds a --resume-suspended option to sylvactl watch: when this option is set, sylvactl watch will resume any suspended resource on when it becomes reconcilable.

This is introduced to address the issue described in sylva-projects/sylva-core#1904 (closed)

This MR does the following:

  • introduce setSuspend and DeepCopy in FluxAdapter ; this is required to let us patch the spec.suspend of FluxCD resources from the informer code
  • modify Reconcilable(): the old behavior was to consider that a suspended resource is not reconcilable; for --resume-suspended we want to unsuspend when a resource becomes reconcilable, so we need to adjust this condition to also consider a suspended resource reconcilable if --resume-suspended is set
    • to make the option flag accessible from Reconcilable() we need to make this function a method of TreeInformer and update all the places calling it, including under checkConditions
  • modify computeStatus: before this MR a suspended resource could be considered ready, but since the rest of the code will not act on ready resources, this MR changes computeStatus so that a suspended resources is ready==false
  • the setReconcileStartedAnnotations function is where the "resume" happens, it is updated to patch the spec.suspend of the resources when needed (and is renamed as setStartReconcile)
  • finally, introduce the CLI flag to control the new behavior and propagate it to TreeInformer
Edited by Thomas Morin

Merge request reports

Loading