|
|
@@ -7,6 +7,7 @@ import cn.seecoder.api.k8s.model.K8sObjectRequest;
|
|
|
|
|
|
import cn.seecoder.api.k8s.model.LabelSelector;
|
|
|
import cn.seecoder.common.util.LoggerUtil;
|
|
|
+import com.google.gson.JsonSyntaxException;
|
|
|
import io.kubernetes.client.openapi.ApiException;
|
|
|
import io.kubernetes.client.openapi.apis.BatchV1Api;
|
|
|
import io.kubernetes.client.openapi.models.V1DeleteOptions;
|
|
|
@@ -81,28 +82,19 @@ public class JobApiImpl implements JobApi {
|
|
|
FOREGROUND_PROPAGATION_POLICY,
|
|
|
v1DeleteOptions
|
|
|
);
|
|
|
- } catch (ApiException e){
|
|
|
+ } catch (ApiException e) {
|
|
|
LoggerUtil.error(logger, e, "删除Job失败,namespace={}, name={}, response={}", job.getNamespace(), job.getName(), e.getResponseBody());
|
|
|
if (e.getCode() == NOT_FOUND) {
|
|
|
throw new K8sApiException(NOT_FOUND, "namespace不存在");
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
throw K8s_SYSTEM_ERROR_EXCEPTION;
|
|
|
}
|
|
|
+ } catch (JsonSyntaxException | IllegalStateException e) {
|
|
|
+ // k8s api的bug,其实删除成功了,但是返回值类型不正确
|
|
|
+ LoggerUtil.info(logger, "删除Job成功");
|
|
|
} catch (Exception e){
|
|
|
- // k8s api 删除job的时候存在bug
|
|
|
- if (e.getCause() instanceof IllegalStateException) {
|
|
|
- IllegalStateException ise = (IllegalStateException) e.getCause();
|
|
|
- if (ise.getMessage() != null && ise.getMessage().contains("Expected a string but was BEGIN_OBJECT")) {
|
|
|
- // 实际上是删除成功了
|
|
|
- LoggerUtil.error(logger, e, "Catching exception because of issue https://github.com/kubernetes/kubernetes/issues/65121");
|
|
|
- } else {
|
|
|
- LoggerUtil.error(logger, e, "删除Job失败,namespace={}, name={}, response={}", job.getNamespace());
|
|
|
- throw e;
|
|
|
- }
|
|
|
- } else {
|
|
|
- LoggerUtil.error(logger, e, "删除Job失败,namespace={}, name={}, response={}", job.getNamespace());
|
|
|
- throw e;
|
|
|
- }
|
|
|
+ LoggerUtil.error(logger, e, "删除Job失败,namespace={}, name={}, response={}", job.getNamespace());
|
|
|
+ throw e;
|
|
|
}
|
|
|
}
|
|
|
|