diff --git a/pkg/controller/external.go b/pkg/controller/external.go index bd317340..9e9872be 100644 --- a/pkg/controller/external.go +++ b/pkg/controller/external.go @@ -43,6 +43,7 @@ const ( const ( rateLimiterScheduler = "scheduler" + rateLimiterStatus = "status" retryLimit = 20 ) @@ -295,6 +296,7 @@ func (e *external) Observe(ctx context.Context, mg xpresource.Managed) (managed. switch { // we prioritize critical annotation updates over status updates case annotationsUpdated: + e.logger.Debug("Critical annotations have been updated.") return managed.ExternalObservation{ ResourceExists: true, ResourceUpToDate: true, @@ -305,6 +307,10 @@ func (e *external) Observe(ctx context.Context, mg xpresource.Managed) (managed. case !markedAvailable: addTTR(tr) tr.SetConditions(xpv1.Available()) + e.logger.Debug("Resource is marked as available.") + if lateInitedParams && e.eventHandler != nil { + e.eventHandler.RequestReconcile(rateLimiterStatus, mg.GetName(), nil) + } return managed.ExternalObservation{ ResourceExists: true, ResourceUpToDate: true, @@ -313,6 +319,10 @@ func (e *external) Observe(ctx context.Context, mg xpresource.Managed) (managed. // with the least priority wrt critical annotation updates and status updates // we allow a late-initialization before the Workspace.Plan call case lateInitedParams: + e.logger.Debug("Resource is late-initialized.") + if e.eventHandler != nil { + e.eventHandler.Forget(rateLimiterStatus, mg.GetName()) + } return managed.ExternalObservation{ ResourceExists: true, ResourceUpToDate: true, @@ -327,6 +337,7 @@ func (e *external) Observe(ctx context.Context, mg xpresource.Managed) (managed. } resource.SetUpToDateCondition(mg, plan.UpToDate) + e.logger.Debug("Called plan on the resource.", "upToDate", plan.UpToDate) return managed.ExternalObservation{ ResourceExists: true, diff --git a/pkg/controller/external_test.go b/pkg/controller/external_test.go index 9ca9bb38..cb76b511 100644 --- a/pkg/controller/external_test.go +++ b/pkg/controller/external_test.go @@ -19,6 +19,7 @@ import ( "testing" xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" + "github.com/crossplane/crossplane-runtime/pkg/logging" xpmeta "github.com/crossplane/crossplane-runtime/pkg/meta" "github.com/crossplane/crossplane-runtime/pkg/reconciler/managed" xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" @@ -601,7 +602,7 @@ func TestObserve(t *testing.T) { } for name, tc := range cases { t.Run(name, func(t *testing.T) { - e := &external{workspace: tc.w, config: config.DefaultResource("upjet_resource", nil, nil), kube: tc.args.client} + e := &external{workspace: tc.w, config: config.DefaultResource("upjet_resource", nil, nil), kube: tc.args.client, logger: logging.NewNopLogger()} observation, err := e.Observe(context.TODO(), tc.args.obj) if diff := cmp.Diff(tc.want.obs, observation); diff != "" { t.Errorf("\n%s\nObserve(...): -want observation, +got observation:\n%s", tc.reason, diff)