for (ContainerState containerState : containerStates) { if (containerState.names == null || containerState.names.isEmpty()) { logInfo("Names not set for container: %s", containerState.documentSelfLink); if (counter.decrementAndGet() == 0) { callback.accept(null);
private void updateExistingContainer(ContainerState c, ContainerListCallback callback) { boolean changed = false; ContainerState patch = new ContainerState(); // handle power state changes PowerState newPowerState = callback.containerIdsAndState.get(c.id); if (newPowerState != null && c.powerState != newPowerState && !ContainerState.CONTAINER_UNHEALTHY_STATUS.equals(c.status)) { // do not modify the power state set during the health config check! logInfo("Changing power state of container %s (%s) from %s to %s", c.names, c.documentSelfLink, c.powerState, newPowerState); changed = true; patch.powerState = newPowerState; } if (changed) { // power state is change - save the new state and inspect the container sendRequest(Operation .createPatch(this, c.documentSelfLink) .setBodyNoCloning(patch)); inspectContainer(c, ServiceTaskCallback.createEmpty()); } }
(ComputeState host) -> { if (ContainerHostUtil.getDriver(host) == null) { logInfo("Skipping the installation of the system container." + "The driver is not initialized."); return; logInfo("VIC host detected, system containers will not be installed."); return; logInfo("Kubernetes host detected, system containers will not be" + " installed."); return;
private void createDiscoveredContainerDescription(ContainerState containerState) { logFine("Creating ContainerDescription for discovered container: %s", containerState.id); ContainerDescription containerDesc = ContainerUtil .createContainerDescription(containerState); sendRequest(OperationUtil .createForcedPost(this, ContainerDescriptionService.FACTORY_LINK) .setBodyNoCloning(containerDesc) .setCompletion((o, ex) -> { if (ex != null) { logSevere("Failed to create ContainerDescription for discovered container" + " (id=%s): %s", containerState.id, ex.getMessage()); } else { logInfo("Created ContainerDescription for discovered container: %s", containerState.id); } })); }
private void patchHostState(String containerHostLink, ComputeState state) { sendRequest(Operation .createPatch(this, containerHostLink) .setBody(state) .setCompletion((operation, e) -> { if (e != null) { logSevere("Failure updating host [%s] with container count. Error: %s", containerHostLink, Utils.toString(e)); return; } logInfo("Host [%s] updated with container count.", containerHostLink); })); }
return; logInfo("Provisioning system container: %s with name: %s started ...", container.documentSelfLink, container.names); }));
logInfo("Created ContainerState for discovered container: %s", containerState.id);
return; logInfo("Deleted ContainerState of missing container: %s", containerState.documentSelfLink); })); containerState.documentSelfLink, Utils.toString(ex)); } else { logInfo("Marked container as missing: %s (expiration=%d hours)", containerState.documentSelfLink, RETIRED_CONTAINER_EXPIRE_PERIOD_HOURS);
logInfo("Already created system container state: %s", r.getResult().documentSelfLink); op = Operation.createPut(this, containerStateLink); logInfo("Created system ContainerState: %s", body.documentSelfLink); createSystemContainerInstanceRequest(body, null); updateNumberOfContainers(containerHostLink);
private void startSystemContainer(ContainerState containerState, ServiceTaskCallback serviceTaskCallback) { AdapterRequest adapterRequest = new AdapterRequest(); adapterRequest.resourceReference = UriUtils .buildUri(getHost(), containerState.documentSelfLink); adapterRequest.operationTypeId = ContainerOperationType.START.id; if (serviceTaskCallback == null) { String systemContainerName = isSystemContainer( SystemContainerDescriptions.getSystemContainerNames(), containerState.names); startAndCreateCallbackHandlerService(systemContainerName, createSystemContainerReadyHandler(containerState), (callback) -> startSystemContainer(containerState, callback)); return; } adapterRequest.serviceTaskCallback = serviceTaskCallback; sendRequest(Operation .createPatch(getHost(), containerState.adapterManagementReference.toString()) .setBodyNoCloning(adapterRequest) .setCompletion((o, e) -> { if (e != null) { logWarning("Failure starting system container: %s", Utils.toString(e)); return; } logInfo("Starting system container: %s with name: %s ...", containerState.documentSelfLink, containerState.names); })); }
logInfo("Created system ContainerState: %s", body.documentSelfLink); createSystemContainerInstanceRequest(body, null);
retryCount, request.hostUri, Utils.toString(e)); getHost().schedule(() -> { logInfo("Waiting for the system container SSL certificate from '%s'" + " to be imported", request.hostUri); importAgentSslCertificate(container, host, retryCount - 1); logInfo("System container SSL certificate imported from '%s'", request.hostUri); }));