private boolean validate(Set<ResourceState> resourcesStates) { if (resourcesStates.stream() .filter(r -> r instanceof ContainerState) .map(r -> ((ContainerState) r)) .anyMatch(c -> isSystemContainer(c))) { failTask(null, new LocalizableValidationException( "Day2 operations are not supported for system container", "request.system.container.day2")); return false; } return true; }
private void queryContainerResources(ContainerOperationTaskState state) { QueryTask computeQuery = createResourcesQuery(ContainerState.class, state.resourceLinks); ServiceDocumentQuery<ContainerState> query = new ServiceDocumentQuery<>(getHost(), ContainerState.class); final List<ContainerState> documents = new ArrayList<>(state.resourceLinks.size()); query.query(computeQuery, (r) -> { if (r.hasException()) { failTask("Failure retrieving query results", r.getException()); } else if (r.hasResult()) { if (isSystemContainer(r.getResult())) { failTask(null, new LocalizableValidationException( "Day2 operations are not supported for system container", "request.system.container.day2")); } documents.add(r.getResult()); } else { if (documents.isEmpty()) { if (ContainerOperationType.DELETE.id.equals(state.operation)) { logWarning("No resources found to be removed with links: %s", state.resourceLinks); proceedTo(SubStage.COMPLETED); } else { failTask("No available resources", null); } } else { performResourceOperations(state, documents, null); } } }); }
if (isSystemContainer(o.getBody(ContainerState.class)) && !(isRemoveHost.get())) { logWarning("Resource [%s] will not be removed because it is a"
private Operation releaseResourcePlacement(ContainerRemovalTaskState state, ContainerState cs, String subTaskLink) { if (isDiscoveredContainer(cs) || state.skipReleaseResourcePlacement) { logFine("Skipping releasing placement because container is a discovered one: %s", cs.documentSelfLink); return null; } if (isSystemContainer(cs)) { logFine("Skipping releasing placement because container is a system one: %s", cs.documentSelfLink); return null; } ReservationRemovalTaskState rsrvTask = new ReservationRemovalTaskState(); rsrvTask.resourceCount = 1; rsrvTask.resourceDescriptionLink = cs.descriptionLink; rsrvTask.groupResourcePlacementLink = cs.groupResourcePlacementLink; rsrvTask.requestTrackerLink = state.requestTrackerLink; // Completion of the reservation removal also notifies the counter task rsrvTask.serviceTaskCallback = ServiceTaskCallback.create(subTaskLink); return Operation.createPost(this, ReservationRemovalTaskFactoryService.SELF_LINK) .setBody(rsrvTask) .setCompletion((o, e) -> { if (e != null) { logWarning("Failed creating task to delete placement %s. Error: %s", cs.groupResourcePlacementLink, Utils.toString(e)); return; } }); }
containerState.documentSelfLink); completeSubTasksCounter(subTaskLink, null); } else if (isSystemContainer(o.getBody(ContainerState.class))) { logWarning( "Resource [%s] will not be removed because it is a system container",
private void handleMissingContainer(ContainerState containerState) { if (SystemContainerDescriptions.isSystemContainer(containerState)) { return;