Increase model pull retry delay and attempts

Raised the base delay for model pull retries from 1s to 3s and updated log output to show seconds instead of milliseconds. Also increased the number of retries for model pull in integration tests from 3 to 5 to improve robustness.
This commit is contained in:
amithkoujalgi 2025-08-30 17:04:02 +05:30
parent de379d73b2
commit c705432510
No known key found for this signature in database
GPG Key ID: E29A37746AF94B70
2 changed files with 4 additions and 4 deletions

View File

@ -429,7 +429,7 @@ public class OllamaAPI {
return; return;
} }
int numberOfRetries = 0; int numberOfRetries = 0;
long baseDelayMillis = 1000L; // 1 second base delay long baseDelayMillis = 3000L; // 1 second base delay
while (numberOfRetries < numberOfRetriesForModelPull) { while (numberOfRetries < numberOfRetriesForModelPull) {
try { try {
this.doPullModel(modelName); this.doPullModel(modelName);
@ -450,8 +450,8 @@ public class OllamaAPI {
int attempt = currentRetry + 1; int attempt = currentRetry + 1;
if (attempt < maxRetries) { if (attempt < maxRetries) {
long backoffMillis = baseDelayMillis * (1L << currentRetry); long backoffMillis = baseDelayMillis * (1L << currentRetry);
logger.error("Failed to pull model {}, retrying in {} ms... (attempt {}/{})", logger.error("Failed to pull model {}, retrying in {} s... (attempt {}/{})",
modelName, backoffMillis, attempt, maxRetries); modelName, backoffMillis/1000, attempt, maxRetries);
try { try {
Thread.sleep(backoffMillis); Thread.sleep(backoffMillis);
} catch (InterruptedException ie) { } catch (InterruptedException ie) {

View File

@ -75,7 +75,7 @@ class OllamaAPIIntegrationTest {
} }
api.setRequestTimeoutSeconds(120); api.setRequestTimeoutSeconds(120);
api.setVerbose(true); api.setVerbose(true);
api.setNumberOfRetriesForModelPull(3); api.setNumberOfRetriesForModelPull(5);
} }
@Test @Test