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

🌱 Remove and reinstall BMO in source cluster before and after pivot #838

Merged
merged 1 commit into from
Jul 3, 2023

Conversation

kashifest
Copy link
Member

@kashifest kashifest commented Jan 24, 2023

BMO is caching the old node states after pivoting back and that might be the cause to the flake where the bmh is not deleted in centos this PR tries to solve the issue by reinstating bmo after moving back to source cluster

@metal3-io-bot metal3-io-bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jan 24, 2023
@kashifest
Copy link
Member Author

/test-ubuntu-e2e-main
/test-centos-e2e-main
/test-upgrade-e2e-main

@kashifest
Copy link
Member Author

/test-ubuntu-e2e-main
/test-centos-e2e-main
/test-upgrade-e2e-main

@kashifest
Copy link
Member Author

/retest

@kashifest
Copy link
Member Author

/test-ubuntu-e2e-main
/test-upgrade-e2e-main

@furkatgofurov7
Copy link
Member

/retest

@furkatgofurov7
Copy link
Member

/test generate

@kashifest
Copy link
Member Author

/retest

@kashifest
Copy link
Member Author

/test all

@kashifest
Copy link
Member Author

/test-ubuntu-e2e-main
/test-centos-e2e-main
/test-upgrade-e2e-main

1 similar comment
@kashifest
Copy link
Member Author

/test-ubuntu-e2e-main
/test-centos-e2e-main
/test-upgrade-e2e-main

@kashifest
Copy link
Member Author

/keep-test-ubuntu-integration-e2e-main

@kashifest
Copy link
Member Author

/test-ubuntu-e2e-main
/test-centos-e2e-main
/test-upgrade-e2e-main

@kashifest
Copy link
Member Author

/test-ubuntu-e2e-main
/test-centos-e2e-main
/test-upgrade-e2e-main

@kashifest
Copy link
Member Author

/test-centos-e2e-main
/test-upgrade-e2e-main

@kashifest
Copy link
Member Author

/test-ubuntu-e2e-main
/test-centos-e2e-main
/test-upgrade-e2e-main

@kashifest
Copy link
Member Author

/test-ubuntu-e2e-main
/test-centos-e2e-main
/test-upgrade-e2e-main

@kashifest
Copy link
Member Author

/test-centos-e2e-main

@kashifest
Copy link
Member Author

/test-centos-e2e-main
/test-upgrade-e2e-main

@kashifest
Copy link
Member Author

/test-upgrade-e2e-main

3 similar comments
@kashifest
Copy link
Member Author

/test-upgrade-e2e-main

@kashifest
Copy link
Member Author

/test-upgrade-e2e-main

@kashifest
Copy link
Member Author

/test-upgrade-e2e-main

@kashifest
Copy link
Member Author

/test-ubuntu-integration-main

@@ -33,6 +33,7 @@ const (
ironicBasicAuth = "IRONIC_BASIC_AUTH"
Kind = "kind"
NamePrefix = "NAMEPREFIX"
NameSuffix = "NAMESUFFIX"
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 not used.

Suggested change
NameSuffix = "NAMESUFFIX"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is used, check RemoveIronicBMOInput below

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is different. It is defined in the struct here

This is a constant that is never referenced. The other constants above are used to get the value from the e2e config as in

NamePrefix: input.E2EConfig.GetVariable(NamePrefix),

But this NameSuffix does not exist in the e2e config so we never take it from there.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true, good catch! I will remove it, with other change

Comment on lines 102 to 121
iNamespace := &corev1.Namespace{
ObjectMeta: metav1.ObjectMeta{
Name: input.E2EConfig.GetVariable(ironicNamespace),
},
}
_, err := targetClusterClientSet.CoreV1().Namespaces().Create(ctx, ironicNamespace, metav1.CreateOptions{})
_, err := targetClusterClientSet.CoreV1().Namespaces().Create(ctx, iNamespace, metav1.CreateOptions{})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why change the variable name? I think it was easier to understand before. iNamespace is harder to understand. Is it "in namespace" or "ironic namespace" or "input namespace"? 🤷

Copy link
Member Author

@kashifest kashifest Jan 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you see closely, it is creating a Namespace out of the ironicNameSpace value and previously it was assigning it to ironicNameSpace var only. That was ok since ironicNameSpace was not needed as a string later. Now that we need it, simply converting it to string didn't work. So a rename was needed. And it is used in line 102 and 107 only.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see! What if we rename ironicNamespace -> ironicNamespaceName or ironicNamespaceVar (since it is the variable where we get the name from) and then this can be ironicNamespace?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}

func removeIronic(ctx context.Context, inputGetter func() RemoveIronicInput) {
func removeIronicBMO(ctx context.Context, inputGetter func() RemoveIronicBMOInput) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is starting to feel a bit messy. It is almost a generic function for deleting a Deployment, but it also tries to handle the case when Ironic is running outside the cluster. If we combine the remove BMO part with IsDeployment=false, we get complete nonsense. Also, if we fail to delete the Deployment we get an error that it failed to delete Ironic (even if we tried to delete BMO).

I think a cleaner solution would be to separate out the case when Ironic is running outside the cluster, e.g. removeLocalIronic. Then this function can be a generic deleteDeployment function. No need for the prefix/suffix either, just take the name as input.

What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

combining ironic local and deployment deletion in one function was there before. I am not adding that functionality here. I am adding BMO removal only. And since we know its always a deployment we always hardcode the isDeployment to true. Expecting common sense from developer here. Since a developer can also try to delete ironic deployment while it was deployed locally. One good point raised by you is the error message at line 304. We can add the deployment or component name to be deleted which I missed out .

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

combining ironic local and deployment deletion in one function was there before

I know, but adding BMO to this makes it harder to understand and easier to make mistakes. Splitting it into two functions was just a suggestion for how to make it cleaner, we can go the other way also. Then I would suggest to make it "smarter", similar to installIronicBMO. Add to the input a variable that tells if it is BMO or Ironic we are dealing with, then use it to set the other parameters that are already known, e.g. prefix/suffix. We also know that BMO is never deployed locally in this context so check and error out if we get this combination.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am in favor of keeping the function core as it is now as both ironic and bmo have the same lifecycle and do the refactoring later on?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that might be this work will not solve the centos issue to delete bmh and then I would prefer to revert this changes

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not understanding the issue. Why make a messy implementation that we have to fix in the future when we can make a nice implementation? Both of them can easily be reverted but only one have to be improved.

Just think about how the function is used. I want to remove BMO, ok removeIronicBMO sounds good. What does it take as input? Name suffix, what is this? Why should I have to know this to remove BMO? I just want to say if I want to remove BMO or Ironic.

I stand my ground. This must be simplified. Either split it into separate functions or make it "smarter" so it is harder to shoot yourself in the foot.

Copy link
Member Author

@kashifest kashifest Apr 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just think about how the function is used. I want to remove BMO, ok removeIronicBMO sounds good. What does it take as input? Name suffix, what is this? Why should I have to know this to remove BMO? I just want to say if I want to remove BMO or Ironic.

I didn't get your point here, this is not asked from user. Theres bunch of other similar suffix, prefix parameter in the same file here. You as a user dont need to know, you as a developer will always code the name to delete no matter how simplified the function is. Suffix is a part of it.

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 can agree on one point , this might be a bit difficult to understand in future since ironic is deployed locally and in deployment while BMO is only deployed as a deployment. So for BMO isDeployment var doesn’t make any sense and leaves room for mistakes. Splitting it in two functions increases readability and understanding of the code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is always a user. The user of the function is the developer. And no, the developer does not need to know the suffix and should not need to think about this. It is always -controller-manager for BMO and -ironic for Ironic. This can be taken care of by the function.

Alternatively, if you want to keep the flexibility of setting the exact name, then just make a generic function that can delete any deployment by giving a name. I'm also fine with that. But mixing it in one function is not nice.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is always a user. The user of the function is the developer. And no, the developer does not need to know the suffix and should not need to think about this. It is always -controller-manager for BMO and -ironic for Ironic. This can be taken care of by the function.

Hummm, I don’t think I agree. let’s agree to disagree here. Atleast we agree we need separate functions :)

@tuminoid
Copy link
Member

Please add proper description and commit message.

@mboukhalfa
Copy link
Member

/test-centos-e2e-feature-main

2 similar comments
@mboukhalfa
Copy link
Member

/test-centos-e2e-feature-main

@mboukhalfa
Copy link
Member

/test-centos-e2e-feature-main

@mboukhalfa
Copy link
Member

/test-ubuntu-integration-main
/test-centos-e2e-integration-main

@kashifest
Copy link
Member Author

I know its going to fail but just running it so that we can see it as a test in github.
/test-ubuntu-integration-release-1-4

@kashifest
Copy link
Member Author

I know its going to fail but just running it so that we can see it as a test in github. /test-ubuntu-integration-release-1-4

Funny enough, it passed

@mboukhalfa
Copy link
Member

/test-centos-e2e-integration-main

@mboukhalfa
Copy link
Member

/test-centos-e2e-integration-main

1 similar comment
@mboukhalfa
Copy link
Member

/test-centos-e2e-integration-main

@mboukhalfa
Copy link
Member

/keep-test-centos-e2e-integration-main

@mboukhalfa
Copy link
Member

/keep-test-centos-e2e-integration-main

@mboukhalfa
Copy link
Member

/test-centos-e2e-integration-main

@mboukhalfa
Copy link
Member

/test-ubuntu-integration-main

@mboukhalfa
Copy link
Member

/assign @furkatgofurov7

@metal3-io-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: furkatgofurov7

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@metal3-io-bot metal3-io-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 3, 2023
Copy link
Member

@Sunnatillo Sunnatillo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@metal3-io-bot metal3-io-bot added the lgtm Indicates that a PR is ready to be merged. label Jul 3, 2023
@metal3-io-bot metal3-io-bot merged commit 4ba5131 into metal3-io:main Jul 3, 2023
3 checks passed
@kashifest kashifest deleted the add-remove-bmo-pivot branch August 29, 2023 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants