You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
log.Printf("[INFO] Attempting to read model (attempt %d/%d)", i+1, maxRetries)
20
+
21
+
err=resourceLiteLLMModelRead(d, m)
22
+
iferr==nil {
23
+
log.Printf("[INFO] Successfully read model after %d attempts", i+1)
24
+
returnnil
25
+
}
26
+
27
+
// Check if this is a "model not found" error
28
+
iferr.Error() !="failed to read model: API request failed: Status: 400 Bad Request, Response: {\"detail\":{\"error\":\"Model id = "+d.Id()+" not found on litellm proxy\"}}, Request: null" {
29
+
// If it's a different error, don't retry
30
+
returnerr
31
+
}
32
+
33
+
ifi<maxRetries-1 {
34
+
log.Printf("[INFO] Model not found yet, retrying in %v...", delay)
35
+
time.Sleep(delay)
36
+
37
+
// Exponential backoff with a maximum delay
38
+
delay*=2
39
+
ifdelay>maxDelay {
40
+
delay=maxDelay
41
+
}
42
+
}
43
+
}
44
+
45
+
log.Printf("[WARN] Failed to read model after %d attempts: %v", maxRetries, err)
46
+
returnerr
47
+
}
48
+
11
49
const (
12
50
endpointModelNew="/model/new"
13
51
endpointModelUpdate="/model/update"
@@ -102,13 +140,9 @@ func createOrUpdateModel(d *schema.ResourceData, m interface{}, isUpdate bool) e
102
140
103
141
d.SetId(modelID)
104
142
105
-
// Add a delay to allow the model to be registered in the LiteLLM proxy
106
-
fmt.Printf("Model created with ID %s. Waiting 5 seconds for LiteLLM proxy to register the model...\n", modelID)
107
-
time.Sleep(5*time.Second)
108
-
fmt.Printf("Wait complete. Proceeding to read the model...\n")
109
-
110
-
// Read back the resource to ensure the state is consistent
111
-
returnresourceLiteLLMModelRead(d, m)
143
+
log.Printf("[INFO] Model created with ID %s. Starting retry mechanism to read the model...", modelID)
144
+
// Read back the resource with retries to ensure the state is consistent
0 commit comments