-
Notifications
You must be signed in to change notification settings - Fork 23
gh-628 fix deletion of dnsrecord and certificates on deletion of gateway target for dnspolicy and tlspolicy #635
Conversation
49d26a2
to
2e1971e
Compare
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.
Looks good, just a couple of small changes that i think we need to make sure we aren't deleting the wrong resources when processing the gateways that have an invalid policy ref.
pkg/controllers/tlspolicy/tlspolicy_certmanager_certificates.go
Outdated
Show resolved
Hide resolved
2e1971e
to
6b7a63f
Compare
6b7a63f
to
7377256
Compare
pkg/controllers/tlspolicy/tlspolicy_certmanager_certificates.go
Outdated
Show resolved
Hide resolved
7377256
to
6a9d91e
Compare
…n of gateway target for dnspolicy and tlspolicy
6a9d91e
to
b9d615a
Compare
EDIT: e2e test are passing now. Seems it was intermittent/unrelated. Aside from this feedback has been addressed and verification steps are updated. I will keep investigating the failure but it seems intermittent and unrelated. cc @mikenairn |
func (r *TLSPolicyReconciler) deleteGatewayCertificates(ctx context.Context, gateway *gatewayv1beta1.Gateway, tlsPolicy *v1alpha1.TLSPolicy) error { | ||
return r.deleteUnexpectedGatewayCertificates(ctx, []*certmanv1.Certificate{}, gateway, tlsPolicy) | ||
func (r *TLSPolicyReconciler) deleteGatewayCertificates(ctx context.Context, expectedCerts []*certmanv1.Certificate, gateway *gatewayv1beta1.Gateway, tlsPolicy *v1alpha1.TLSPolicy) error { | ||
return r.deleteCertificatesWithLabels(ctx, expectedCerts, commonTLSCertificateLabels(client.ObjectKeyFromObject(gateway), client.ObjectKeyFromObject(tlsPolicy)), tlsPolicy.Namespace) |
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.
Any reason you have removed the deleteUnexpectedGatewayCertificates
method here, but chose to keep deleteUnexpectedGatewayProbes
in the dnspolicy_healthchecks reconcile?
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.
My thinking at the time was to bring it in line with the DNSRecords reconciliation, but looking at it now it makes sense to keep it. I'm bringing the three more in line with each other so I'll return the unexpectedcertificates to match the unexpectedhealthcheckprobes. Doesn't seem a need for it in the dnsrecords reconciliation though so I wont add it there. Commit coming soon.
@laurafitzgerald Looks good to me. Left a couple of comments, will let you reply to those before sticking the lgtm on it. |
…s in line with each other
return fmt.Errorf("error creating and updating expected certificates for gateway %v: %w", gw.Gateway.Name, err) | ||
} | ||
if err := r.deleteUnexpectedCertificates(ctx, expectedCertificates, gw.Gateway, tlsPolicy); err != nil { | ||
return fmt.Errorf("error removing unexpected certificate for gateway %v: %w", gw.Gateway.Name, err) | ||
} | ||
} |
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.
Personally i kind of preferred the pattern this (and DNSRecord) was using of having a reconcileGateway<Resource> method that deals with reconciling resources for a given Gateway instead of having it broken up inside the main reconcile<Resource> method.
- reconcile<Resource> - Reconcile resources(create/update/delete) for the current policy
- reconcileGateway<Resource> - Reconcile resources(create/update/delete) for the current policy and gateway
- delete<Resource> - Delete resources for the current policy
- deleteGateway<Resource> - Delete resources for the current policy and gateway
I'd say if we are trying to make these controllers consistent (looks like you have copied the pattern from health checks) we should actually update the DNSRecord one to deal with unexpected gateway resources in the same way as the other two.
Since none of that is in the scope of this bug fix i'd say we can come back to this later.
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: laurafitzgerald, mikenairn 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 |
Addressed #628
Verification
DNSRecord
Follow the steps described in the issue, the dnsrecord should be deleted.
Health Check Probes
kubectl create secret generic probe-headers --from-literal=test=dGVzdAo= -n multi-cluster-gateways
Follow the steps describe in the issue with the following adjustments.
Add the following block to your dnspolicy
there should be one dnshealthcheck probe present in the cluster now
e.g.
Delete the dnspolicy, the healthcheck probe should be deleted.
Certificates