Skip to content
Merged
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
6 changes: 3 additions & 3 deletions bundle/direct/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down
16 changes: 8 additions & 8 deletions bundle/direct/dresources/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand All @@ -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))
Expand Down Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions bundle/direct/dresources/all_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion bundle/direct/dresources/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion bundle/direct/dresources/database_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions bundle/direct/dresources/model_serving_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion bundle/direct/dresources/vector_search_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading