Skip to content
Snippets Groups Projects
Commit 3ab79309 authored by Lukasz Lopatowski's avatar Lukasz Lopatowski
Browse files

Merge branch '302-move-application-availability-checks-from-janitor-to-platform' into 'develop'

Resolve "Move application availability checks from Janitor to Platform"

See merge request !260
parents 44c91d73 b345a06d
No related branches found
No related tags found
2 merge requests!273Release 1.8.0 update,!260Resolve "Move application availability checks from Janitor to Platform"
Pipeline #95197 passed
......@@ -3,8 +3,12 @@ package net.geant.nmaas.kubernetes;
import io.fabric8.kubernetes.api.model.Namespace;
import io.fabric8.kubernetes.api.model.NamespaceBuilder;
import io.fabric8.kubernetes.api.model.apps.Deployment;
import io.fabric8.kubernetes.api.model.apps.DeploymentList;
import io.fabric8.kubernetes.api.model.apps.StatefulSet;
import io.fabric8.kubernetes.api.model.apps.StatefulSetList;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.dsl.NonNamespaceOperation;
import io.fabric8.kubernetes.client.dsl.RollableScalableResource;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.geant.nmaas.kubernetes.remote.entities.KCluster;
......@@ -47,9 +51,13 @@ public class KubernetesApiClientService {
public Deployment getDeployment(KCluster kCluster, String namespace, String deploymentName) {
try (KubernetesClient client = initClient(kCluster)) {
return client.apps()
NonNamespaceOperation<Deployment, DeploymentList, RollableScalableResource<Deployment>> deploymentsInNamespace = client.apps()
.deployments()
.inNamespace(namespace)
.inNamespace(namespace);
log.debug("Found the following deployments in namespace {} -> {}",
namespace,
deploymentsInNamespace.list().getItems().stream().map(d -> d.getMetadata().getName()).toList());
return deploymentsInNamespace
.withName(deploymentName)
.get();
}
......@@ -57,9 +65,13 @@ public class KubernetesApiClientService {
public StatefulSet getStatefulSet(KCluster kCluster, String statefulSetName, String namespace) {
try (KubernetesClient client = initClient(kCluster)) {
return client.apps()
NonNamespaceOperation<StatefulSet, StatefulSetList, RollableScalableResource<StatefulSet>> statefulSetsInNamespace = client.apps()
.statefulSets()
.inNamespace(namespace)
.inNamespace(namespace);
log.debug("Found the following statefulsets in namespace {} -> {}",
namespace,
statefulSetsInNamespace.list().getItems().stream().map(d -> d.getMetadata().getName()).toList());
return statefulSetsInNamespace
.withName(statefulSetName)
.get();
}
......
......@@ -54,7 +54,10 @@ public class KubernetesApiJanitorService {
if (Objects.nonNull(statefulSet)) {
return Objects.equals(statefulSet.getSpec().getReplicas(), statefulSet.getStatus().getReadyReplicas());
}
throw new JanitorResponseException("");
log.info("StatefulSet not found as well");
throw new JanitorResponseException(
String.format("Not able to check application state. No deployment/statefulset with name %s found in namespace %s", deploymentId.value(), namespace)
);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment