Skip to content

Commit 3f9f68a

Browse files
committed
Set AsyncOperationInProgress in async Observe paths
All four async-in-progress return sites now set AsyncOperationInProgress: true in ExternalObservation, signaling the managed reconciler to set Synced=False(ReconcilePending) instead of the misleading Synced=True(ReconcileSuccess). Note: go.mod contains a temporary replace directive pointing at ajnye/crossplane-runtime for the AsyncOperationInProgress field. This will be updated to the upstream version once crossplane/crossplane-runtime#984 merges. Fixes crossplane#609 Signed-off-by: Aj Nye <aj.nye@appian.com>
1 parent c6d5213 commit 3f9f68a

7 files changed

Lines changed: 39 additions & 14 deletions

File tree

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,3 +146,5 @@ require (
146146
sigs.k8s.io/randfill v1.0.0 // indirect
147147
sigs.k8s.io/structured-merge-diff/v6 v6.3.2-0.20260122202528-d9cc6641c482 // indirect
148148
)
149+
150+
replace github.com/crossplane/crossplane-runtime/v2 => github.com/ajnye/crossplane-runtime/v2 v2.2.1-0.20260429154540-465317a68bee

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ github.com/Masterminds/semver/v3 v3.4.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lpr
77
github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
88
github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo=
99
github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
10+
github.com/ajnye/crossplane-runtime/v2 v2.2.1-0.20260429154540-465317a68bee h1:6Wp0RzkQQGKWCw89AbWHDWN/9HoF+ONUOv318FR4sQU=
11+
github.com/ajnye/crossplane-runtime/v2 v2.2.1-0.20260429154540-465317a68bee/go.mod h1:8I+x4w5bG4x8aO8ifF/QC8GZoNCN6v21NHzgoYPNYAQ=
1012
github.com/alecthomas/kingpin/v2 v2.4.0 h1:f48lwail6p8zpO1bC4TxtqACaGqHYA22qkHjHpqDjYY=
1113
github.com/alecthomas/kingpin/v2 v2.4.0/go.mod h1:0gyi0zQnjuFk8xrkNKamJoyUo382HRL7ATRpFZCw6tE=
1214
github.com/alecthomas/kong v0.2.16/go.mod h1:kQOmtJgV+Lb4aj+I2LEn40cbtawdWJ9Y8QLq+lElKxE=
@@ -37,8 +39,6 @@ github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UF
3739
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
3840
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
3941
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
40-
github.com/crossplane/crossplane-runtime/v2 v2.2.0 h1:jLoQm9D5buk9lBqwRtQ40ueaFotjOljJATq+24bVYI8=
41-
github.com/crossplane/crossplane-runtime/v2 v2.2.0/go.mod h1:8I+x4w5bG4x8aO8ifF/QC8GZoNCN6v21NHzgoYPNYAQ=
4242
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
4343
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
4444
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=

pkg/controller/external.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,9 @@ func (e *external) Observe(ctx context.Context, mg xpresource.Managed) (managed.
224224
case res.ASyncInProgress:
225225
mg.SetConditions(resource.AsyncOperationOngoingCondition())
226226
return managed.ExternalObservation{
227-
ResourceExists: true,
228-
ResourceUpToDate: true,
227+
ResourceExists: true,
228+
ResourceUpToDate: true,
229+
AsyncOperationInProgress: true,
229230
}, nil
230231
case !res.Exists:
231232
return managed.ExternalObservation{
@@ -474,8 +475,9 @@ func (e *external) Import(ctx context.Context, tr resource.Terraformed) (managed
474475
if res.ASyncInProgress {
475476
tr.SetConditions(resource.AsyncOperationOngoingCondition())
476477
return managed.ExternalObservation{
477-
ResourceExists: true,
478-
ResourceUpToDate: true,
478+
ResourceExists: true,
479+
ResourceUpToDate: true,
480+
AsyncOperationInProgress: true,
479481
}, nil
480482
}
481483
// If the resource doesn't exist, we don't need to do anything else.

pkg/controller/external_async_tfpluginfw.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,9 @@ func (n *terraformPluginFrameworkAsyncExternalClient) Observe(ctx context.Contex
117117
if n.opTracker.LastOperation.IsRunning() {
118118
n.logger.WithValues("opType", n.opTracker.LastOperation.Type).Debug("ongoing async operation")
119119
return managed.ExternalObservation{
120-
ResourceExists: true,
121-
ResourceUpToDate: true,
120+
ResourceExists: true,
121+
ResourceUpToDate: true,
122+
AsyncOperationInProgress: true,
122123
}, nil
123124
}
124125

pkg/controller/external_async_tfpluginsdk.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,9 @@ func (n *terraformPluginSDKAsyncExternal) Observe(ctx context.Context, mg xpreso
119119
if n.opTracker.LastOperation.IsRunning() {
120120
n.logger.WithValues("opType", n.opTracker.LastOperation.Type).Debug("ongoing async operation")
121121
return managed.ExternalObservation{
122-
ResourceExists: true,
123-
ResourceUpToDate: true,
122+
ResourceExists: true,
123+
ResourceUpToDate: true,
124+
AsyncOperationInProgress: true,
124125
}, nil
125126
}
126127
n.opTracker.LastOperation.Clear(true)

pkg/controller/external_async_tfpluginsdk_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,27 @@ func TestAsyncTerraformPluginSDKObserve(t *testing.T) {
189189
},
190190
},
191191
},
192+
"AsyncInProgress": {
193+
args: args{
194+
r: mockResource{},
195+
cfg: cfgAsync,
196+
obj: objAsync,
197+
},
198+
want: want{
199+
obs: managed.ExternalObservation{
200+
ResourceExists: true,
201+
ResourceUpToDate: true,
202+
AsyncOperationInProgress: true,
203+
},
204+
},
205+
},
192206
}
193207
for name, tc := range cases {
194208
t.Run(name, func(t *testing.T) {
195209
terraformPluginSDKAsyncExternal := prepareTerraformPluginSDKAsyncExternal(tc.args.r, tc.args.cfg, CallbackFns{})
210+
if name == "AsyncInProgress" {
211+
terraformPluginSDKAsyncExternal.opTracker.LastOperation.MarkStart("update")
212+
}
196213
observation, err := terraformPluginSDKAsyncExternal.Observe(context.TODO(), tc.args.obj)
197214
if diff := cmp.Diff(tc.want.obs, observation); diff != "" {
198215
t.Errorf("\n%s\nObserve(...): -want observation, +got observation:\n", diff)

pkg/controller/external_test.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,9 @@ func TestObserve(t *testing.T) {
273273
},
274274
want: want{
275275
obs: managed.ExternalObservation{
276-
ResourceExists: true,
277-
ResourceUpToDate: true,
276+
ResourceExists: true,
277+
ResourceUpToDate: true,
278+
AsyncOperationInProgress: true,
278279
},
279280
},
280281
},
@@ -398,8 +399,9 @@ func TestObserve(t *testing.T) {
398399
},
399400
want: want{
400401
obs: managed.ExternalObservation{
401-
ResourceExists: true,
402-
ResourceUpToDate: true,
402+
ResourceExists: true,
403+
ResourceUpToDate: true,
404+
AsyncOperationInProgress: true,
403405
},
404406
},
405407
},

0 commit comments

Comments
 (0)