use of io.fabric8.kubernetes.api.model.apps.ReplicaSetList in project kubernetes-client by fabric8io.
the class DeploymentOperationsImpl method doGetLog.
private List<RollableScalableResource<ReplicaSet>> doGetLog() {
List<RollableScalableResource<ReplicaSet>> rcs = new ArrayList<>();
Deployment deployment = requireFromServer();
String rcUid = deployment.getMetadata().getUid();
ReplicaSetOperationsImpl rsOperations = new ReplicaSetOperationsImpl(new RollingOperationContext(rollingOperationContext.getContainerId(), false, 0, null, rollingOperationContext.getLogWaitTimeout()), context.withName(null));
ReplicaSetList rcList = rsOperations.withLabels(getDeploymentSelectorLabels(deployment)).list();
for (ReplicaSet rs : rcList.getItems()) {
OwnerReference ownerReference = KubernetesResourceUtil.getControllerUid(rs);
if (ownerReference != null && ownerReference.getUid().equals(rcUid)) {
rcs.add(rsOperations.withName(rs.getMetadata().getName()));
}
}
return rcs;
}
use of io.fabric8.kubernetes.api.model.apps.ReplicaSetList in project kubernetes-client by fabric8io.
the class ReplicaSetIT method list.
@Test
public void list() {
ReplicaSetList replicaSetList = client.apps().replicaSets().inNamespace(session.getNamespace()).list();
assertThat(replicaSetList).isNotNull();
assertTrue(replicaSetList.getItems().size() >= 1);
}
use of io.fabric8.kubernetes.api.model.apps.ReplicaSetList in project kubernetes-client by fabric8io.
the class ResourceIT method testDeleteExistingWithOrphanDeletion.
@Test
public void testDeleteExistingWithOrphanDeletion() throws Exception {
// Create Deployment
Resource<Deployment> resource = client.resource(deployment).inNamespace(session.getNamespace());
resource.createOrReplace();
await().atMost(30, TimeUnit.SECONDS).until(resourceIsReady(deployment));
// get uid of underlying replicaset. we expect this NOT to match later, meaning the orphan WAS deleted.
ReplicaSetList replicaSetList = client.apps().replicaSets().inNamespace(session.getNamespace()).withLabel("run", deploymentName).list();
assertEquals(1, replicaSetList.getItems().size());
String replicaSetUid = replicaSetList.getItems().get(0).getMetadata().getUid();
// Recreate deployment
resource.delete();
resource.waitUntilCondition(Objects::isNull, 30, TimeUnit.SECONDS);
resource.create();
final Callable<List<ReplicaSet>> replicaSets = () -> client.apps().replicaSets().inNamespace(session.getNamespace()).withLabel("run", deploymentName).list().getItems().stream().filter(rs -> Utils.isNullOrEmpty(rs.getMetadata().getDeletionTimestamp())).collect(Collectors.toList());
await().atMost(30, TimeUnit.SECONDS).until(() -> resourceIsReady(deployment).call() && replicaSets.call().size() == 1);
// check that uid DOES NOT MATCH original, meaning the orphan WAS deleted
assertNotEquals(replicaSetUid, replicaSets.call().iterator().next().getMetadata().getUid());
// cleanup
assertEquals(true, resource.withGracePeriod(0L).delete());
// Check whether child resources are also deleted
await().atMost(30, TimeUnit.SECONDS).until(() -> client.apps().replicaSets().inNamespace(session.getNamespace()).withLabel("run", deploymentName).list().getItems().isEmpty());
}
use of io.fabric8.kubernetes.api.model.apps.ReplicaSetList in project kubernetes-client by fabric8io.
the class DeleteIT method testDeleteWithPropagationPolicyOrphan.
@Test
public void testDeleteWithPropagationPolicyOrphan() {
// Given
String name = "deleteit-existent-orphan";
// When
Boolean isDeleted = client.apps().deployments().inNamespace(session.getNamespace()).withName(name).withPropagationPolicy(DeletionPropagation.ORPHAN).delete();
// Then
ReplicaSetList replicaSetList = client.apps().replicaSets().inNamespace(session.getNamespace()).withLabel("test", name).list();
assertTrue(isDeleted);
assertNotNull(replicaSetList);
assertEquals(1, replicaSetList.getItems().size());
assertTrue(client.resource(replicaSetList.getItems().get(0)).inNamespace(session.getNamespace()).delete());
}
use of io.fabric8.kubernetes.api.model.apps.ReplicaSetList in project kubernetes-client by fabric8io.
the class DeleteIT method testDeleteResourcePropagationPolicyOrphan.
@Test
public void testDeleteResourcePropagationPolicyOrphan() {
// Given
String name = "deleteit-resource-orphan";
// When
Deployment deploy = client.apps().deployments().inNamespace(session.getNamespace()).withName(name).get();
Boolean isDeleted = client.resource(deploy).inNamespace(session.getNamespace()).withPropagationPolicy(DeletionPropagation.ORPHAN).delete();
// Then
ReplicaSetList replicaSetList = client.apps().replicaSets().inNamespace(session.getNamespace()).withLabel("test", name).list();
assertTrue(isDeleted);
assertNotNull(replicaSetList);
assertEquals(1, replicaSetList.getItems().size());
assertTrue(client.resource(replicaSetList.getItems().get(0)).inNamespace(session.getNamespace()).delete());
}
Aggregations