gardenctl
gardenctl copied to clipboard
add gardenctl hibernate and gardenctl wakeup to hibernate/wakeup shoot cluster
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
if no objection i will merge this PR by EOB today
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 thisThe 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
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 oflist
. 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
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
/close as this feature will not be implemented
per customer requirement i'm reopening this issue https://github.com/gardener/gardenctl/issues/450#issuecomment-838292497 will continue when available /reopen
This pull request has conflicts, please resolve those before we can evaluate the pull request.
@neo-liang-sap You need rebase this pull request with latest master branch. Please check.