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

OCPBUGS-17157: *: detect when all objects are labelled, restart #3028

Conversation

stevekuznetsov
Copy link
Member

When all of the k8s objects that need labels have them, we are good to exit the process. The next Pod that start up will detect that all labels are present and be able to filter informers going forward.

@openshift-ci-robot openshift-ci-robot added jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. labels Sep 7, 2023
@openshift-ci-robot
Copy link
Collaborator

@stevekuznetsov: This pull request references Jira Issue OCPBUGS-17157, which is valid.

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

Requesting review from QA contact:
/cc @jianzhangbjz

The bug has been updated to refer to the pull request using the external bug tracker.

In response to this:

When all of the k8s objects that need labels have them, we are good to exit the process. The next Pod that start up will detect that all labels are present and be able to filter informers going forward.

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 openshift-ci bot requested a review from jianzhangbjz September 7, 2023 16:21
@stevekuznetsov stevekuznetsov force-pushed the skuznets/restart-process-fully-labelled branch 5 times, most recently from 4201200 to 99461d2 Compare September 11, 2023 13:49
@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 13, 2023
@stevekuznetsov stevekuznetsov force-pushed the skuznets/restart-process-fully-labelled branch from 99461d2 to 365a2ec Compare September 13, 2023 13:53
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 13, 2023
@stevekuznetsov stevekuznetsov force-pushed the skuznets/restart-process-fully-labelled branch from 365a2ec to e77fae7 Compare September 13, 2023 20:26
@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 19, 2023
@stevekuznetsov stevekuznetsov force-pushed the skuznets/restart-process-fully-labelled branch from e77fae7 to a079ab1 Compare September 20, 2023 14:49
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 20, 2023
@stevekuznetsov stevekuznetsov force-pushed the skuznets/restart-process-fully-labelled branch 6 times, most recently from 1ef8099 to c7f21a3 Compare September 21, 2023 13:25
Comment on lines +55 to +60
func ServiceAccountFilter(isServiceAccountReferenced func(namespace, name string) bool) func(object metav1.Object) bool {
return func(object metav1.Object) bool {
return HasOLMOwnerRef(object) || HasOLMLabel(object) || isServiceAccountReferenced(object.GetNamespace(), object.GetName())
}
}

Copy link
Member

Choose a reason for hiding this comment

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

Am I correct in assuming that these filters that are split out are used in special cases where we don't want (or can't) use the filters map?

If so, maybe call out the different use cases somehow? I'm a little concerned that a future commit might add something to the filters map that ends up being overwritten by some other code that blindly changes the map key to point to another function.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, these are special filters that can't be expressed in a simple way since they require other state inputs. When we're running these filters in the labelling controller, we can answer their other state needs with informers. When we're doing the at-startup check, though, we give them live client calls. I agree that it's easy to break this if you're not careful but I would suggest that we guard against that with careful review to this code in the future rather than some sort of super-clever coding paradigm. I don't know that this needs to get any more complex than it already is.

Copy link
Member

Choose a reason for hiding this comment

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

can't be expressed in a simple way since they require other state inputs.

Ah I see that now.

I would suggest that we guard against that with careful review to this code in the future rather than some sort of super-clever coding paradigm. I don't know that this needs to get any more complex than it already is.

Totally agree! But I don't think a helper function would add too much complexity:

type filtersMap map[schema.GroupVersionResource]func(metav1.Object) bool

func mustAddFilter(m filtersMap, gvr schema.GroupVersionResource, filter func(metav1.Object) bool) {
	if _, ok := m[gvr]; ok {
 		panic("programmer error: cannot add filter to map: already contains key " + gvr.String())
 	}
 	m[gvr] = filter
}

Copy link
Member Author

Choose a reason for hiding this comment

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

That function covers the one case of error, but the other and more insidious one is that you need to start & run every labeller you check for in Validate()

Copy link
Member

Choose a reason for hiding this comment

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

No super strong feelings here as long as we're confident we can page this knowledge in fairly easily in the future. Maybe just more well-placed comments is enough.

Signed-off-by: Steve Kuznetsov <[email protected]>
@joelanford
Copy link
Member

/lgtm
/approve

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Sep 28, 2023
@openshift-ci
Copy link

openshift-ci bot commented Sep 28, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: joelanford, perdasilva, stevekuznetsov

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:
  • OWNERS [joelanford,perdasilva]

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

@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Oct 3, 2023
@openshift-ci
Copy link

openshift-ci bot commented Oct 3, 2023

New changes are detected. LGTM label has been removed.

@openshift-ci-robot
Copy link
Collaborator

@stevekuznetsov: This pull request references Jira Issue OCPBUGS-17157, which is valid.

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

Requesting review from QA contact:
/cc @jianzhangbjz

In response to this:

When all of the k8s objects that need labels have them, we are good to exit the process. The next Pod that start up will detect that all labels are present and be able to filter informers going forward.

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.

@stevekuznetsov stevekuznetsov force-pushed the skuznets/restart-process-fully-labelled branch from 2f02237 to 3552193 Compare October 3, 2023 15:24
@stevekuznetsov stevekuznetsov added this pull request to the merge queue Oct 3, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 3, 2023
@stevekuznetsov stevekuznetsov added the lgtm Indicates that a PR is ready to be merged. label Oct 3, 2023
@stevekuznetsov stevekuznetsov added this pull request to the merge queue Oct 3, 2023
Merged via the queue into operator-framework:master with commit 03302ff Oct 3, 2023
15 checks passed
@openshift-ci-robot
Copy link
Collaborator

@stevekuznetsov: Jira Issue OCPBUGS-17157: Some pull requests linked via external trackers have merged:

The following pull requests linked via external trackers have not merged:

These pull request must merge or be unlinked from the Jira bug in order for it to move to the next state. Once unlinked, request a bug refresh with /jira refresh.

Jira Issue OCPBUGS-17157 has not been moved to the MODIFIED state.

In response to this:

When all of the k8s objects that need labels have them, we are good to exit the process. The next Pod that start up will detect that all labels are present and be able to filter informers going forward.

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. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants