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

API-1835: Don't use Update in removestaleconditionscontroller #1864

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

bertinatto
Copy link
Member

@bertinatto bertinatto commented Oct 28, 2024

Proof: openshift/cluster-authentication-operator#729

Manual testing done:

  1. Introduced the removestaleconditions controller in https://github.com/openshift/gcp-pd-csi-driver-operator and marked the ManagementStateDegraded condition to be removed.
  2. Removed the managementstate controller from the operator.
  3. Watched the removestaleconditions controller remove the condition correctly.
  4. Added the managementstate controller back to the operator and watched both controller fighting.

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Oct 28, 2024
@openshift-ci-robot
Copy link

openshift-ci-robot commented Oct 28, 2024

@bertinatto: This pull request references API-1835 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the epic to target the "4.18.0" version, but no target version was set.

In response to this:

/hold
for proof and tests

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 openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 28, 2024
Copy link
Contributor

openshift-ci bot commented Oct 28, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bertinatto

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 openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 28, 2024
@bertinatto bertinatto changed the title API-1835: Migrate removestaleconditionscontroller to SSA API-1835: Don't use Update in removestaleconditionscontroller Oct 29, 2024
Copy link
Contributor

@p0lyn0mial p0lyn0mial left a comment

Choose a reason for hiding this comment

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

lgtm

conditions []string
operatorClient v1helpers.OperatorClient
controllerInstanceName string
conditions []string
Copy link
Contributor

Choose a reason for hiding this comment

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

please rename to conditionTypes or even conditionTypesToRemove

Copy link
Member Author

Choose a reason for hiding this comment

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

Renamed to conditionTypesToRemove

}
return factory.New().
ResyncEvery(time.Minute).
WithSync(c.sync).
WithInformers(operatorClient.Informer()).
ToController(
"RemoveStaleConditionsController", // don't change what is passed here unless you also remove the old FooDegraded condition
c.controllerInstanceName,
eventRecorder.WithComponentSuffix("remove-stale-conditions"),
)
}

func (c RemoveStaleConditionsController) sync(ctx context.Context, syncContext factory.SyncContext) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

would you mind adding some unit tests for the sync 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.

Added some unit tests (bases on the node status controller)

var removedCount int
jsonPatch := jsonpatch.New()
for i, existingCondition := range operatorStatus.Conditions {
for _, conditionToRemove := range c.conditions {
Copy link
Contributor

Choose a reason for hiding this comment

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

please rename to conditionTypeToRemove

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

}
jsonPatch.WithRemove(
fmt.Sprintf("/status/conditions/%d", removeAtIndex),
jsonpatch.NewTestCondition(fmt.Sprintf("/status/conditions/%d/type", removeAtIndex), conditionToRemove),
Copy link
Contributor

Choose a reason for hiding this comment

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

is there an e2e test that we could rely on ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not aware of any

@openshift-ci-robot
Copy link

openshift-ci-robot commented Oct 31, 2024

@bertinatto: This pull request references API-1835 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the epic to target the "4.18.0" version, but no target version was set.

In response to this:

/hold

Proof: openshift/cluster-authentication-operator#729
Also needs manual testing.

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 openshift-eng/jira-lifecycle-plugin repository.

Copy link
Contributor

openshift-ci bot commented Oct 31, 2024

@bertinatto: all tests passed!

Full PR test history. Your PR dashboard.

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-sigs/prow repository. I understand the commands that are listed here.

@openshift-ci-robot
Copy link

openshift-ci-robot commented Nov 1, 2024

@bertinatto: This pull request references API-1835 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the epic to target the "4.18.0" version, but no target version was set.

In response to this:

Proof: openshift/cluster-authentication-operator#729

Manual testing done:

  1. Introduced the removestaleconditions controller in https://github.com/openshift/gcp-pd-csi-driver-operator and marked the ManagementStateDegraded condition to be removed.
  2. Removed the managementstate controller from the operator.
  3. Watched the removestaleconditions controller remove the condition correctly.
  4. Added the managementstate controller back to the operator and watched both controller fighting.

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 openshift-eng/jira-lifecycle-plugin 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. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants