-
Notifications
You must be signed in to change notification settings - Fork 96
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
✨Adds a new controller to synchronize labels between BMHs and K Nodes #152
Conversation
Hi @Arvinderpal. Thanks for your PR. I'm waiting for a metal3-io member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
/ok-to-test |
1dd77b9
to
04aa457
Compare
@maelk I added the pause check for the BareMetalHost, Cluster and Metal3Cluster. Thanks. |
@dhellmann @maelk @zaneb |
04aa457
to
d05cc34
Compare
prefix, between BareMetalHost and Kubernetes Nodes.
d05cc34
to
3c3fd2b
Compare
// +kubebuilder:rbac:groups=metal3.io,resources=baremetalhosts,verbs=get;list;watch;create;update;patch;delete | ||
// +kubebuilder:rbac:groups=metal3.io,resources=baremetalhosts/status,verbs=get;update;patch | ||
// +kubebuilder:rbac:groups=infrastructure.cluster.x-k8s.io,resources=metal3machines,verbs=get;list;watch | ||
// +kubebuilder:rbac:groups=infrastructure.cluster.x-k8s.io,resources=metal3machines/status,verbs=get | ||
// +kubebuilder:rbac:groups=cluster.x-k8s.io,resources=machines;machines/status,verbs=get;list;watch | ||
// +kubebuilder:rbac:groups="",resources=events,verbs=get;list;watch;create;update;patch | ||
// +kubebuilder:rbac:groups="",resources=secrets,verbs=get;list;watch;create;update;patch;delete |
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.
do you need all those permissions ? I would highly recommend to trim them down
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.
Yes, you're right. I will only keep the read operations -- they are needed to fetch the kubeconfig of the target cluster.
} | ||
return ctrl.Result{}, err | ||
} | ||
if host.Annotations != nil && host.Annotations[bmh.PausedAnnotation] == baremetal.PausedAnnotationKey { |
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.
You should check on the presence of the annotation, not on the value. There might be other values set by the user (or empty string) so we should not care for it when checking for pause (like in capi)
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.
Done.
3c3fd2b
to
1121d0b
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.
@maelk Thanks for the review. Please take another look.
// +kubebuilder:rbac:groups=metal3.io,resources=baremetalhosts,verbs=get;list;watch;create;update;patch;delete | ||
// +kubebuilder:rbac:groups=metal3.io,resources=baremetalhosts/status,verbs=get;update;patch | ||
// +kubebuilder:rbac:groups=infrastructure.cluster.x-k8s.io,resources=metal3machines,verbs=get;list;watch | ||
// +kubebuilder:rbac:groups=infrastructure.cluster.x-k8s.io,resources=metal3machines/status,verbs=get | ||
// +kubebuilder:rbac:groups=cluster.x-k8s.io,resources=machines;machines/status,verbs=get;list;watch | ||
// +kubebuilder:rbac:groups="",resources=events,verbs=get;list;watch;create;update;patch | ||
// +kubebuilder:rbac:groups="",resources=secrets,verbs=get;list;watch;create;update;patch;delete |
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.
Yes, you're right. I will only keep the read operations -- they are needed to fetch the kubeconfig of the target cluster.
} | ||
return ctrl.Result{}, err | ||
} | ||
if host.Annotations != nil && host.Annotations[bmh.PausedAnnotation] == baremetal.PausedAnnotationKey { |
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.
Done.
@dhellmann @zaneb PTAL. |
Hey, @Arvinderpal Can you fix unit test issues ? Otherwise this patch looks good. |
|
@fmuyassarov PTAL at this PR. |
Seems you inserted the word inside the code block, and it did not work. /retest |
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.
Looks good to me, just some nits
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.
One last comment, otherwise looks good to me
capm3Machine := &capm3.Metal3Machine{} | ||
if err := r.Client.Get(context.TODO(), name, capm3Machine); err != nil { | ||
log.Error(err, "failed to get Metal3Machine") | ||
return nil |
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'm wondering if we should rather use "continue" here to not block the reconciliation on one machine. For example a user has scaled out a machine deployment but does not have enough BMH. If that machine is first in the list, it will always return on line 311. Using continue, would allow us to get past that.
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.
@maelk That's a good point. I had thought about this too and took the more conservative route. In addition to line 311, should we also use continue for 316 and 321?
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.
yes, I think for all exit conditions, we should instead use "continue"
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.
Done.
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 about line 306. There could be situations (though hopefully not frequent) where a machine was created without metal3machine (yet ?). We should probably use continue there too, no ?
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.
@maelk The if statement above "if m.Spec.InfrastructureRef.Name == nil", should catch the case where Machine exists but Metal3Machine does not. I suppose there is a rare corner case where InfrastructureRef is updated but Metal3Machine is not yet created. I will make the change.
/lgtm |
e9bdf05
to
5b3bab1
Compare
@fmuyassarov Can you issue /test-integration |
/test-integration |
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
/cc @maelk @kashifest
@Arvinderpal I have a nit, however, I think it could be good to go as is, and fixed afterwards, as you wish. I will approve the PR and put a hold. if you want to merge it and fix after, that's ok by me, since it's a detail, then jut remove the hold. But if you fix it in this PR, you'll just need another lgtm. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Arvinderpal, digambar15, maelk 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 |
Hum, my comment is not easily visible, it is regarding lne 306, where we should probably use a continue too. |
Metal3Cluster that defines prefix set. Only labels that fall within prefix set will be synchronized.
5b3bab1
to
2ca12f2
Compare
/retest |
Can someone kick off /test-integration for me? |
/test-integration |
/lgtm |
@maelk @fmuyassarov PTAL. Should be ready to merge. |
/hold cancel |
/test golint |
Introduces a new controller in CAPM3 to synchronize a specific set of labels placed on a BMH with those on the corresponding Kubernetes Node running on that BMH.
Design Proposal: metal3-io/metal3-docs#149
Example 1: Labels on BMH are added to the K Node
Example 2: Label changes directly on K Node will be reconciled: