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
Allow dns operator to be disabled with managementState field #260
Conversation
[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 |
This is an excellent start! Two things:
|
Sorry, I meant |
2909f8a
to
baf9663
Compare
@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. |
Issues go stale after 90d of inactivity. Mark the issue as fresh by commenting If this issue is safe to close now please do so with /lifecycle stale |
baf9663
to
5387044
Compare
/remove-lifecycle stale |
/retest |
5387044
to
01b23d7
Compare
Updating |
There was a problem hiding this 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.
var upgradeable bool | ||
for _, cond := range dns.Status.Conditions { | ||
if cond.Type == operatorv1.OperatorStatusTypeUpgradeable && cond.Status == operatorv1.ConditionTrue { | ||
upgradeable = true |
There was a problem hiding this comment.
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:
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), |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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}}, |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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:
).
BTW, I usually squash commits and have just one commit with the vendor bump and |
01b23d7
to
7fe06da
Compare
Thanks @Miciah. I agree with all your suggestions; the latest changes should have them all implemented. |
/retest |
1 similar comment
/retest |
/retest-required |
/retest |
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) |
There was a problem hiding this comment.
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?
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.
Thanks! |
[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 |
this change allows resources normally managed by the dns operator to be left unmanaged when
spec.managementState
is set toUnmanaged
. This will make debugging issues with dns resources easierAlso dependent on openshift/api PR #888 for API change