Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pkg/controller/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func (ac *APICallbacks) callbackFn(nn types.NamespacedName, op string) terraform
// status condition but we need changes in the managed reconciler
// to do so. So we keep the `LastAsyncOperation` condition.
// TODO: move this to the `Synced` condition.
tr.SetConditions(resource.LastAsyncOperationCondition(err))
tr.SetConditions(resource.LastAsyncOperationCondition(err).WithObservedGeneration(tr.GetGeneration()))
if err != nil {
wrapMsg := ""
switch op {
Expand All @@ -135,12 +135,12 @@ func (ac *APICallbacks) callbackFn(nn types.NamespacedName, op string) terraform
case "destroy":
wrapMsg = errXPReconcileDelete
}
tr.SetConditions(xpv1.ReconcileError(errors.Wrap(err, wrapMsg)))
tr.SetConditions(xpv1.ReconcileError(errors.Wrap(err, wrapMsg)).WithObservedGeneration(tr.GetGeneration()))
} else {
tr.SetConditions(xpv1.ReconcileSuccess())
tr.SetConditions(xpv1.ReconcileSuccess().WithObservedGeneration(tr.GetGeneration()))
}
if ac.enableStatusUpdates {
tr.SetConditions(resource.AsyncOperationFinishedCondition())
tr.SetConditions(resource.AsyncOperationFinishedCondition().WithObservedGeneration(tr.GetGeneration()))
}
uErr := errors.Wrapf(ac.kube.Status().Update(ctx, tr), errUpdateStatusFmt, tr.GetObjectKind().GroupVersionKind().String(), nn, op)
if ac.eventHandler != nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/external.go
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ func (e *external) Import(ctx context.Context, tr resource.Terraformed) (managed
// in progress. In that case, we want to wait for the operation to finish
// before we start observing.
if res.ASyncInProgress {
tr.SetConditions(resource.AsyncOperationOngoingCondition())
tr.SetConditions(resource.AsyncOperationOngoingCondition().WithObservedGeneration(tr.GetGeneration()))
return managed.ExternalObservation{
ResourceExists: true,
ResourceUpToDate: true,
Expand Down Expand Up @@ -502,7 +502,7 @@ func (e *external) Import(ctx context.Context, tr resource.Terraformed) (managed
return managed.ExternalObservation{}, errors.Wrap(err, "cannot get connection details")
}

tr.SetConditions(xpv1.Available())
tr.SetConditions(xpv1.Available().WithObservedGeneration(tr.GetGeneration()))
return managed.ExternalObservation{
ResourceExists: true,
ResourceUpToDate: true,
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/external_async_tfpluginfw.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ func (n *terraformPluginFrameworkAsyncExternalClient) Observe(ctx context.Contex
// because there are no pending updates on the existing resource and it's
// not scheduled to be deleted.
if err == nil && o.ResourceExists && o.ResourceUpToDate && !meta.WasDeleted(mg) {
mg.(resource.Terraformed).SetConditions(resource.LastAsyncOperationCondition(nil))
mg.(resource.Terraformed).SetConditions(xpv1.ReconcileSuccess())
mg.(resource.Terraformed).SetConditions(resource.LastAsyncOperationCondition(nil).WithObservedGeneration(mg.GetGeneration()))
mg.(resource.Terraformed).SetConditions(xpv1.ReconcileSuccess().WithObservedGeneration(mg.GetGeneration()))
n.opTracker.LastOperation.Clear(false)
}
return o, err
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/external_async_tfpluginsdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ func (n *terraformPluginSDKAsyncExternal) Observe(ctx context.Context, mg xpreso
// because there are no pending updates on the existing resource and it's
// not scheduled to be deleted.
if err == nil && o.ResourceExists && o.ResourceUpToDate && !meta.WasDeleted(mg) {
mg.(resource.Terraformed).SetConditions(resource.LastAsyncOperationCondition(nil))
mg.(resource.Terraformed).SetConditions(xpv1.ReconcileSuccess())
mg.(resource.Terraformed).SetConditions(resource.LastAsyncOperationCondition(nil).WithObservedGeneration(mg.GetGeneration()))
mg.(resource.Terraformed).SetConditions(xpv1.ReconcileSuccess().WithObservedGeneration(mg.GetGeneration()))
n.opTracker.LastOperation.Clear(false)
}
return o, err
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/external_tfpluginfw.go
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ func (n *terraformPluginFrameworkExternalClient) Observe(ctx context.Context, mg
mg.GetCondition(xpv1.TypeReady).Status == corev1.ConditionFalse {
addTTR(mg)
}
mg.SetConditions(xpv1.Available())
mg.SetConditions(xpv1.Available().WithObservedGeneration(mg.GetGeneration()))

// we get the connection details from the observed state before
// the conversion because the sensitive paths assume the native Terraform
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/external_tfpluginsdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ func (n *terraformPluginSDKExternal) Observe(ctx context.Context, mg xpresource.
mg.GetCondition(xpv1.TypeReady).Status == corev1.ConditionFalse {
addTTR(mg)
}
mg.SetConditions(xpv1.Available())
mg.SetConditions(xpv1.Available().WithObservedGeneration(mg.GetGeneration()))

// we get the connection details from the observed state before
// the conversion because the sensitive paths assume the native Terraform
Expand Down
2 changes: 1 addition & 1 deletion pkg/resource/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,6 @@ func SetUpToDateCondition(mg xpresource.Managed, upToDate bool) {
// After running refresh, if the resource is up-to-date and a test resource
// we can set the UpToDate condition
if upToDate && IsTest(mg) {
mg.SetConditions(UpToDateCondition())
mg.SetConditions(UpToDateCondition().WithObservedGeneration(mg.GetGeneration()))
}
}
Loading