Java Code Examples for io.kubernetes.client.openapi.ApiException#getMessage()

The following examples show how to use io.kubernetes.client.openapi.ApiException#getMessage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AppsV1Controller.java    From incubator-heron with Apache License 2.0 6 votes vote down vote up
@Override
public void removeContainers(Set<PackingPlan.ContainerPlan> containersToRemove) {
  final V1StatefulSet statefulSet;
  try {
    statefulSet = getStatefulSet();
  } catch (ApiException ae) {
    final String message = ae.getMessage() + "\ndetails:" + ae.getResponseBody();
    throw new TopologyRuntimeManagementException(message, ae);
  }
  final int currentContainerCount = statefulSet.getSpec().getReplicas();
  final int newContainerCount = currentContainerCount - containersToRemove.size();

  final V1StatefulSetSpec newSpec = new V1StatefulSetSpec();
  newSpec.setReplicas(newContainerCount);

  try {
    doPatch(newSpec);
  } catch (ApiException e) {
    throw new TopologyRuntimeManagementException(
        e.getMessage() + "\ndetails\n" + e.getResponseBody());
  }
}
 
Example 2
Source File: MavenDeployPlugin.java    From dew with Apache License 2.0 5 votes vote down vote up
@Override
public Optional<String> fetchLastDeployedVersion(String projectId, String appName, String namespace) {
    try {
        return VersionController.getLastVersion(projectId, appName, namespace, true)
                .map(VersionController::getAppVersion);
    } catch (ApiException e) {
        throw new ProjectProcessException(e.getMessage(), e);
    }
}
 
Example 3
Source File: KubernetesDeployPlugin.java    From dew with Apache License 2.0 5 votes vote down vote up
@Override
public Optional<String> fetchLastDeployedVersion(String projectId, String appName, String namespace) throws ProjectProcessException {
    V1Service service;
    try {
        service = KubeHelper.inst(projectId).read(appName, namespace, KubeRES.SERVICE, V1Service.class);
        if (service == null) {
            return Optional.empty();
        }
        return Optional.of(VersionController.getAppVersion(service));
    } catch (ApiException e) {
        throw new ProjectProcessException(e.getMessage(), e);
    }
}
 
Example 4
Source File: AppsV1Controller.java    From incubator-heron with Apache License 2.0 5 votes vote down vote up
@Override
boolean submit(PackingPlan packingPlan) {
  final String topologyName = getTopologyName();
  if (!topologyName.equals(topologyName.toLowerCase())) {
    throw new TopologySubmissionException("K8S scheduler does not allow upper case topologies.");
  }

  final Resource containerResource = getContainerResource(packingPlan);

  // find the max number of instances in a container so we can open
  // enough ports if remote debugging is enabled.
  int numberOfInstances = 0;
  for (PackingPlan.ContainerPlan containerPlan : packingPlan.getContainers()) {
    numberOfInstances = Math.max(numberOfInstances, containerPlan.getInstances().size());
  }
  final V1StatefulSet statefulSet = createStatefulSet(containerResource, numberOfInstances);

  try {
    final V1StatefulSet response =
        appsClient.createNamespacedStatefulSet(getNamespace(), statefulSet, null,
            null, null);
  } catch (ApiException e) {
    KubernetesUtils.logExceptionWithDetails(LOG, "Error creating topology", e);
    throw new TopologySubmissionException(e.getMessage());
  }

  return true;
}