Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
Merge pull request #196 from muvaf/cherry-0.3
Browse files Browse the repository at this point in the history
cherry-pick #194 to release-0.3
  • Loading branch information
muvaf authored Jan 7, 2022
2 parents 4a4dc50 + 2bc86dd commit fbfad2c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pkg/controller/external.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ func (e *external) Observe(ctx context.Context, mg xpresource.Managed) (managed.
}
switch {
case res.IsApplying, res.IsDestroying:
mg.SetConditions(resource.AsyncOperationOngoingCondition())
return managed.ExternalObservation{
ResourceExists: true,
ResourceUpToDate: true,
Expand All @@ -135,6 +136,10 @@ func (e *external) Observe(ctx context.Context, mg xpresource.Managed) (managed.
ResourceExists: false,
}, nil
}
// There might be a case where async operation is finished and the status
// update marking it as finished didn't go through. At this point, we are
// sure that there is no ongoing operation.
tr.SetConditions(resource.AsyncOperationFinishedCondition())

// No operation was in progress, our observation completed successfully, and
// we have an observation to consume.
Expand Down Expand Up @@ -189,7 +194,6 @@ func (e *external) Observe(ctx context.Context, mg xpresource.Managed) (managed.

func (e *external) Create(ctx context.Context, mg xpresource.Managed) (managed.ExternalCreation, error) {
if e.config.UseAsync {
mg.SetConditions(resource.AsyncOperationOngoingCondition())
return managed.ExternalCreation{}, errors.Wrap(e.workspace.ApplyAsync(e.callback.Apply(mg.GetName())), errStartAsyncApply)
}
tr, ok := mg.(resource.Terraformed)
Expand Down Expand Up @@ -217,7 +221,6 @@ func (e *external) Create(ctx context.Context, mg xpresource.Managed) (managed.E

func (e *external) Update(ctx context.Context, mg xpresource.Managed) (managed.ExternalUpdate, error) {
if e.config.UseAsync {
mg.SetConditions(resource.AsyncOperationOngoingCondition())
return managed.ExternalUpdate{}, errors.Wrap(e.workspace.ApplyAsync(e.callback.Apply(mg.GetName())), errStartAsyncApply)
}
tr, ok := mg.(resource.Terraformed)
Expand Down

0 comments on commit fbfad2c

Please sign in to comment.