当前位置: 首页>>代码示例>>Java>>正文


Java PodStatus.getPhase方法代码示例

本文整理汇总了Java中io.fabric8.kubernetes.api.model.PodStatus.getPhase方法的典型用法代码示例。如果您正苦于以下问题:Java PodStatus.getPhase方法的具体用法?Java PodStatus.getPhase怎么用?Java PodStatus.getPhase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.fabric8.kubernetes.api.model.PodStatus的用法示例。


在下文中一共展示了PodStatus.getPhase方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isInErrorState

import io.fabric8.kubernetes.api.model.PodStatus; //导入方法依赖的package包/类
private static Optional<Event> isInErrorState(WorkflowInstance workflowInstance, Pod pod) {
  final PodStatus status = pod.getStatus();
  final String phase = status.getPhase();

  switch (phase) {
    case "Pending":
      // check if one or more docker contains failed to pull their image, a possible silent error
      return status.getContainerStatuses().stream()
          .filter(IS_STYX_CONTAINER.and(KubernetesPodEventTranslator::hasPullImageError))
          .findAny()
          .map((x) -> Event.runError(workflowInstance, "One or more containers failed to pull their image"));

    case "Succeeded":
    case "Failed":
      final Optional<ContainerStatus> containerStatusOpt =
          pod.getStatus().getContainerStatuses().stream()
              .filter(IS_STYX_CONTAINER)
              .findFirst();

      if (!containerStatusOpt.isPresent()) {
        return Optional.of(Event.runError(workflowInstance, "Could not find our container in pod"));
      }

      final ContainerStatus containerStatus = containerStatusOpt.get();
      final ContainerStateTerminated terminated = containerStatus.getState().getTerminated();
      if (terminated == null) {
        return Optional.of(Event.runError(workflowInstance, "Unexpected null terminated status"));
      }
      return Optional.empty();

    case "Unknown":
      return Optional.of(Event.runError(workflowInstance, "Pod entered Unknown phase"));

    default:
      return Optional.empty();
  }
}
 
开发者ID:spotify,项目名称:styx,代码行数:38,代码来源:KubernetesPodEventTranslator.java

示例2: buildTaskStatus

import io.fabric8.kubernetes.api.model.PodStatus; //导入方法依赖的package包/类
TaskStatus buildTaskStatus(String id) {
	Pod pod = client.pods().inNamespace(client.getNamespace()).withName(id).get();
	if (pod == null) {
		return new TaskStatus(id, LaunchState.unknown, new HashMap<>());
	}
	PodStatus podStatus = pod.getStatus();
	if (podStatus == null) {
		return new TaskStatus(id, LaunchState.unknown, new HashMap<>());
	}
	if (podStatus.getPhase() != null) {
		if (podStatus.getPhase().equals("Pending")) {
			return new TaskStatus(id, LaunchState.launching, new HashMap<>());
		}
		else if (podStatus.getPhase().equals("Failed")) {
			return new TaskStatus(id, LaunchState.failed, new HashMap<>());
		}
		else if (podStatus.getPhase().equals("Succeeded")) {
			return new TaskStatus(id, LaunchState.complete, new HashMap<>());
		}
		else {
			return new TaskStatus(id, LaunchState.running, new HashMap<>());
		}
	}
	else {
		return new TaskStatus(id, LaunchState.launching, new HashMap<>());
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-deployer-kubernetes,代码行数:28,代码来源:KubernetesTaskLauncher.java

示例3: blockUntilComplete

import io.fabric8.kubernetes.api.model.PodStatus; //导入方法依赖的package包/类
private Optional<URI> blockUntilComplete(final String podName) throws InterruptedException {
  LOG.debug("Checking running statuses");

  boolean nodeAssigned = false;

  while (true) {
    final PodResource<Pod, DoneablePod> pod = client.pods().withName(podName);
    final PodStatus status = pod.get().getStatus();

    if (!nodeAssigned && pod.get().getSpec().getNodeName() != null) {
      LOG.info("Pod {} assigned to node {}", podName, pod.get().getSpec().getNodeName());
      nodeAssigned = true;
    }

    switch (status.getPhase()) {
      case "Succeeded":
        LOG.info("Kubernetes pod {} exited with status {}", podName, status.getPhase());

        final Optional<ContainerStatus> containerStatus = status.getContainerStatuses().stream()
            .filter(c -> HYPE_RUN.equals(c.getName()))
            .findFirst();

        final Optional<String> terminated = containerStatus
            .flatMap(s -> Optional.ofNullable(s.getState().getTerminated()))
            .flatMap(t -> Optional.ofNullable(t.getMessage()));

        if (terminated.isPresent()) {
          String message = terminated.get();
          LOG.info("Got termination message: {}", message);
          return Optional.of(URI.create(message));
        }
        break;

      case "Failed":
        LOG.info("Kubernetes pod {} failed with status {}", podName, status);
        return Optional.empty();

      default:
        break;
    }
    Thread.sleep(TimeUnit.SECONDS.toMillis(POLL_PODS_INTERVAL_SECONDS));
  }
}
 
开发者ID:spotify,项目名称:hype,代码行数:44,代码来源:KubernetesDockerRunner.java


注:本文中的io.fabric8.kubernetes.api.model.PodStatus.getPhase方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。