-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wait until the manager is actually gone before continuing the upgrade #1635
Conversation
Signed-off-by: Andreas Neumann <aneumann@mesosphere.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to wait for the webhook as well, right? UninstallWebHook
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree with @alenkacz
Also... I much prefer to move k8s specific functionality to that package. What we are deleting or waiting for should be declared here (manager
) but the logic of how to delete or wait should be encapsulated in a kube
/ kubernetes
package. Not a blocker as there is a prior art... but a kind loving nug :)
Good point. I've started out that way, but that was a bit too generic: In the I'm not opposed to adding it there though. Especially as we have to wait for the webhook resource as well, I think it makes sense to generalise this. |
Signed-off-by: Andreas Neumann <aneumann@mesosphere.com>
Signed-off-by: Andreas Neumann <aneumann@mesosphere.com>
Signed-off-by: Andreas Neumann <aneumann@mesosphere.com>
Signed-off-by: Andreas Neumann <aneumann@mesosphere.com>
Signed-off-by: Andreas Neumann <aneumann@mesosphere.com>
Waiting for Webhook is now in, and Alena doesn't have time for a full re-review today
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nothing blocking... but I'm challenged by the verbosity levels and the name "step" in the initializer code.
pkg/kubernetes/client.go
Outdated
// Wait for resources to be deleted. | ||
return wait.PollImmediate(250*time.Millisecond, 30*time.Second, func() (done bool, err error) { | ||
err = c.Get(context.TODO(), key, obj.DeepCopyObject()) | ||
clog.V(8).Printf("Fetched %s/%s to wait for delete: %v", key.Namespace, key.Name, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
questioning this verbose levels... level 7-9 tend to be deconstruction of serialized objects or deep http calls. These seem like level 2 and 3 type stuff (obviously subjective)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've adjusted them a bit to 6 - This one especially is in a tight loop and can get quite spammy that's why I didn't want to have it in the higher ones
@@ -15,3 +24,47 @@ func GetDiscoveryClient(mgr manager.Manager) (*discovery.DiscoveryClient, error) | |||
} | |||
return dc, nil | |||
} | |||
|
|||
// DeleteAndWait deletes the given runtime object and waits until it is fully deleted | |||
func DeleteAndWait(c client.Client, obj runtime.Object, options ...client.DeleteOption) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do you think about a Delete(c, obj, wait bool
, options) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather add another func
Delete(c client.Client, obj runtime.Object, options ...client.DeleteOption) error
which does not wait. I think having the "AndWait" in the name makes the intention more clear than a bool param.
@@ -33,8 +34,8 @@ type Initializer struct { | |||
} | |||
|
|||
// NewInitializer returns the setup management object | |||
func NewInitializer(options kudoinit.Options) Initializer { | |||
return Initializer{ | |||
func NewInitializer(options kudoinit.Options) *Initializer { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a reason for this change?
makes me wonder if the methods need adjustment as well... meaning
func (m Initializer) UninstallService(client *kube.Client) error {
->
func (m *Initializer) UninstallService(client *kube.Client) error {
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly to make the usage of this more clear in setup.go
. And i've changed the receiver to a pointer. It's not required to be mutable right now, but it might as well be in the future and can be hard to find these kind of bugs :-/
} | ||
|
||
func (m Initializer) UninstallService(client *kube.Client) error { | ||
clog.V(4).Printf("Uninstall KUDO manager service") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this number seems high... I would expect 2
pkg/kudoctl/kudoinit/setup/setup.go
Outdated
@@ -33,14 +36,22 @@ func NewInstaller(options kudoinit.Options, crdOnly bool) *Installer { | |||
} | |||
} | |||
|
|||
// This is a bit cumbersome - we need to access some funcs from these two | |||
// steps for the upgrade process, that's why they are initialized here. | |||
// This should be cleaned up |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you elaborate (in code comments) what is meant by cleaned up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've removed the "Cleaned up" part and changed the comment a bit.
I think the whole setup.go
with the []kudoinit.Step
slice should probably refactored. It was a good idea in the beginning, but doesn't work that well with upgrades when we need to access specific elements from the slice.
pkg/kudoctl/kudoinit/setup/setup.go
Outdated
@@ -21,6 +21,9 @@ var _ kudoinit.InstallVerifier = &Installer{} | |||
type Installer struct { | |||
options kudoinit.Options | |||
steps []kudoinit.Step | |||
|
|||
managerStep *manager.Initializer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
really don't like the name... step is a meaningful thing in kudo, and this doesn't align... it would be ok if it was some kind of step, but I don't see that... it is a manager Initializer..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've renamed it to managerInitializer
, same for the webhook
pkg/kudoctl/kudoinit/setup/setup.go
Outdated
@@ -21,6 +21,9 @@ var _ kudoinit.InstallVerifier = &Installer{} | |||
type Installer struct { | |||
options kudoinit.Options | |||
steps []kudoinit.Step |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is likely where the managerStep gets it's name... but why do we see these as steps? These are an array of initializers... the renaming to step loses that context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've renamed the slice as well. I've left the kudoinit.Step
type for now, but I agree that this should probably be renamed in another PR
Signed-off-by: Andreas Neumann <aneumann@mesosphere.com>
Signed-off-by: Andreas Neumann aneumann@mesosphere.com
Fixes #1633 #1632