aboutsummaryrefslogtreecommitdiffstats
path: root/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi
diff options
context:
space:
mode:
authorHarald Musum <musum@yahooinc.com>2022-04-26 09:10:08 +0200
committerHarald Musum <musum@yahooinc.com>2022-04-26 09:10:08 +0200
commit6820548be3499875ae5d49f82b25703918130d7a (patch)
tree797f400d014c6c179c0ef2f3d042e798c155ac83 /node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi
parentdebff80c81f6362427d25b8d5d1a6f3ae90d859d (diff)
Use a lock timeout mathcing client timeout for ApplicationPatcher
Diffstat (limited to 'node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi')
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/ApplicationPatcher.java8
1 files changed, 5 insertions, 3 deletions
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/ApplicationPatcher.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/ApplicationPatcher.java
index cb3c6c0f5f4..7b5146955fb 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/ApplicationPatcher.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/ApplicationPatcher.java
@@ -13,6 +13,7 @@ import com.yahoo.vespa.hosted.provision.applications.Application;
import java.io.IOException;
import java.io.InputStream;
import java.io.UncheckedIOException;
+import java.time.Duration;
/**
* A class which can take a partial JSON node/v2 application JSON structure and apply it to an application object.
@@ -33,7 +34,8 @@ public class ApplicationPatcher implements AutoCloseable {
} catch (IOException e) {
throw new UncheckedIOException("Error reading request body", e);
}
- this.lock = nodeRepository.nodes().lock(applicationId);
+ // Use same timeout for acquiring lock as client timeout for patch request
+ this.lock = nodeRepository.nodes().lock(applicationId, Duration.ofSeconds(30));
try {
this.application = nodeRepository.applications().require(applicationId);
}
@@ -47,7 +49,7 @@ public class ApplicationPatcher implements AutoCloseable {
public Application apply() {
inspector.traverse((String name, Inspector value) -> {
try {
- application = applyField(application, name, value, inspector);
+ application = applyField(application, name, value);
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException("Could not set field '" + name + "'", e);
}
@@ -65,7 +67,7 @@ public class ApplicationPatcher implements AutoCloseable {
lock.close();
}
- private Application applyField(Application application, String name, Inspector value, Inspector root) {
+ private Application applyField(Application application, String name, Inspector value) {
switch (name) {
case "currentReadShare" :
return application.with(application.status().withCurrentReadShare(asDouble(value)));