Skip to content

Commit 0f08ad4

Browse files
committed
Apply timeout to the entire operation
1 parent c8df3a8 commit 0f08ad4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

internal/elasticsearch/ml/job_state/update.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ func (r *mlJobStateResource) update(ctx context.Context, plan tfsdk.Plan, state
5252
jobId := data.JobId.ValueString()
5353
desiredState := data.State.ValueString()
5454

55+
// Create context with timeout
56+
ctx, cancel := context.WithTimeout(ctx, operationTimeout)
57+
defer cancel()
58+
5559
// First, get the current job stats to check if the job exists and its current state
5660
currentState, fwDiags := r.getJobState(ctx, jobId)
5761
diags.Append(fwDiags...)
@@ -110,10 +114,6 @@ func (r *mlJobStateResource) performStateTransition(ctx context.Context, client
110114
return nil
111115
}
112116

113-
// Create context with timeout
114-
ctx, cancel := context.WithTimeout(ctx, operationTimeout)
115-
defer cancel()
116-
117117
// Initiate the state change
118118
switch desiredState {
119119
case "opened":

0 commit comments

Comments
 (0)