public void removeValid(String fingerprint) { if (fingerprintToLatestValidConfigMap.containsKey(fingerprint)) { fingerprintToLatestValidConfigMap.remove(fingerprint); serverHealthService.removeByScope(HealthStateScope.forPartialConfigRepo(fingerprint)); } }
public void removeKnown(String fingerprint) { if (fingerprintToLatestKnownConfigMap.containsKey(fingerprint)) { fingerprintToLatestKnownConfigMap.remove(fingerprint); serverHealthService.removeByScope(HealthStateScope.forPartialConfigRepo(fingerprint)); } }
private void markAsValidAndUpdateServerHealthMessage(String fingerprint, PartialConfig newPart) { fingerprintToLatestValidConfigMap.put(fingerprint, newPart); serverHealthService.removeByScope(HealthStateScope.forPartialConfigRepo(fingerprint)); }
public void onConfigChange(CruiseConfig newCruiseConfig) { if (registering) { registering = false; return; } serverHealthService.removeByScope(HealthStateScope.forInvalidConfig()); }
private void removeByScope(HealthStateType type) { removeByScope(type.getScope()); }
private void removeMessagesForElementsNoLongerInConfig(CruiseConfig cruiseConfig) { for (HealthStateType type : entryKeys()) { if (type.isRemovedFromConfig(cruiseConfig)) { this.removeByScope(type); } } }
@Override public void onConfigChange(CruiseConfig newCruiseConfig) { for (ServerHealthState state : serverHealthService.logs()) { HealthStateScope currentScope = state.getType().getScope(); if (currentScope.isForJob()) { serverHealthService.removeByScope(currentScope); } } }
public void onConfigChange(CruiseConfig newCruiseConfig) { Set<HealthStateScope> materialScopes = toHealthStateScopes(newCruiseConfig.getAllUniqueMaterials()); for (ServerHealthState state : serverHealthService.logs()) { HealthStateScope currentScope = state.getType().getScope(); if (currentScope.isForMaterial() && !materialScopes.contains(currentScope)) { serverHealthService.removeByScope(currentScope); } } }
private void removeHungJobWarning(JobIdentifier jobIdentifier) { serverHealthService.removeByScope(HealthStateScope.forJob(jobIdentifier.getPipelineName(), jobIdentifier.getStageName(), jobIdentifier.getBuildName())); }
public void checkRepoAndAddWarningIfRequired() { try { if (configRepository.getLooseObjectCount() >= systemEnvironment.get(SystemEnvironment.GO_CONFIG_REPO_GC_LOOSE_OBJECT_WARNING_THRESHOLD)) { String message = "Action required: Run 'git gc' on config.git repo"; String description = "Number of loose objects in your Configuration repository(config.git) has grown beyond " + "the configured threshold. As the size of config repo increases, the config save operations tend to slow down " + "drastically. It is recommended that you run 'git gc' from " + "'<go server installation directory>/db/config.git/' to address this problem. Go can do this " + "automatically on a periodic basis if you enable automatic GC. <a target='_blank' href='" + docsUrl("/advanced_usage/config_repo.html") + "'>read more...</a>"; serverHealthService.update(ServerHealthState.warningWithHtml(message, description, HealthStateType.general(HealthStateScope.forConfigRepo(SCOPE)))); LOGGER.warn("{}:{}", message, description); } else { serverHealthService.removeByScope(HealthStateScope.forConfigRepo(SCOPE)); } } catch (Exception e) { LOGGER.error(e.getMessage(), e); } } }
private void replaceServerHealthMessages(String errorMessageTitle, HealthStateScope scope, List<PluginHealthMessage> pluginHealthMessages) { serverHealthService.removeByScope(scope); for (int index = 0; index < pluginHealthMessages.size(); index++) { PluginHealthMessage pluginHealthMessage = pluginHealthMessages.get(index); ServerHealthState state; if (pluginHealthMessage.isWarning()) { state = ServerHealthState.warning(errorMessageTitle, pluginHealthMessage.message(), HealthStateType.withSubkey(scope, "message_" + index)); } else { state = ServerHealthState.error(errorMessageTitle, pluginHealthMessage.message(), HealthStateType.withSubkey(scope, "message_" + index)); } serverHealthService.update(state); } } }
public void onMessage(MaterialUpdateCompletedMessage message) { if (message instanceof MaterialUpdateSkippedMessage) { inProgress.remove(message.getMaterial()); return; } try { LOGGER.debug("[Material Update] Material update completed for material {}", message.getMaterial()); Date addedOn = inProgress.remove(message.getMaterial()); serverHealthService.removeByScope(HealthStateScope.forMaterialUpdate(message.getMaterial())); if (addedOn == null) { LOGGER.warn("[Material Update] Material {} was not removed from those inProgress. This might result in it's pipelines not getting scheduled. in-progress: {}", message.getMaterial(), inProgress); } for (MaterialUpdateCompleteListener listener : materialUpdateCompleteListeners) { listener.onMaterialUpdate(message.getMaterial()); } } finally { mduPerformanceLogger.completionMessageForMaterialReceived(message.trackingId(), message.getMaterial()); } }
public void heartbeat() { LinkedMultiValueMap<String, ElasticAgentMetadata> elasticAgentsOfMissingPlugins = agentService.allElasticAgents(); // pingMessage TTL is set lesser than elasticPluginHeartBeatInterval to ensure there aren't multiple ping request for the same plugin long pingMessageTimeToLive = elasticPluginHeartBeatInterval - 10000L; for (PluginDescriptor descriptor : elasticAgentPluginRegistry.getPlugins()) { serverPingQueue.post(new ServerPingMessage(descriptor.id()), pingMessageTimeToLive); elasticAgentsOfMissingPlugins.remove(descriptor.id()); serverHealthService.removeByScope(scope(descriptor.id())); } if (!elasticAgentsOfMissingPlugins.isEmpty()) { for (String pluginId : elasticAgentsOfMissingPlugins.keySet()) { Collection<String> uuids = elasticAgentsOfMissingPlugins.get(pluginId).stream().map(ElasticAgentMetadata::uuid).collect(Collectors.toList()); String description = String.format("Elastic agent plugin with identifier %s has gone missing, but left behind %s agent(s) with UUIDs %s.", pluginId, elasticAgentsOfMissingPlugins.get(pluginId).size(), uuids); serverHealthService.update(ServerHealthState.warning("Elastic agents with no matching plugins", description, HealthStateType.general(scope(pluginId)))); LOGGER.warn(description); } } }
@Override public void onEntityConfigChange(PipelineConfig pipelineConfig) { for (ServerHealthState state : serverHealthService.logs()) { HealthStateScope currentScope = state.getType().getScope(); if (currentScope.isForJob()) { String[] split = currentScope.getScope().split("/"); if (split.length > 0 && new CaseInsensitiveString(split[0]).equals(pipelineConfig.name())) { serverHealthService.removeByScope(currentScope); } } } } }
healthService.removeByScope(scope); } catch (Exception e) { String message = "Modification check failed for material: " + material.getLongDescription();
@Override public void onMessage(PluginNotificationMessage message) { HealthStateScope scope = HealthStateScope.aboutPlugin(message.pluginId()); try { LOGGER.debug("Sending {} notification message {} for plugin {}", message.getRequestName(), message, message.pluginId()); Result result = notificationExtension.notify(message.pluginId(), message.getRequestName(), message.getData()); if (result.isSuccessful()) { serverHealthService.removeByScope(scope); LOGGER.debug("Successfully sent {} notification message {} for plugin {}", message.getRequestName(), message, message.pluginId()); } else { String errorDescription = result.getMessages() == null ? null : StringUtils.join(result.getMessages(), ", "); handlePluginNotifyError(message.pluginId(), scope, errorDescription, null); } } catch (Exception e) { String errorDescription = e.getMessage() == null ? "Unknown error" : e.getMessage(); handlePluginNotifyError(message.pluginId(), scope, errorDescription, e); } }
public boolean updateMaterial(Material material) { Date inProgressSince = inProgress.putIfAbsent(material, new Date()); if (inProgressSince == null || !material.isAutoUpdate()) { LOGGER.debug("[Material Update] Starting update of material {}", material); try { long trackingId = mduPerformanceLogger.materialSentToUpdateQueue(material); queueFor(material).post(new MaterialUpdateMessage(material, trackingId)); return true; } catch (RuntimeException e) { inProgress.remove(material); throw e; } } else { LOGGER.warn("[Material Update] Skipping update of material {} which has been in-progress since {}", material, inProgressSince); long idleTime = getProcessManager().getIdleTimeFor(material.getFingerprint()); if (idleTime > getMaterialUpdateInActiveTimeoutInMillis()) { HealthStateScope scope = HealthStateScope.forMaterialUpdate(material); serverHealthService.removeByScope(scope); serverHealthService.update(warning("Material update for " + material.getUriForDisplay() + " hung:", "Material update is currently running but has not shown any activity in the last " + idleTime / 60000 + " minute(s). This may be hung. Details - " + material.getLongDescription(), general(scope))); } return false; } }
String environment = environmentConfigService.envForPipeline(plan.getPipelineName()); createAgentQueue.post(new CreateAgentMessage(goConfigService.serverConfig().getAgentAutoRegisterKey(), environment, plan.getElasticProfile(), plan.getIdentifier()), messageTimeToLive); serverHealthService.removeByScope(HealthStateScope.forJob(plan.getIdentifier().getPipelineName(), plan.getIdentifier().getStageName(), plan.getIdentifier().getBuildName())); } else { String jobConfigIdentifier = plan.getIdentifier().jobConfigIdentifier().toString();
serverHealthService.removeByScope(HealthStateScope.forPipeline(pipelineName)); LOGGER.debug("finished producing buildcause for {}", pipelineName); return ServerHealthState.success(HealthStateType.general(HealthStateScope.forPipeline(pipelineName)));
@Test public void shouldRemoveLogByCategoryFromServerHealth() throws Exception { HealthStateScope scope = forPipeline(PIPELINE_NAME); serverHealthService.update(ServerHealthState.error("message", "description", HealthStateType.general(scope))); serverHealthService.update(ServerHealthState.error("message", "description", HealthStateType.invalidLicense(scope))); serverHealthService.update(ServerHealthState.error("message", "description", globalId)); assertThat(serverHealthService.logs().size(), is(3)); serverHealthService.removeByScope(scope); assertThat(serverHealthService.logs().size(), is(1)); assertThat(serverHealthService, ServerHealthMatcher.containsState(globalId)); }