Search in sources :

Example 1 with DeploymentCondition

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));
    }
}
Also used : Pod(io.fabric8.kubernetes.api.model.Pod) ArrayList(java.util.ArrayList) PodCondition(io.fabric8.kubernetes.api.model.PodCondition) DeploymentCondition(io.fabric8.kubernetes.api.model.apps.DeploymentCondition)

Example 2 with DeploymentCondition

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;
    }
}
Also used : DeploymentConfig(io.fabric8.openshift.api.model.DeploymentConfig) DeploymentCondition(io.fabric8.openshift.api.model.DeploymentCondition)

Example 3 with DeploymentCondition

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));
    }
}
Also used : Pod(io.fabric8.kubernetes.api.model.Pod) ArrayList(java.util.ArrayList) PodCondition(io.fabric8.kubernetes.api.model.PodCondition) DeploymentCondition(io.fabric8.kubernetes.api.model.apps.DeploymentCondition)

Example 4 with DeploymentCondition

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;
    }
}
Also used : DeploymentConfig(io.fabric8.openshift.api.model.DeploymentConfig) DeploymentCondition(io.fabric8.openshift.api.model.DeploymentCondition)

Example 5 with DeploymentCondition

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"));
}
Also used : DeploymentStatus(io.fabric8.kubernetes.api.model.apps.DeploymentStatus) DeploymentCondition(io.fabric8.kubernetes.api.model.apps.DeploymentCondition)

Aggregations

DeploymentCondition (io.fabric8.kubernetes.api.model.apps.DeploymentCondition)3 Pod (io.fabric8.kubernetes.api.model.Pod)2 PodCondition (io.fabric8.kubernetes.api.model.PodCondition)2 DeploymentCondition (io.fabric8.openshift.api.model.DeploymentCondition)2 DeploymentConfig (io.fabric8.openshift.api.model.DeploymentConfig)2 ArrayList (java.util.ArrayList)2 DeploymentStatus (io.fabric8.kubernetes.api.model.apps.DeploymentStatus)1