From 3909b37b98b234965da1d00564a5056fb2a258a9 Mon Sep 17 00:00:00 2001 From: Andrew Nester Date: Mon, 18 May 2026 11:23:08 +0200 Subject: [PATCH] direct: Pass id to WaitAfterXXX methods --- bundle/direct/apply.go | 6 +++--- bundle/direct/dresources/adapter.go | 16 ++++++++-------- bundle/direct/dresources/all_test.go | 4 ++-- bundle/direct/dresources/app.go | 2 +- bundle/direct/dresources/database_instance.go | 2 +- .../direct/dresources/model_serving_endpoint.go | 4 ++-- .../direct/dresources/vector_search_endpoint.go | 2 +- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/bundle/direct/apply.go b/bundle/direct/apply.go index e7186f64670..ba0f54bfc7b 100644 --- a/bundle/direct/apply.go +++ b/bundle/direct/apply.go @@ -66,7 +66,7 @@ func (d *DeploymentUnit) Create(ctx context.Context, db *dstate.DeploymentState, return fmt.Errorf("saving state after creating id=%s: %w", newID, err) } - waitRemoteState, err := d.Adapter.WaitAfterCreate(ctx, newState) + waitRemoteState, err := d.Adapter.WaitAfterCreate(ctx, newID, newState) if err != nil { return fmt.Errorf("waiting after creating id=%s: %w", newID, err) } @@ -116,7 +116,7 @@ func (d *DeploymentUnit) Update(ctx context.Context, db *dstate.DeploymentState, return fmt.Errorf("saving state id=%s: %w", id, err) } - waitRemoteState, err := d.Adapter.WaitAfterUpdate(ctx, newState) + waitRemoteState, err := d.Adapter.WaitAfterUpdate(ctx, id, newState) if err != nil { return fmt.Errorf("waiting after updating id=%s: %w", id, err) } @@ -152,7 +152,7 @@ func (d *DeploymentUnit) UpdateWithID(ctx context.Context, db *dstate.Deployment return fmt.Errorf("saving state id=%s: %w", oldID, err) } - waitRemoteState, err := d.Adapter.WaitAfterUpdate(ctx, newState) + waitRemoteState, err := d.Adapter.WaitAfterUpdate(ctx, newID, newState) if err != nil { return fmt.Errorf("waiting after updating id=%s: %w", newID, err) } diff --git a/bundle/direct/dresources/adapter.go b/bundle/direct/dresources/adapter.go index f931208c3cc..5e46dad540b 100644 --- a/bundle/direct/dresources/adapter.go +++ b/bundle/direct/dresources/adapter.go @@ -67,10 +67,10 @@ type IResource interface { // [Optional] WaitAfterCreate waits for the resource to become ready after creation. Returns optionally updated remote state. // TODO: wait status should be persisted in the state. - WaitAfterCreate(ctx context.Context, newState any) (remoteState any, e error) + WaitAfterCreate(ctx context.Context, id string, newState any) (remoteState any, e error) // [Optional] WaitAfterUpdate waits for the resource to become ready after update. Returns optionally updated remote state. - WaitAfterUpdate(ctx context.Context, newState any) (remoteState any, e error) + WaitAfterUpdate(ctx context.Context, id string, newState any) (remoteState any, e error) // [Optional] KeyedSlices returns a map from path patterns to KeyFunc for comparing slices by key instead of by index. // Example: func (*ResourcePermissions) KeyedSlices(state *PermissionsState) map[string]any @@ -306,7 +306,7 @@ func (a *Adapter) validate() error { } if a.waitAfterCreate != nil { - validations = append(validations, "WaitAfterCreate newState", a.waitAfterCreate.InTypes[1], stateType) + validations = append(validations, "WaitAfterCreate newState", a.waitAfterCreate.InTypes[2], stateType) // WaitAfterCreate must return (remoteType, error) if len(a.waitAfterCreate.OutTypes) != 2 { return fmt.Errorf("WaitAfterCreate must return (remoteType, error), got %d return values", len(a.waitAfterCreate.OutTypes)) @@ -315,7 +315,7 @@ func (a *Adapter) validate() error { } if a.waitAfterUpdate != nil { - validations = append(validations, "WaitAfterUpdate newState", a.waitAfterUpdate.InTypes[1], stateType) + validations = append(validations, "WaitAfterUpdate newState", a.waitAfterUpdate.InTypes[2], stateType) // WaitAfterUpdate must return (remoteType, error) if len(a.waitAfterUpdate.OutTypes) != 2 { return fmt.Errorf("WaitAfterUpdate must return (remoteType, error), got %d return values", len(a.waitAfterUpdate.OutTypes)) @@ -485,12 +485,12 @@ func (a *Adapter) DoResize(ctx context.Context, id string, newState any) error { // WaitAfterCreate waits for the resource to become ready after creation. // If the resource doesn't implement this method, this is a no-op. // Returns the updated remoteState if available, otherwise returns nil -func (a *Adapter) WaitAfterCreate(ctx context.Context, newState any) (any, error) { +func (a *Adapter) WaitAfterCreate(ctx context.Context, id string, newState any) (any, error) { if a.waitAfterCreate == nil { return nil, nil // no-op if not implemented } - outs, err := a.waitAfterCreate.Call(ctx, newState) + outs, err := a.waitAfterCreate.Call(ctx, id, newState) if err != nil { return nil, err } @@ -502,12 +502,12 @@ func (a *Adapter) WaitAfterCreate(ctx context.Context, newState any) (any, error // WaitAfterUpdate waits for the resource to become ready after update. // If the resource doesn't implement this method, this is a no-op. // Returns the updated remoteState if available, otherwise returns nil. -func (a *Adapter) WaitAfterUpdate(ctx context.Context, newState any) (any, error) { +func (a *Adapter) WaitAfterUpdate(ctx context.Context, id string, newState any) (any, error) { if a.waitAfterUpdate == nil { return nil, nil // no-op if not implemented } - outs, err := a.waitAfterUpdate.Call(ctx, newState) + outs, err := a.waitAfterUpdate.Call(ctx, id, newState) if err != nil { return nil, err } diff --git a/bundle/direct/dresources/all_test.go b/bundle/direct/dresources/all_test.go index 0b0e273c1c8..2c0a2e52f22 100644 --- a/bundle/direct/dresources/all_test.go +++ b/bundle/direct/dresources/all_test.go @@ -798,7 +798,7 @@ func testCRUD(t *testing.T, group string, adapter *Adapter, client *databricks.W "unexpected differences between remappedState and remappedRemoteStateFromCreate") } - remoteStateFromWaitCreate, err := adapter.WaitAfterCreate(ctx, newState) + remoteStateFromWaitCreate, err := adapter.WaitAfterCreate(ctx, createdID, newState) require.NoError(t, err) if remoteStateFromWaitCreate != nil { require.Equal(t, remote, remoteStateFromWaitCreate) @@ -814,7 +814,7 @@ func testCRUD(t *testing.T, group string, adapter *Adapter, client *databricks.W "unexpected differences between remappedState and remappedStateFromUpdate") } - remoteStateFromWaitUpdate, err := adapter.WaitAfterUpdate(ctx, newState) + remoteStateFromWaitUpdate, err := adapter.WaitAfterUpdate(ctx, createdID, newState) require.NoError(t, err) if remoteStateFromWaitUpdate != nil { remappedStateFromWaitUpdate, err := adapter.RemapState(remoteStateFromWaitUpdate) diff --git a/bundle/direct/dresources/app.go b/bundle/direct/dresources/app.go index 5f882170613..8cae2e50e67 100644 --- a/bundle/direct/dresources/app.go +++ b/bundle/direct/dresources/app.go @@ -321,7 +321,7 @@ func (r *ResourceApp) DoDelete(ctx context.Context, id string) error { return err } -func (r *ResourceApp) WaitAfterCreate(ctx context.Context, config *AppState) (*AppRemote, error) { +func (r *ResourceApp) WaitAfterCreate(ctx context.Context, id string, config *AppState) (*AppRemote, error) { remote, err := r.waitForApp(ctx, r.client, config.Name) if err != nil { return nil, err diff --git a/bundle/direct/dresources/database_instance.go b/bundle/direct/dresources/database_instance.go index e7a5e8d824c..d3bceda4b7d 100644 --- a/bundle/direct/dresources/database_instance.go +++ b/bundle/direct/dresources/database_instance.go @@ -46,7 +46,7 @@ func (d *ResourceDatabaseInstance) DoUpdate(ctx context.Context, id string, conf return nil, err } -func (d *ResourceDatabaseInstance) WaitAfterCreate(ctx context.Context, config *database.DatabaseInstance) (*database.DatabaseInstance, error) { +func (d *ResourceDatabaseInstance) WaitAfterCreate(ctx context.Context, id string, config *database.DatabaseInstance) (*database.DatabaseInstance, error) { waiter := &database.WaitGetDatabaseInstanceDatabaseAvailable[database.DatabaseInstance]{ Response: config, Name: config.Name, diff --git a/bundle/direct/dresources/model_serving_endpoint.go b/bundle/direct/dresources/model_serving_endpoint.go index 4d384edab1f..35aec6ffd44 100644 --- a/bundle/direct/dresources/model_serving_endpoint.go +++ b/bundle/direct/dresources/model_serving_endpoint.go @@ -150,11 +150,11 @@ func (r *ResourceModelServingEndpoint) waitForEndpointReady(ctx context.Context, }, nil } -func (r *ResourceModelServingEndpoint) WaitAfterCreate(ctx context.Context, config *serving.CreateServingEndpoint) (*ModelServingEndpointRemote, error) { +func (r *ResourceModelServingEndpoint) WaitAfterCreate(ctx context.Context, id string, config *serving.CreateServingEndpoint) (*ModelServingEndpointRemote, error) { return r.waitForEndpointReady(ctx, config.Name) } -func (r *ResourceModelServingEndpoint) WaitAfterUpdate(ctx context.Context, config *serving.CreateServingEndpoint) (*ModelServingEndpointRemote, error) { +func (r *ResourceModelServingEndpoint) WaitAfterUpdate(ctx context.Context, id string, config *serving.CreateServingEndpoint) (*ModelServingEndpointRemote, error) { return r.waitForEndpointReady(ctx, config.Name) } diff --git a/bundle/direct/dresources/vector_search_endpoint.go b/bundle/direct/dresources/vector_search_endpoint.go index 0d904f6807b..39211ca63ab 100644 --- a/bundle/direct/dresources/vector_search_endpoint.go +++ b/bundle/direct/dresources/vector_search_endpoint.go @@ -77,7 +77,7 @@ func (r *ResourceVectorSearchEndpoint) DoCreate(ctx context.Context, config *vec return id, newVectorSearchEndpointRemote(waiter.Response), nil } -func (r *ResourceVectorSearchEndpoint) WaitAfterCreate(ctx context.Context, config *vectorsearch.CreateEndpoint) (*VectorSearchEndpointRemote, error) { +func (r *ResourceVectorSearchEndpoint) WaitAfterCreate(ctx context.Context, id string, config *vectorsearch.CreateEndpoint) (*VectorSearchEndpointRemote, error) { info, err := r.client.VectorSearchEndpoints.WaitGetEndpointVectorSearchEndpointOnline(ctx, config.Name, 60*time.Minute, nil) if err != nil { return nil, err