Skip to content

Commit

Permalink
Partially Enforced sets Enforced status to true (#679)
Browse files Browse the repository at this point in the history
  • Loading branch information
maksymvavilov authored May 30, 2024
1 parent 0e2a9d6 commit dc98cab
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion controllers/dnspolicy_controller_single_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ var _ = Describe("DNSPolicy Single Cluster", func() {
g.Expect(dnsPolicy.Status.Conditions).To(
ContainElement(MatchFields(IgnoreExtras, Fields{
"Type": Equal(string(kuadrant.PolicyConditionEnforced)),
"Status": Equal(metav1.ConditionFalse),
"Status": Equal(metav1.ConditionTrue),
"Reason": Equal(string(kuadrant.PolicyReasonEnforced)),
"Message": Equal("DNSPolicy has been partially enforced"),
})),
Expand Down
2 changes: 1 addition & 1 deletion controllers/dnspolicy_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ var _ = Describe("DNSPolicy controller", func() {
}),
MatchFields(IgnoreExtras, Fields{
"Type": Equal(string(kuadrant.PolicyConditionEnforced)),
"Status": Equal(metav1.ConditionFalse),
"Status": Equal(metav1.ConditionTrue),
"Reason": Equal(string(kuadrant.PolicyReasonEnforced)),
"Message": Equal("DNSPolicy has been partially enforced"),
})),
Expand Down
2 changes: 1 addition & 1 deletion controllers/dnspolicy_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func (r *DNSPolicyReconciler) enforcedCondition(recordsList *kuadrantdnsv1alpha1
}
}

// at least one DNS record is controlled byt the policy
// at least one DNS record is controlled by the policy
// and all controlled records are accepted
if controlled {
return kuadrant.EnforcedCondition(dnsPolicy, nil, true)
Expand Down
4 changes: 1 addition & 3 deletions pkg/library/kuadrant/apimachinery_status_conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,12 @@ func AcceptedCondition(p Policy, err error) *metav1.Condition {
func EnforcedCondition(policy Policy, err PolicyError, allSubresourcesReady bool) *metav1.Condition {
// Enforced
message := fmt.Sprintf("%s has been successfully enforced", policy.Kind())
status := metav1.ConditionTrue
if !allSubresourcesReady {
message = fmt.Sprintf("%s has been partially enforced", policy.Kind())
status = metav1.ConditionFalse
}
cond := &metav1.Condition{
Type: string(PolicyConditionEnforced),
Status: status,
Status: metav1.ConditionTrue,
Reason: string(PolicyReasonEnforced),
Message: message,
}
Expand Down

0 comments on commit dc98cab

Please sign in to comment.