This is an automated email from the ASF dual-hosted git repository.
pingsutw pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/submarine.git
The following commit(s) were added to refs/heads/master by this push:
new b3e9be84 SUBMARINE-1251. fix patch type and add error handling
b3e9be84 is described below
commit b3e9be84400feb4bf8ebbc5e77d28b0d4c91c655
Author: KUAN-HSUN-LI <[email protected]>
AuthorDate: Mon Apr 4 16:51:33 2022 +0800
SUBMARINE-1251. fix patch type and add error handling
### What is this PR for?
In the previous PR #915, the patch method is not fixed since the
`InvalidSpecException` is sending status code 200.
### What type of PR is it?
[Bug Fix]
### Todos
### What is the Jira issue?
https://issues.apache.org/jira/browse/SUBMARINE-1251
### How should this be tested?
### Screenshots (if appropriate)
### Questions:
* Do the license files need updating? No
* Are there breaking changes for older versions? No
* Does this need new documentation? No
Author: KUAN-HSUN-LI <[email protected]>
Signed-off-by: Kevin <[email protected]>
Closes #919 from KUAN-HSUN-LI/SUBMARINE-1251 and squashes the following
commits:
2ce66f4a [KUAN-HSUN-LI] SUBMARINE-1251. fix patch type and add error
handling
---
.../submarine/server/submitter/k8s/K8sSubmitter.java | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git
a/submarine-server/server-submitter/submitter-k8s/src/main/java/org/apache/submarine/server/submitter/k8s/K8sSubmitter.java
b/submarine-server/server-submitter/submitter-k8s/src/main/java/org/apache/submarine/server/submitter/k8s/K8sSubmitter.java
index d9e86809..d06eef39 100644
---
a/submarine-server/server-submitter/submitter-k8s/src/main/java/org/apache/submarine/server/submitter/k8s/K8sSubmitter.java
+++
b/submarine-server/server-submitter/submitter-k8s/src/main/java/org/apache/submarine/server/submitter/k8s/K8sSubmitter.java
@@ -32,6 +32,7 @@ import java.util.function.Function;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
+import io.kubernetes.client.util.generic.options.PatchOptions;
import okhttp3.OkHttpClient;
import io.kubernetes.client.openapi.ApiClient;
import io.kubernetes.client.openapi.ApiException;
@@ -318,19 +319,28 @@ public class K8sSubmitter implements Submitter {
try {
MLJob mlJob = ExperimentSpecParser.parseJob(spec);
mlJob.getMetadata().setNamespace(getServerNamespace());
+ // Using apply yaml patch, field manager must be set, and it must be
forced.
+ //
https://kubernetes.io/docs/reference/using-api/server-side-apply/#field-management
+ PatchOptions patchOptions = new PatchOptions();
+ patchOptions.setFieldManager(spec.getMeta().getExperimentId());
+ patchOptions.setForce(true);
Object object = mlJob.getPlural().equals(TFJob.CRD_TF_PLURAL_V1)
? tfJobClient.patch(getServerNamespace(),
mlJob.getMetadata().getName(),
V1Patch.PATCH_FORMAT_APPLY_YAML,
- new V1Patch(new Gson().toJson(((TFJob)
mlJob).getSpec()))).throwsApiException().getObject()
+ new V1Patch(new Gson().toJson(mlJob)),
+ patchOptions).throwsApiException().getObject()
: pyTorchJobClient.patch(getServerNamespace(),
mlJob.getMetadata().getName(),
V1Patch.PATCH_FORMAT_APPLY_YAML,
- new V1Patch(new Gson().toJson(((PyTorchJob)
mlJob).getSpec()))).throwsApiException().getObject()
+ new V1Patch(new Gson().toJson(mlJob)),
+ patchOptions).throwsApiException().getObject()
;
experiment = parseExperimentResponseObject(object,
ParseOp.PARSE_OP_RESULT);
} catch (InvalidSpecException e) {
- throw new SubmarineRuntimeException(200, e.getMessage());
+ throw new SubmarineRuntimeException(409, e.getMessage());
} catch (ApiException e) {
throw new SubmarineRuntimeException(e.getCode(), e.getMessage());
+ } catch (Error e) {
+ throw new SubmarineRuntimeException(500, String.format("Unhandled error:
%s", e.getMessage()));
}
return experiment;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]