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

Bug 1930791: [wmco] Stop adding pub-key-hash label to all nodes #323

Merged
merged 1 commit into from Mar 4, 2021

Conversation

sebsoto
Copy link
Contributor

@sebsoto sebsoto commented Mar 1, 2021

This commit fixes an issue where the public key hash annotation was being
added to not all nodes, not just Windows nodes. This commit also adds
logic to remove the annotation from Linux nodes when the operator is
installed.

As part of this fix, Windows node selection in the secret controller
now uses the label "kubernetes.io/os=windows". There is a mix of this
label and "node.openshift.io/os_id=Windows" in the node selection logic
throughout WMCO, and we should move towards just using one. Future work
should be done to only use the "kubernetes.io/os" label for node
selection throughout WMCO.

@sebsoto sebsoto changed the title [wmco] Stop adding pub-key-hash label to all nodes [WIP] [wmco] Stop adding pub-key-hash label to all nodes Mar 1, 2021
@openshift-ci-robot openshift-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 1, 2021
@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 1, 2021
@sebsoto
Copy link
Contributor Author

sebsoto commented Mar 1, 2021

/approve cancel

@openshift-ci-robot openshift-ci-robot removed the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 1, 2021
@sebsoto sebsoto changed the title [WIP] [wmco] Stop adding pub-key-hash label to all nodes Bug 1930791: [wmco] Stop adding pub-key-hash label to all nodes Mar 2, 2021
@openshift-ci-robot openshift-ci-robot added bugzilla/severity-high Referenced Bugzilla bug's severity is high for the branch this PR is targeting. and removed do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels Mar 2, 2021
@openshift-ci-robot
Copy link

@sebsoto: This pull request references Bugzilla bug 1930791, which is valid. The bug has been moved to the POST state. The bug has been updated to refer to the pull request using the external bug tracker.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.8.0) matches configured target release for branch (4.8.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

Bug 1930791: [wmco] Stop adding pub-key-hash label to all nodes

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.

@openshift-ci-robot openshift-ci-robot added the bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. label Mar 2, 2021
@sebsoto sebsoto changed the title Bug 1930791: [wmco] Stop adding pub-key-hash label to all nodes Bug 1934281: [wmco] Stop adding pub-key-hash label to all nodes Mar 2, 2021
@openshift-ci-robot
Copy link

@sebsoto: This pull request references Bugzilla bug 1934281, which is valid. The bug has been moved to the POST state. The bug has been updated to refer to the pull request using the external bug tracker.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.8.0) matches configured target release for branch (4.8.0)
  • bug is in the state NEW, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

Bug 1934281: [wmco] Stop adding pub-key-hash label to all nodes

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.

@sebsoto sebsoto changed the title Bug 1934281: [wmco] Stop adding pub-key-hash label to all nodes Bug 1930791: [wmco] Stop adding pub-key-hash label to all nodes Mar 2, 2021
@openshift-ci-robot
Copy link

@sebsoto: This pull request references Bugzilla bug 1930791, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.8.0) matches configured target release for branch (4.8.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

Bug 1930791: [wmco] Stop adding pub-key-hash label to all nodes

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.

Copy link
Contributor

@aravindhp aravindhp left a comment

Choose a reason for hiding this comment

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

Thanks for working on this, @sebsoto. Please address my comments.

@@ -180,7 +184,13 @@ func (r *ReconcileSecret) Reconcile(request reconcile.Request) (reconcile.Result
return reconcile.Result{}, errors.Wrap(err, "error creating signer from private key")
}
nodes := &core.NodeList{}
err = r.client.List(context.TODO(), nodes, client.HasLabels{nodeconfig.WindowsOSLabel})
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't you do the equivalent of tc.client.K8s.CoreV1().Nodes().List(context.TODO(), metav1.ListOptions{LabelSelector: nodeconfig.WindowsOSLabel}) that we have in our e2e tests? i.e use the label selector.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I ended up taking @VaishnaviHire suggestion and using the core.LabelOSStable label which makes this simpler

Copy link
Contributor

Choose a reason for hiding this comment

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

While I am fine with the change, it has again been made silently. Please call this out in the commit message. Also add a follow up story to replace nodeconfig.WindowsOSLabel with core.LabelOSStable

@@ -213,6 +223,28 @@ func (r *ReconcileSecret) Reconcile(request reconcile.Request) (reconcile.Result
}
}

// removeDepreciatedAnnotations corrects annotations applied by previous versions of WMCO.
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest renaming this to removeInvalidAnnotationsFromLinuxNodes or something to that effect. Please mention the annotation that you are deleting. I don't see any reason to future proof given this is just a helper.

// removeDepreciatedAnnotations corrects annotations applied by previous versions of WMCO.
func (r *ReconcileSecret) removeDepreciatedAnnotations() error {
nodes := &core.NodeList{}
err := r.client.List(context.TODO(), nodes)
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't you just list Linux nodes?

controllers/secret/secret_controller.go Show resolved Hide resolved
Comment on lines 237 to 238
if _, present := node.Annotations[nodeconfig.PubKeyHashAnnotation]; present == true &&
node.Labels[core.LabelOSStable] != "windows" {
Copy link
Contributor

Choose a reason for hiding this comment

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

If you only list Linux nodes using the label selector you won't have to do this check.

Copy link
Contributor

@VaishnaviHire VaishnaviHire left a comment

Choose a reason for hiding this comment

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

@sebsoto Thanks for the fix. PTAL at my comments:

Commit message needs to be updated to annotation was being added to all nodes,

err = r.client.List(context.TODO(), nodes, client.HasLabels{nodeconfig.WindowsOSLabel})
// The controller-runtime client requires a map for label matching, so the Windows identifying label var needs
// to be split into a key/value pair.
windowsLabelKeyValuePair := strings.SplitN(nodeconfig.WindowsOSLabel, "=", 2)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we use core.LabelOSStable as we are doing in windows_machine controller ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was considering making this change but was on the fence about it. Since we are using it in the node mapper I'm happy to use it here.

@sebsoto sebsoto force-pushed the labelBug branch 3 times, most recently from 7373048 to b2ad5da Compare March 3, 2021 15:18
@VaishnaviHire
Copy link
Contributor

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 3, 2021
Copy link
Contributor

@aravindhp aravindhp left a comment

Choose a reason for hiding this comment

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

/approve

with the caveat that you address the minor comments.

@@ -180,7 +184,13 @@ func (r *ReconcileSecret) Reconcile(request reconcile.Request) (reconcile.Result
return reconcile.Result{}, errors.Wrap(err, "error creating signer from private key")
}
nodes := &core.NodeList{}
err = r.client.List(context.TODO(), nodes, client.HasLabels{nodeconfig.WindowsOSLabel})
Copy link
Contributor

Choose a reason for hiding this comment

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

While I am fine with the change, it has again been made silently. Please call this out in the commit message. Also add a follow up story to replace nodeconfig.WindowsOSLabel with core.LabelOSStable

@@ -59,6 +59,10 @@ func newReconciler(mgr manager.Manager) (reconcile.Reconciler, error) {
}

reconciler := &ReconcileSecret{client: client, scheme: mgr.GetScheme()}
if err = reconciler.removeInvalidAnnotationsFromLinuxNodes(); err != nil {
log.Error(err, "unable to clean up annotations from previous WMCO versions")
Copy link
Contributor

Choose a reason for hiding this comment

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

...annotations on Linux nodes...

@aravindhp
Copy link
Contributor

/hold
so that you can address the comments.

@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: aravindhp

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

@openshift-ci-robot openshift-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Mar 3, 2021
This commit fixes an issue where the public key hash annotation was being
added to not all nodes, not just Windows nodes. This commit also adds
logic to remove the annotation from Linux nodes when the operator is
installed.

As part of this fix, Windows node selection in the secret controller
now uses the label "kubernetes.io/os=windows". There is a mix of this
label and "node.openshift.io/os_id=Windows" in the node selection logic
throughout WMCO, and we should move towards just using one. Future work
should be done to only use the "kubernetes.io/os" label for node
selection throughout WMCO.
@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Mar 3, 2021
@openshift-ci-robot
Copy link

@sebsoto: This pull request references Bugzilla bug 1930791, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.8.0) matches configured target release for branch (4.8.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

Bug 1930791: [wmco] Stop adding pub-key-hash label to all nodes

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.

@VaishnaviHire
Copy link
Contributor

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 3, 2021
@sebsoto
Copy link
Contributor Author

sebsoto commented Mar 3, 2021

/hold cancel

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 3, 2021
@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

1 similar comment
@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot openshift-merge-robot merged commit 1b5f54b into openshift:master Mar 4, 2021
@openshift-ci-robot
Copy link

@sebsoto: All pull requests linked via external trackers have merged:

Bugzilla bug 1930791 has been moved to the MODIFIED state.

In response to this:

Bug 1930791: [wmco] Stop adding pub-key-hash label to all nodes

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.

@sebsoto
Copy link
Contributor Author

sebsoto commented Mar 31, 2021

/cherry-pick release-4.7

@openshift-cherrypick-robot

@sebsoto: new pull request created: #370

In response to this:

/cherry-pick release-4.7

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.

@sebsoto
Copy link
Contributor Author

sebsoto commented Mar 31, 2021

/cherry-pick community-4.7

@openshift-cherrypick-robot

@sebsoto: new pull request created: #371

In response to this:

/cherry-pick community-4.7

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.

wgahnagl pushed a commit to wgahnagl/windows-machine-config-operator that referenced this pull request Mar 6, 2023
Run hybrid-overlay as a Windows service in e2e tests
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. bugzilla/severity-high Referenced Bugzilla bug's severity is high for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants