Skip to content

Commit

Permalink
Use a revision tracker to reconcile on KCerts
Browse files Browse the repository at this point in the history
  • Loading branch information
ReToCode committed Jan 18, 2024
1 parent 67cf527 commit ae3acea
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pkg/reconciler/revision/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ func newControllerWithOptions(
return controller.Options{ConfigStore: configStore}
})

c.tracker = impl.Tracker

transport := http.DefaultTransport
if rt, err := newResolverTransport(k8sCertPath, digestResolutionWorkers, digestResolutionWorkers); err != nil {
logging.FromContext(ctx).Errorw("Failed to create resolver transport", zap.Error(err))
Expand Down Expand Up @@ -136,7 +138,15 @@ func newControllerWithOptions(
}
deploymentInformer.Informer().AddEventHandler(handleMatchingControllers)
paInformer.Informer().AddEventHandler(handleMatchingControllers)
certificateInformer.Informer().AddEventHandler(handleMatchingControllers)
certificateInformer.Informer().AddEventHandler(controller.HandleAll(
// Call the tracker's OnChanged method, but we've seen the objects
// coming through this path missing TypeMeta, so ensure it is properly
// populated.
controller.EnsureTypeMeta(
c.tracker.OnChanged,
v1.SchemeGroupVersion.WithKind("Revision"),
),
))

// We don't watch for changes to Image because we don't incorporate any of its
// properties into our own status and should work completely in the absence of
Expand Down
11 changes: 11 additions & 0 deletions pkg/reconciler/revision/reconcile_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"fmt"

"go.uber.org/zap"
"knative.dev/pkg/tracker"
networkingaccessor "knative.dev/serving/pkg/reconciler/accessor/networking"

appsv1 "k8s.io/api/apps/v1"
Expand Down Expand Up @@ -249,5 +250,15 @@ func (c *Reconciler) reconcileQueueProxyCertificate(ctx context.Context, rev *v1
return fmt.Errorf("certificate in secret %s/%s is not ready yet: private key not found", ns, networking.ServingCertName)
}

// Tell our trackers to reconcile the Revision when our Knative Certificate changes
if err := c.tracker.TrackReference(tracker.Reference{
APIVersion: rev.APIVersion,
Kind: rev.Kind,
Namespace: rev.Namespace,
Name: rev.Name,
}, rev); err != nil {
return err
}

return nil
}
2 changes: 2 additions & 0 deletions pkg/reconciler/revision/revision.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
appsv1listers "k8s.io/client-go/listers/apps/v1"
cachingclientset "knative.dev/caching/pkg/client/clientset/versioned"
networkingclientset "knative.dev/networking/pkg/client/clientset/versioned"
"knative.dev/pkg/tracker"
clientset "knative.dev/serving/pkg/client/clientset/versioned"

revisionreconciler "knative.dev/serving/pkg/client/injection/reconciler/serving/v1/revision"
Expand Down Expand Up @@ -66,6 +67,7 @@ type Reconciler struct {
deploymentLister appsv1listers.DeploymentLister
certificateLister networkinglisters.CertificateLister

tracker tracker.Interface
resolver resolver
}

Expand Down

0 comments on commit ae3acea

Please sign in to comment.