gardenctl icon indicating copy to clipboard operation
gardenctl copied to clipboard

add gardenctl hibernate and gardenctl wakeup to hibernate/wakeup shoot cluster

Open neo-liang-sap opened this issue 4 years ago • 8 comments

What this PR does / why we need it: add gardenctl hibernate and gardenctl wakeup to hibernate/wakeup shoot cluster Which issue(s) this PR fixes: Fixes https://github.com/gardener/gardenctl/issues/450

Special notes for your reviewer:

Release note:

after targeting a shoot, you could run "gardenctl hibernate" / "gardenctl wakeup" to hibernate / wakeup a shoot

neo-liang-sap avatar Nov 25 '20 07:11 neo-liang-sap

if no objection i will merge this PR by EOB today

neo-liang-sap avatar Dec 01 '20 02:12 neo-liang-sap

Hi @petersutter , thanks for your review and comments.

  • i've modified shoot namespace while doing list of shoots, now it's shootList, err := gardenClientset.CoreV1beta1().Shoots(shoot.GetNamespace()).List(metav1.ListOptions{})

  • i've removed description compare, so the typo is also removed

  • for watch for changes, i'm not understanding very clearly. Do you mean move the logic of getting newShoot outside of for loop? in my test, the newShoot object is immutable object, this object will stay the same without reflecting new status change. I'm not sure whether i have expressed myself clearly, if i put logic of getting newShoot outside of for loop the result would be sth like this image The progress won't change.

So 'each time pulling newShoot object is the simplest way i can come up with, in my test i see the performance is OK , as gardenctl hibernate/wakeup checks shoot status at 1 min interval, this waiting interval takes most of the running time.

Do you have a better way for getting & comparing the newShoot status? it would be much appreciate if you can propose some code snippet for me to reference, thanks! -Neo

neo-liang-sap avatar Dec 02 '20 02:12 neo-liang-sap

Hi @neo-liang-sap ,

  • In general, if you are only interested in one shoot and you have the namespace and name of the shoot, as you do in this case, please use get instead of list. But if you watch for changes you anyhow need to do it differently
  • Take this as an example on how to implement a watch a resource
    • watch with 10 seconds timeout https://github.com/gardener/terminal-controller-manager/blob/master/controllers/terminal_controller.go#L1255-L1258
    • https://github.com/gardener/terminal-controller-manager/blob/master/controllers/terminal_controller.go#L833-L883

Implementing a watch is not required of course, but definitely more efficient and instant

petersutter avatar Dec 03 '20 11:12 petersutter

Hi @petersutter , thanks, i've changed code to use get to get shoot. For watch example you provided i took look at them and it seems would takes much effort to implement similar in hibernate/wakeup function, as this function doesn't have strict performance requirement i wonder is it ok to use current implementation (get the shoot object at 1 min interval and check the status) as a easy solution? Thanks. -Neo

neo-liang-sap avatar Dec 03 '20 14:12 neo-liang-sap

/close as this feature will not be implemented

neo-liang-sap avatar Dec 23 '20 02:12 neo-liang-sap

per customer requirement i'm reopening this issue https://github.com/gardener/gardenctl/issues/450#issuecomment-838292497 will continue when available /reopen

neo-liang-sap avatar May 11 '21 11:05 neo-liang-sap

This pull request has conflicts, please resolve those before we can evaluate the pull request.

github-actions[bot] avatar Jul 06 '21 02:07 github-actions[bot]

@neo-liang-sap You need rebase this pull request with latest master branch. Please check.

gardener-robot avatar Sep 07 '21 09:09 gardener-robot