-
Notifications
You must be signed in to change notification settings - Fork 23
GH-324 pollicyaffected condition for gateway #433
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: makslion The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/hold
The "how" part:
Also, invite @mikenairn to add more or correct me on this. |
ConditionTypeReady string = "Ready" | ||
ConditionTypeReady ConditionType = "Ready" | ||
|
||
DNSPolicyAffected ConditionType = "DNSPolicyAffected" |
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.
hmm I am wondering if this would be better in the dnspolicy package?
@@ -225,6 +236,49 @@ func (r *DNSPolicyReconciler) readyCondition(targetNetworkObjectectKind string, | |||
return cond | |||
} | |||
|
|||
func buildGatewayCondition(reason conditions.ConditionReason, err error) *metav1.Condition { |
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.
prob should name this buildDNSPolicyAffectedCondition
?
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.
or we could make it a bit more generic and add it to the conditions package
func buildPolicyAffectedCondition(conditionType conditions.ConditionType, policy metav1.Object, reason conditions.ConditionReason, err error) *metav1.Condition {
condition := &metav1.Condition{
Type: string(conditionType),
Status: metav1.ConditionTrue,
Reason: string(reason),
Message: fmt.Sprintf("%s policy affected. policy namespace %s policy name", conditionType, policy.Namespace, policy.Name),
}
if err != nil {
condition.Status = metav1.ConditionFalse
condition.Message = err.Error()
}
return condition
}
return condition | ||
} | ||
|
||
func (r *DNSPolicyReconciler) updateGatewayCondition(ctx context.Context, condition *metav1.Condition, gatewayDiff *reconcilers.GatewayDiff) error { |
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.
These seem like potentially generic for all policy controllers?
if err := r.reconcileDNSRecords(ctx, dnsPolicy, gatewayDiffObj); err != nil { | ||
if err = r.reconcileDNSRecords(ctx, dnsPolicy, gatewayDiffObj); err != nil { | ||
gatewayCondition = buildGatewayCondition(conditions.DNSPolicyReasonInvalid, err) | ||
_ = r.updateGatewayCondition(ctx, gatewayCondition, gatewayDiffObj) |
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.
not sure why we are ignoring the error here?
if err := r.reconcileHealthChecks(ctx, dnsPolicy, gatewayDiffObj); err != nil { | ||
if err = r.reconcileHealthChecks(ctx, dnsPolicy, gatewayDiffObj); err != nil { | ||
gatewayCondition = buildGatewayCondition(conditions.DNSPolicyReasonInvalid, err) | ||
_ = r.updateGatewayCondition(ctx, gatewayCondition, gatewayDiffObj) |
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.
same here and below. Not much point in returning an error if all we do is ignore it
@@ -357,7 +357,7 @@ var _ = Describe("DNSPolicy", Ordered, func() { | |||
return false | |||
} | |||
|
|||
return meta.IsStatusConditionTrue(dnsPolicy.Status.Conditions, conditions.ConditionTypeReady) | |||
return meta.IsStatusConditionTrue(dnsPolicy.Status.Conditions, string(conditions.ConditionTypeReady)) |
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.
why did we change the types here out of curiosity
closes #324
What
Reporting the state of the DNSPolicy to the Gateway affected by that policy
Verification