|
|
@@ -1,5 +1,7 @@
|
|
|
package nju.seec.SEECdemo.logic.api.k8s.impl;
|
|
|
|
|
|
+import com.google.gson.JsonSyntaxException;
|
|
|
+import io.kubernetes.client.ApiCallback;
|
|
|
import io.kubernetes.client.ApiException;
|
|
|
import io.kubernetes.client.apis.AppsV1Api;
|
|
|
import io.kubernetes.client.models.*;
|
|
|
@@ -11,6 +13,9 @@ import org.slf4j.Logger;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
import static nju.seec.SEECdemo.logic.api.k8s.exception.K8sApiException.ALREADY_EXIST;
|
|
|
import static nju.seec.SEECdemo.logic.api.k8s.exception.K8sApiException.NOT_FOUND;
|
|
|
import static nju.seec.SEECdemo.util.Constants.FOREGROUND_PROPAGATION_POLICY;
|
|
|
@@ -52,6 +57,40 @@ public class DeploymentApiImpl implements DeploymentApi{
|
|
|
|
|
|
@Override
|
|
|
public Deployment createAsync(Deployment deployment) {
|
|
|
+ V1Deployment v1Deployment = deployment.toV1Deployment();
|
|
|
+ try {
|
|
|
+ appsV1Api.createNamespacedDeploymentAsync(deployment.getNamespace(), v1Deployment, PRETTY_FORMAT, new ApiCallback<V1Deployment>() {
|
|
|
+ @Override
|
|
|
+ public void onFailure(ApiException e, int i, Map<String, List<String>> map) {
|
|
|
+ System.out.println("fail");
|
|
|
+ System.out.println(e);
|
|
|
+ System.out.println(i);
|
|
|
+ System.out.println(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onSuccess(V1Deployment v1Deployment, int i, Map<String, List<String>> map) {
|
|
|
+ System.out.println("success");
|
|
|
+ System.out.println(v1Deployment);
|
|
|
+ System.out.println(i);
|
|
|
+ System.out.println(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onUploadProgress(long l, long l1, boolean b) {
|
|
|
+ System.out.println("on upload progress");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onDownloadProgress(long l, long l1, boolean b) {
|
|
|
+ System.out.println("on download progress " + l);
|
|
|
+ System.out.println("on download progress " + l1);
|
|
|
+ System.out.println("on download progress " + b);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } catch (ApiException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
@@ -69,7 +108,9 @@ public class DeploymentApiImpl implements DeploymentApi{
|
|
|
}else {
|
|
|
throw K8sApiException.K8s_SYSTEM_ERROR_EXCEPTION;
|
|
|
}
|
|
|
- }catch (Exception e) {
|
|
|
+ } catch (JsonSyntaxException e) {
|
|
|
+ //do nothing
|
|
|
+ } catch (Exception e) {
|
|
|
LoggerUtil.error(logger, e, "删除Deployment异常,namespace={}, name={}", namespace, name);
|
|
|
}
|
|
|
}
|
|
|
@@ -85,8 +126,11 @@ public class DeploymentApiImpl implements DeploymentApi{
|
|
|
LoggerUtil.error(logger, e, "删除Deployment失败,namespace={}, name={}, response={}", namespace, name, e.getResponseBody());
|
|
|
throw K8sApiException.K8s_SYSTEM_ERROR_EXCEPTION;
|
|
|
}
|
|
|
- }catch (Exception e) {
|
|
|
+ } catch (JsonSyntaxException e) {
|
|
|
+ //Do nothing
|
|
|
+ } catch (Exception e) {
|
|
|
LoggerUtil.error(logger, e, "删除Deployment异常,namespace={}, name={}", namespace, name);
|
|
|
+ throw K8sApiException.K8s_SYSTEM_ERROR_EXCEPTION;
|
|
|
}
|
|
|
}
|
|
|
|