Skip to content

✨ Apply labels to Machines if they're part of a MD or MS #1701

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

Closed

Conversation

tahsinrahman
Copy link
Contributor

What this PR does / why we need it:

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #1695

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Oct 31, 2019
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 31, 2019
@vincepri
Copy link
Member

/assign

@tahsinrahman tahsinrahman force-pushed the add-machine-labels branch 2 times, most recently from f1cb7da to aabc18a Compare October 31, 2019 14:55
Copy link
Member

@vincepri vincepri left a comment

Choose a reason for hiding this comment

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

/approve
/assign @detiber @ncdc

for final LGTM

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: tahsinrahman, 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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 31, 2019
@vincepri
Copy link
Member

/milestone v0.3.0

@k8s-ci-robot k8s-ci-robot added this to the v0.3.0 milestone Oct 31, 2019
@@ -181,6 +182,37 @@ func (r *MachineReconciler) reconcile(ctx context.Context, cluster *clusterv1.Cl
return res, kerrors.NewAggregate(errs)
}

func (r *MachineReconciler) reconcileLables(ctx context.Context, m *clusterv1.Machine) error {
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 wondering if these labels should be added at the same time we are adding the ownerreferences in the MachineSet/MachineDeployment.

For example, on the MachineDeployment, we could add the label for the machinedeployment to the MachineSet, but also update the labelselector and the labels applied on the MachineSet. We could do similar in the MachineSet as well.

I'm thinking that if we go this route, since we are already adding the cluster-name label, then we could potentially even remove the need for a user-specified label selector.

@vincepri thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

That was my first idea as well, it's quite different from what this PR is doing though. We can possibly follow-up to improve this in a different PR and move the logic in the MS/MD controllers?

Copy link
Contributor Author

@tahsinrahman tahsinrahman Oct 31, 2019

Choose a reason for hiding this comment

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

@detiber @vincepri thanks for your suggestions! lets close/redo it

We can actually add these following lines in getNewMachine(), it'll be a lot simpler than now!

machine.Labels[clusterv1.MachineSetLabelName] = machineSet.Name
if md := metav1.GetControllerOf(machineSet); md != nil {
	machine.Labels[clusterv1.MachineDeploymentLabelName] = md.Name
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

filed this draft pr!
#1711

@tahsinrahman
Copy link
Contributor Author

closing in favor of #1711
/close

@k8s-ci-robot
Copy link
Contributor

@tahsinrahman: Closed this PR.

In response to this:

closing in favor of #1711
/close

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.

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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Apply labels to Machines if they're part of a MD or MS
5 participants