use of io.fabric8.kubernetes.api.model.apps.DeploymentCondition in project strimzi-kafka-operator by strimzi.
the class DeploymentUtils method logCurrentDeploymentStatus.
/**
* Log actual status of deployment with pods
* @param deployment - every Deployment, that HasMetadata and has status (fabric8 status)
*/
public static void logCurrentDeploymentStatus(Deployment deployment, String namespaceName) {
if (deployment != null) {
String kind = deployment.getKind();
String name = deployment.getMetadata().getName();
List<String> log = new ArrayList<>(asList("\n", kind, " status:\n", "\nConditions:\n"));
for (DeploymentCondition deploymentCondition : deployment.getStatus().getConditions()) {
log.add("\tType: " + deploymentCondition.getType() + "\n");
log.add("\tMessage: " + deploymentCondition.getMessage() + "\n");
}
if (kubeClient(namespaceName).listPodsByPrefixInName(name).size() != 0) {
log.add("\nPods with conditions and messages:\n\n");
for (Pod pod : kubeClient(namespaceName).listPodsByPrefixInName(name)) {
log.add(pod.getMetadata().getName() + ":");
for (PodCondition podCondition : pod.getStatus().getConditions()) {
if (podCondition.getMessage() != null) {
log.add("\n\tType: " + podCondition.getType() + "\n");
log.add("\tMessage: " + podCondition.getMessage() + "\n");
}
}
log.add("\n\n");
}
LOGGER.info("{}", String.join("", log));
}
LOGGER.info("{}", String.join("", log));
}
}
use of io.fabric8.kubernetes.api.model.apps.DeploymentCondition in project strimzi by strimzi.
the class DeploymentConfigOperator method isObserved.
/**
* Check if a deployment configuration has been observed.
*
* @param namespace The namespace.
* @param name The resource name.
* @return Whether the deployment has been observed.
*/
private boolean isObserved(String namespace, String name) {
DeploymentConfig dep = get(namespace, name);
if (dep != null) {
// Get the roll out status
// => Sometimes it takes OCP some time before the generations are updated.
// So we need to check the conditions in addition to detect such situation.
boolean rollOutNotStarting = true;
DeploymentCondition progressing = getProgressingCondition(dep);
if (progressing != null) {
rollOutNotStarting = progressing.getReason() != null && !"Unknown".equals(progressing.getStatus());
}
return dep.getMetadata().getGeneration().equals(dep.getStatus().getObservedGeneration()) && rollOutNotStarting;
} else {
return false;
}
}
use of io.fabric8.kubernetes.api.model.apps.DeploymentCondition in project strimzi by strimzi.
the class DeploymentUtils method logCurrentDeploymentStatus.
/**
* Log actual status of deployment with pods
* @param deployment - every Deployment, that HasMetadata and has status (fabric8 status)
*/
public static void logCurrentDeploymentStatus(Deployment deployment, String namespaceName) {
if (deployment != null) {
String kind = deployment.getKind();
String name = deployment.getMetadata().getName();
List<String> log = new ArrayList<>(asList("\n", kind, " status:\n", "\nConditions:\n"));
for (DeploymentCondition deploymentCondition : deployment.getStatus().getConditions()) {
log.add("\tType: " + deploymentCondition.getType() + "\n");
log.add("\tMessage: " + deploymentCondition.getMessage() + "\n");
}
if (kubeClient(namespaceName).listPodsByPrefixInName(name).size() != 0) {
log.add("\nPods with conditions and messages:\n\n");
for (Pod pod : kubeClient(namespaceName).listPodsByPrefixInName(name)) {
log.add(pod.getMetadata().getName() + ":");
for (PodCondition podCondition : pod.getStatus().getConditions()) {
if (podCondition.getMessage() != null) {
log.add("\n\tType: " + podCondition.getType() + "\n");
log.add("\tMessage: " + podCondition.getMessage() + "\n");
}
}
log.add("\n\n");
}
LOGGER.info("{}", String.join("", log));
}
LOGGER.info("{}", String.join("", log));
}
}
use of io.fabric8.kubernetes.api.model.apps.DeploymentCondition in project strimzi-kafka-operator by strimzi.
the class DeploymentConfigOperator method isObserved.
/**
* Check if a deployment configuration has been observed.
*
* @param namespace The namespace.
* @param name The resource name.
* @return Whether the deployment has been observed.
*/
private boolean isObserved(String namespace, String name) {
DeploymentConfig dep = get(namespace, name);
if (dep != null) {
// Get the roll out status
// => Sometimes it takes OCP some time before the generations are updated.
// So we need to check the conditions in addition to detect such situation.
boolean rollOutNotStarting = true;
DeploymentCondition progressing = getProgressingCondition(dep);
if (progressing != null) {
rollOutNotStarting = progressing.getReason() != null && !"Unknown".equals(progressing.getStatus());
}
return dep.getMetadata().getGeneration().equals(dep.getStatus().getObservedGeneration()) && rollOutNotStarting;
} else {
return false;
}
}
use of io.fabric8.kubernetes.api.model.apps.DeploymentCondition in project debezium by debezium.
the class WaitConditions method deploymentAvailableCondition.
/**
* Wait condition for deployments
* @param resource deployment resource
* @return true when deployment becomes available
*/
public static boolean deploymentAvailableCondition(Deployment resource) {
DeploymentStatus status = resource.getStatus();
if (status == null) {
return false;
}
Stream<DeploymentCondition> conditions = status.getConditions().stream();
return conditions.anyMatch(c -> c.getType().equalsIgnoreCase("Available") && c.getStatus().equalsIgnoreCase("True"));
}
Aggregations