-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
✨ Moved MachineDeployment Cluster Label Name to webhook #2308
Conversation
a90594a
to
6a69912
Compare
g.Expect(md.Spec.Selector.MatchLabels).To(HaveKeyWithValue(clusterv1.ClusterLabelName, "test-md")) | ||
g.Expect(md.Spec.Template.Labels).To(HaveKeyWithValue(clusterv1.ClusterLabelName, "test-md")) |
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.
@hpandeycodeit You probably need to remove clusterv1.ClusterLabelName
and add ClusterLabelName
instead.
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.
thanks! changed it :)
0b0adeb
to
9570ca2
Compare
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.
/approve
Linter is failing with
controllers/machinedeployment_controller.go:151: File is not `gofmt`-ed with `-s` (gofmt)
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: hpandeycodeit, vincepri 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 |
MatchLabels: map[string]string{ | ||
ClusterLabelName: "test-cluster", | ||
}, | ||
}, |
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.
Specifying the Selector here is causing the test failure: line 49 is checking for the MachineDeploymentLabelName key which is only set if there is not a Selector already defined.
It might be good to add a separate test that specifies md.Spec.Selector.MatchLabels and md.Spec.Template.Labels and verifies that the MachineDeployment labels are not added, while the ClusterLabelName ones are.
/milestone v0.3.0-rc.1 |
@hpandeycodeit Are still interested to get this change merged? |
yes. will make the suggested changes today. |
@hpandeycodeit LGTM pending squash |
/milestone v0.3.0 |
df2c99f
to
0bedc08
Compare
/test pull-cluster-api-test |
There were some assumptions in the tests that this change breaks. The tests have two choices. Either implement webhooks in the envtest set of tests or ensure that when we create machine deployments they always have the right label/selectors applied. Here is a diff required to get these tests to passing: diff --git a/controllers/machinedeployment_controller_test.go b/controllers/machinedeployment_controller_test.go
index b947d3b7e..ccf1fc86a 100644
--- a/controllers/machinedeployment_controller_test.go
+++ b/controllers/machinedeployment_controller_test.go
@@ -62,19 +62,29 @@ var _ = Describe("MachineDeployment Reconciler", func() {
})
It("Should reconcile a MachineDeployment", func() {
- labels := map[string]string{"foo": "bar"}
+ labels := map[string]string{
+ "foo": "bar",
+ clusterv1.ClusterLabelName: testCluster.Name,
+ }
version := "1.10.3"
deployment := &clusterv1.MachineDeployment{
ObjectMeta: metav1.ObjectMeta{
GenerateName: "md-",
Namespace: namespace.Name,
+ Labels: map[string]string{
+ clusterv1.ClusterLabelName: testCluster.Name,
+ },
},
Spec: clusterv1.MachineDeploymentSpec{
ClusterName: testCluster.Name,
MinReadySeconds: pointer.Int32Ptr(0),
Replicas: pointer.Int32Ptr(2),
RevisionHistoryLimit: pointer.Int32Ptr(0),
- Selector: metav1.LabelSelector{},
+ Selector: metav1.LabelSelector{
+ MatchLabels: map[string]string{
+ clusterv1.ClusterLabelName: testCluster.Name,
+ },
+ },
Strategy: &clusterv1.MachineDeploymentStrategy{
Type: clusterv1.RollingUpdateMachineDeploymentStrategyType,
RollingUpdate: &clusterv1.MachineRollingUpdateDeployment{
@@ -306,7 +316,8 @@ var _ = Describe("MachineDeployment Reconciler", func() {
oldLabels[clusterv1.MachineDeploymentLabelName] = deployment.Name
newLabels := map[string]string{
- "new-key": "new-value",
+ "new-key": "new-value",
+ clusterv1.ClusterLabelName: testCluster.Name,
}
By("Updating MachineDeployment label") |
if you apply that patch or any similar patch that gets the tests passing @hpandeycodeit, this lgtm. |
Thanks @chuckha I have applied this patch! |
/lgtm |
/hold |
Sorry, just noticed this wasn't squashed, can you squash this down to 1 commit please? |
fix the import issue Minor change to the test gofmted the file Added separate test case for labels Modified the MachineDeployment reconcile test, added labels, selectors
578f570
to
dab38c8
Compare
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.
/lgtm
@chuckha to unhold
/hold cancel |
@hpandeycodeit: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
What this PR does / why we need it:
Moved MachineDeployment Cluster Label Name to webhook as per #2302
Which issue(s) this PR fixes :
Fixes #2302