Skip to content
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

Merged
merged 7 commits into from
Aug 17, 2020

Conversation

ANeumann82
Copy link
Member

@ANeumann82 ANeumann82 commented Aug 6, 2020

Signed-off-by: Andreas Neumann aneumann@mesosphere.com

Fixes #1633 #1632

Signed-off-by: Andreas Neumann <aneumann@mesosphere.com>
Copy link
Contributor

@alenkacz alenkacz left a 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

pkg/kudoctl/kudoinit/manager/manager.go Outdated Show resolved Hide resolved
Copy link
Member

@kensipe kensipe left a 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 :)

@ANeumann82
Copy link
Member Author

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 kubernetes package I'd like to have a generic version of this, which would need the dynamic.Interface client which we currently don't have in the kubectl client.

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>
@alenkacz alenkacz self-requested a review August 7, 2020 13:10
@ANeumann82 ANeumann82 dismissed alenkacz’s stale review August 7, 2020 13:14

Waiting for Webhook is now in, and Alena doesn't have time for a full re-review today

Copy link
Member

@kensipe kensipe left a 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.

// 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)
Copy link
Member

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)

Copy link
Member Author

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 {
Copy link
Member

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) ?

Copy link
Member Author

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 {
Copy link
Member

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 { ?

Copy link
Member Author

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")
Copy link
Member

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

@@ -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
Copy link
Member

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?

Copy link
Member Author

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.

@@ -21,6 +21,9 @@ var _ kudoinit.InstallVerifier = &Installer{}
type Installer struct {
options kudoinit.Options
steps []kudoinit.Step

managerStep *manager.Initializer
Copy link
Member

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..

Copy link
Member Author

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

@@ -21,6 +21,9 @@ var _ kudoinit.InstallVerifier = &Installer{}
type Installer struct {
options kudoinit.Options
steps []kudoinit.Step
Copy link
Member

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.

Copy link
Member Author

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>
@ANeumann82 ANeumann82 merged commit 9a08e27 into main Aug 17, 2020
@ANeumann82 ANeumann82 deleted the an/wait-for-delete-uninstall-manager branch August 17, 2020 08:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Kudo init --upgrade should wait on deletion before proceeding with upgrade
3 participants