@@ -138,15 +138,34 @@ func (r *ResourceVectorSearchIndex) DoCreate(ctx context.Context, engine *Engine
138138
139139 // Save state immediately after the index is created (endpoint UUID now set) so it
140140 // is not orphaned if the subsequent provisioning wait is interrupted.
141- engine .SetID (config .Name )
142- if err := engine .SaveState (config ); err != nil {
141+ if err := engine .SaveState (config .Name , config ); err != nil {
143142 return "" , nil , err
144143 }
145144
146- // CreateIndex returns immediately; poll until the embedding pipeline is ready so
147- // dependent resources and the next plan see a usable index.
145+ remote , err := r .waitForIndexReady (ctx , config .Name , endpointUuid )
146+ if err != nil {
147+ return "" , nil , err
148+ }
149+ return config .Name , remote , nil
150+ }
151+
152+ // No DoUpdate: vector search indexes have no update API. All SDK fields are
153+ // declared in resources.yml under recreate_on_changes or ignore_remote_changes.
154+ // If a future SDK bump adds a new field that isn't classified, the framework
155+ // rejects the resulting Update plan at bundle_plan.go (see also the reflection
156+ // test in vector_search_index_test.go which catches it earlier at unit-test time).
157+
158+ func (r * ResourceVectorSearchIndex ) DoDelete (ctx context.Context , id string , _ * VectorSearchIndexState ) error {
159+ return r .client .VectorSearchIndexes .DeleteIndexByIndexName (ctx , id )
160+ }
161+
162+ // waitForIndexReady polls GetIndex until Status.Ready=true. CreateIndex returns
163+ // immediately with metadata of an index whose embedding pipeline is still
164+ // provisioning; queries against an index that isn't ready fail. Blocking here
165+ // lets dependent resources (and the next plan) see a usable index.
166+ func (r * ResourceVectorSearchIndex ) waitForIndexReady (ctx context.Context , id , endpointUuid string ) (* VectorSearchIndexRemote , error ) {
148167 index , err := retries .Poll (ctx , createIndexTimeout , func () (* vectorsearch.VectorIndex , * retries.Err ) {
149- idx , getErr := r .client .VectorSearchIndexes .GetIndexByIndexName (ctx , config . Name )
168+ idx , getErr := r .client .VectorSearchIndexes .GetIndexByIndexName (ctx , id )
150169 if getErr != nil {
151170 return nil , retries .Halt (getErr )
152171 }
@@ -160,19 +179,9 @@ func (r *ResourceVectorSearchIndex) DoCreate(ctx context.Context, engine *Engine
160179 return idx , nil
161180 })
162181 if err != nil {
163- return "" , nil , err
182+ return nil , err
164183 }
165- return config .Name , & VectorSearchIndexRemote {VectorIndex : * index , EndpointUuid : endpointUuid }, nil
166- }
167-
168- // No DoUpdate: vector search indexes have no update API. All SDK fields are
169- // declared in resources.yml under recreate_on_changes or ignore_remote_changes.
170- // If a future SDK bump adds a new field that isn't classified, the framework
171- // rejects the resulting Update plan at bundle_plan.go (see also the reflection
172- // test in vector_search_index_test.go which catches it earlier at unit-test time).
173-
174- func (r * ResourceVectorSearchIndex ) DoDelete (ctx context.Context , id string , _ * VectorSearchIndexState ) error {
175- return r .client .VectorSearchIndexes .DeleteIndexByIndexName (ctx , id )
184+ return & VectorSearchIndexRemote {VectorIndex : * index , EndpointUuid : endpointUuid }, nil
176185}
177186
178187// WaitAfterDelete polls GetIndex until it returns 404. The DELETE call is
0 commit comments