protected void setSystemLabel(Instance instance, Map<String, Object> labels) { if(Boolean.TRUE.equals(instance.getSystem()) && !labels.containsKey(SystemLabels.LABEL_CONTAINER_SYSTEM)) { labels.put(SystemLabels.LABEL_CONTAINER_SYSTEM, "true"); } }
public static boolean isSystem(Instance instance) { return instance.getSystem() || isRancherAgent(instance); }
@Override protected Object getAgentResource(ProcessState state, ProcessInstance process, Object dataResource) { Instance instance = getInstance(state); if (!isPod(instance)) { return false; } Long accountId = instance.getAccountId(); List<Long> agentIds = agentInstanceDao.getAgentProvider(SystemLabels.LABEL_AGENT_SERVICE_LABELS_PROVIDER, accountId); Long agentId = agentIds.size() == 0 ? null : agentIds.get(0); if ((instance instanceof Instance) && (agentIds.contains(instance.getAgentId()) || instance.getSystem())) { return null; } if (agentId == null) { if (k8sRequired(instance)) { throw new ExecutionException("Failed to find labels provider", instance); } else { return null; } } return agentId; }
@Override public HandlerResult handle(ProcessState state, ProcessInstance process) { Instance instance = (Instance)state.getResource(); if (!Boolean.TRUE.equals(instance.getSystem())) { return null; } List<Long> agentIds = agentInstanceDao.getAgentProviderIgnoreHealth(SystemLabels.LABEL_AGENT_SERVICE_IPSEC, instance.getAccountId()); for (long agentId : agentIds) { ConfigUpdateRequest request = ConfigUpdateRequest.forResource(Agent.class, agentId); ConfigUpdateItem item = request.addItem("psk"); item.setApply(true); item.setIncrement(false); statusManager.updateConfig(request); } return null; }
this.uuid = instance.getUuid(); this.external_id = instance.getExternalId(); this.system = instance.getSystem(); Map<String, String> labels = DataAccessor.fields(instance).withKey(InstanceConstants.FIELD_LABELS) .withDefault(Collections.EMPTY_MAP).as(Map.class);
@SuppressWarnings("unchecked") private void callExternalSchedulerToReserve(AllocationAttempt attempt, AllocationCandidate candidate) { List<Long> agentIds = getAgentResource(attempt.getAccountId(), attempt.getInstances()); if (agentIds.isEmpty() && !attempt.getInstances().get(0).getSystem() && allocatorDao.isSchedulerServiceEnabled(attempt.getAccountId()) && allocatorDao.isScheulderIpsEnabled(attempt.getAccountId())) { List<ResourceRequest> resourceRequests = gatherResourceRequests(attempt.getInstances(), attempt.getVolumes(), null);
setMemoryReservation(from.getMemoryReservation()); setMilliCpuReservation(from.getMilliCpuReservation()); setSystem(from.getSystem()); setServiceId(from.getServiceId()); setStackId(from.getStackId());