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

Allow dns operator to be disabled with managementState field #260

Merged
merged 2 commits into from Jul 23, 2021

Conversation

rfredette
Copy link
Contributor

@rfredette rfredette commented Apr 8, 2021

this change allows resources normally managed by the dns operator to be left unmanaged when spec.managementState is set to Unmanaged. This will make debugging issues with dns resources easier

Also dependent on openshift/api PR #888 for API change

@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rfredette

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 the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 8, 2021
@Miciah
Copy link
Contributor

Miciah commented Apr 8, 2021

This is an excellent start! Two things:

  • You are adding logic to report the Upgradeable status condition on the dns object (dnses.operator.openshift.io/default), and we need the clusteroperator object (clusteroperators.config.openshift.io/dns) to report the Upgradeable status condition. The clusteroperator's status is computed by the status controller under pkg/operator/controller/status/controller.go. It can use status condition that you added to the dns object to compute the status condition on the clusteroperator object (basically just copy it from the dns to the clusteroperator).
  • We need to make sure that we handle an empty value for managementState. Please add a unit test TestComputeDNSProgressingCondition in pkg/operator/controller/dns_status_test.go to verify that your new computeDNSProgressingCondition function properly handles this case.

@Miciah
Copy link
Contributor

Miciah commented Apr 8, 2021

Sorry, I meant computeDNSUpgradeableCondition. Replace "Progressing" with "Upgradeable" in my previous comment.

@openshift-ci-robot
Copy link
Contributor

@rfredette: PR needs rebase.

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 needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 11, 2021
@openshift-bot
Copy link
Contributor

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@openshift-ci openshift-ci bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jul 10, 2021
@openshift-ci openshift-ci bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 19, 2021
@rfredette
Copy link
Contributor Author

/remove-lifecycle stale

@openshift-ci openshift-ci bot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jul 19, 2021
@rfredette
Copy link
Contributor Author

/retest

@rfredette
Copy link
Contributor Author

Updating github.com/openshift/build-machinery-go to v0.0.0-20210712174854-1bb7fd1518d3 is not a manual update; it is required in the github.com/openshift/api version update.

Copy link
Contributor

@Miciah Miciah left a comment

Choose a reason for hiding this comment

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

Overall looks good, just a few suggestions.

Comment on lines 349 to 352
var upgradeable bool
for _, cond := range dns.Status.Conditions {
if cond.Type == operatorv1.OperatorStatusTypeUpgradeable && cond.Status == operatorv1.ConditionTrue {
upgradeable = true
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably better to set Upgradeable=True if the DNS doesn't have an Upgradeable status condition:

Suggested change
var upgradeable bool
for _, cond := range dns.Status.Conditions {
if cond.Type == operatorv1.OperatorStatusTypeUpgradeable && cond.Status == operatorv1.ConditionTrue {
upgradeable = true
upgradeable := true
for _, cond := range dns.Status.Conditions {
if cond.Type == operatorv1.OperatorStatusTypeUpgradeable {
upgradeable = cond.Status == operatorv1.ConditionTrue

Type: configv1.OperatorUpgradeable,
Status: configv1.ConditionFalse,
Reason: "DNSNotUpgradeable",
Message: fmt.Sprintf("DNS %s is not upgradeable", dns.Name),
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be useful to include cond.Message from the DNS's status condition in the clusteroperator's status condition.

@@ -19,46 +19,72 @@ func TestDNSStatusConditions(t *testing.T) {
availDNS, desireDNS int32
haveNR bool
availNR, desireNR int32
isManaged bool
Copy link
Contributor

Choose a reason for hiding this comment

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

Besides Managed or Unmanaged, ManagementState also could be Force, Removed, or unset.

{testIn{true, true, 1, 3, true, 3, 3, false}, testOut{true, true, true, false}},
{testIn{true, true, 3, 3, true, 0, 3, false}, testOut{false, true, true, false}},
{testIn{true, true, 2, 3, true, 3, 3, false}, testOut{false, true, true, false}},
{testIn{true, true, 0, 1, true, 0, 1, false}, testOut{true, true, false, false}},
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't necessarily need to test every combination; a few test cases where ManagementState is not Managed should be fine.

}
if err := r.ensureDNSDeleted(dns); err != nil {
errs = append(errs, fmt.Errorf("failed to ensure deletion for dns %s: %v", dns.Name, err))
if dns.Spec.ManagementState != operatorv1.Unmanaged {
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think about switching the if and else so the simpler case (dns.Spec.ManagementState == operatorv1.Unmanaged) comes first? It might also make sense to use a switch statement (even if we only have two cases for now, case operatorv1.Unmanaged: and default:).

@Miciah
Copy link
Contributor

Miciah commented Jul 19, 2021

BTW, I usually squash commits and have just one commit with the vendor bump and make generate and a second commit with the implementation.

@rfredette
Copy link
Contributor Author

Thanks @Miciah. I agree with all your suggestions; the latest changes should have them all implemented.

@rfredette
Copy link
Contributor Author

/retest

1 similar comment
@rfredette
Copy link
Contributor Author

/retest

@rfredette
Copy link
Contributor Author

/retest-required

@rfredette
Copy link
Contributor Author

/retest

Comment on lines +179 to +190
var managementState string
switch tc.inputs.managementState {
case operatorv1.Managed:
managementState = "Managed"
case operatorv1.Force:
managementState = "Force"
case operatorv1.Removed:
managementState = "Removed"
case operatorv1.Unmanaged:
managementState = "Unmanaged"
}
description := fmt.Sprintf("%s, %d/%d DNS pods available, %d/%d node-resolver pods available, managementState is %s", haveClusterIP, tc.inputs.availDNS, tc.inputs.desireDNS, tc.inputs.availNR, tc.inputs.desireNR, managementState)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you use tc.inputs.managementState directly in the print statement?

Suggested change
var managementState string
switch tc.inputs.managementState {
case operatorv1.Managed:
managementState = "Managed"
case operatorv1.Force:
managementState = "Force"
case operatorv1.Removed:
managementState = "Removed"
case operatorv1.Unmanaged:
managementState = "Unmanaged"
}
description := fmt.Sprintf("%s, %d/%d DNS pods available, %d/%d node-resolver pods available, managementState is %s", haveClusterIP, tc.inputs.availDNS, tc.inputs.desireDNS, tc.inputs.availNR, tc.inputs.desireNR, managementState)
description := fmt.Sprintf("%s, %d/%d DNS pods available, %d/%d node-resolver pods available, managementState is %s", haveClusterIP, tc.inputs.availDNS, tc.inputs.desireDNS, tc.inputs.availNR, tc.inputs.desireNR, string(tc.inputs.managementState))

We can merge as-is leave that for a follow-up though.

@Miciah
Copy link
Contributor

Miciah commented Jul 23, 2021

Thanks!
/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jul 23, 2021
@openshift-merge-robot openshift-merge-robot merged commit a6bf664 into openshift:master Jul 23, 2021
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jul 23, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Miciah, rfredette

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

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. 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

5 participants