private ServerHealthState kickMe(ServerHealthState whatWentWrong, boolean isEverythingOk) { canContinue = isEverythingOk; serverHealthService.update(whatWentWrong); state = whatWentWrong; return whatWentWrong; }
public ServerHealthState success(HealthStateType healthStateType) { ServerHealthState state = ServerHealthState.success(healthStateType); serverHealthService.update(state); return state; }
public ServerHealthState error(String message, String description, HealthStateType type) { ServerHealthState state = ServerHealthState.error(message, description, type); serverHealthService.update(state); canContinue = false; return state; }
public ServerHealthState warning(String message, String description, HealthStateType type) { ServerHealthState state = ServerHealthState.warning(message, description, type); serverHealthService.update(state); canContinue = false; return state; }
private synchronized void saveValidConfigToCache(GoConfigHolder configHolder) { if (configHolder != null) { LOGGER.debug("[Config Save] Saving config to the cache"); this.lastException = null; this.configHolder = configHolder; this.currentConfig = this.configHolder.config; this.currentConfigForEdit = this.configHolder.configForEdit; this.mergedCurrentConfigForEdit = configHolder.mergedConfigForEdit; serverHealthService.update(ServerHealthState.success(HealthStateType.invalidConfig())); } }
private void handlePluginNotifyError(String pluginId, HealthStateScope scope, String errorDescription, Exception e) { String message = "Notification update failed for plugin: " + pluginId; serverHealthService.update(ServerHealthState.error(message, errorDescription, HealthStateType.general(scope))); LOGGER.warn(message, e); }
public void onConfigChange(CruiseConfig newCruiseConfig) { ServerHealthState serverHealthState; if (isArtifactsDirChanged(newCruiseConfig)) { serverHealthState = ServerHealthState.warning(ARTIFACTS_ROOT_CHANGED_MESSAGE, ARTIFACTS_ROOT_CHANGED_DESC, ARTIFACTS_ROOT_CHANGE_HEALTH_STATE_TYPE); LOGGER.info("[Configuration Changed] Artifacts directory was changed."); } else { serverHealthState = ServerHealthState.success(ARTIFACTS_ROOT_CHANGE_HEALTH_STATE_TYPE); } serverHealthService.update(serverHealthState); }
private void setServerHealthError(String message, String description) { serverHealthService.update( ServerHealthState.error(message, description, HealthStateType.general(HealthStateScope.forBackupCron())) ); }
private void clearServerHealthError() { serverHealthService.update( ServerHealthState.success(HealthStateType.general(HealthStateScope.forBackupCron())) ); }
private void showPipelineError(PipelineConfig pipelineConfig, Exception e, String msg, String description) { LOG.error(msg, e); serverHealthService.update( ServerHealthState.error(msg, description, HealthStateType.general(HealthStateScope.forPipeline(CaseInsensitiveString.str(pipelineConfig.name()))))); }
private synchronized void saveConfigError(Exception e) { this.lastException = e; ServerHealthState state = ServerHealthState.error(INVALID_CRUISE_CONFIG_XML, GoConfigValidity.invalid(e).errorMessage(), HealthStateType.invalidConfig()); serverHealthService.update(state); }
public void canProduce(PipelineConfig pipelineConfig, SchedulingCheckerService schedulingChecker, ServerHealthService serverHealthService, OperationResult operationResult) { schedulingChecker.canTriggerManualPipeline(pipelineConfig, CaseInsensitiveString.str(username.getUsername()), operationResult); if (!operationResult.canContinue()) { ServerHealthState serverHealthState = operationResult.getServerHealthState(); LOGGER.info("'{}' because '{}'", serverHealthState.getMessage(), serverHealthState.getDescription()); serverHealthService.update(serverHealthState); } }
@Test public void shouldRemoteExistingWarningAboutGCIfLooseObjectCountGoesBelowTheSetThreshold() throws Exception { serverHealthService.update(ServerHealthState.warning("message", "description", HealthStateType.general(HealthStateScope.forConfigRepo("GC")))); assertThat(serverHealthService.filterByScope(HealthStateScope.forConfigRepo("GC")).isEmpty(), is(false)); when(systemEnvironment.get(SystemEnvironment.GO_CONFIG_REPO_GC_LOOSE_OBJECT_WARNING_THRESHOLD)).thenReturn(10L); when(configRepository.getLooseObjectCount()).thenReturn(1L); service.checkRepoAndAddWarningIfRequired(); assertThat(serverHealthService.filterByScope(HealthStateScope.forConfigRepo("GC")).isEmpty(), is(true)); }
@Test public void shouldAddMultipleLogToServerHealth() throws Exception { assertThat(serverHealthService.update(ServerHealthState.error("message", "description", globalId)), is(globalId)); assertThat(serverHealthService.update(ServerHealthState.error("message", "description", pipelineId)), is(pipelineId)); assertThat(serverHealthService.logs().size(), is(2)); assertThat(serverHealthService, ServerHealthMatcher.containsState(globalId)); assertThat(serverHealthService, ServerHealthMatcher.containsState(pipelineId)); }
@Test public void shouldRemoveErrorLogWhenCorrespondingPipelineIsMissing() throws Exception { serverHealthService.update(ServerHealthState.error("message", "description", pipelineId)); serverHealthService.update(ServerHealthState.error("message", "description", HealthStateType.general(forPipeline("other")))); serverHealthService.purgeStaleHealthMessages(new BasicCruiseConfig()); assertThat(serverHealthService.logs().size(), is(0)); }
@Test public void shouldReturnErrorLogs() throws Exception { serverHealthService.update(ServerHealthState.error("message", "description", pipelineId)); CruiseConfig cruiseConfig = new BasicCruiseConfig(); new GoConfigMother().addPipeline(cruiseConfig, PIPELINE_NAME, "stageName", "jon"); serverHealthService.purgeStaleHealthMessages(cruiseConfig); assertThat(serverHealthService.logs().size(), is(1)); }
@Test public void shouldRemoveErrorLogWhenCorrespondingMaterialIsMissing() throws Exception { serverHealthService.update(ServerHealthState.error("hg-message", "description", HealthStateType.general(forMaterial(MaterialsMother.hgMaterial())))); SvnMaterialConfig svnMaterialConfig = MaterialConfigsMother.svnMaterialConfig(); serverHealthService.update(ServerHealthState.error("svn-message", "description", HealthStateType.general(forMaterialConfig(svnMaterialConfig)))); CruiseConfig cruiseConfig = new BasicCruiseConfig(); cruiseConfig.addPipeline("defaultGroup", new PipelineConfig(new CaseInsensitiveString("dev"), new MaterialConfigs(svnMaterialConfig), new StageConfig(new CaseInsensitiveString("first"), new JobConfigs()))); serverHealthService.purgeStaleHealthMessages(cruiseConfig); assertThat(serverHealthService.logs().size(), is(1)); }
@Test public void globalStateRelatedPipelineNames() { HgMaterial hgMaterial = MaterialsMother.hgMaterial(); CruiseConfig config = new BasicCruiseConfig(); config.addPipeline("group", PipelineConfigMother.pipelineConfig(PIPELINE_NAME, new MaterialConfigs(hgMaterial.config()))); config.addPipeline("group", PipelineConfigMother.pipelineConfig("pipeline2", new MaterialConfigs(hgMaterial.config()))); config.addPipeline("group", PipelineConfigMother.pipelineConfig("pipeline3")); serverHealthService.update(ServerHealthState.error("message", "description", HealthStateType.invalidConfig())); assertTrue((serverHealthService.logs().get(0)).getPipelineNames(config).isEmpty()); }
@Test public void faninErrorStateRelatedPipelineNames() { HgMaterial hgMaterial = MaterialsMother.hgMaterial(); CruiseConfig config = new BasicCruiseConfig(); config.addPipeline("group", PipelineConfigMother.pipelineConfig(PIPELINE_NAME, new MaterialConfigs(hgMaterial.config()))); config.addPipeline("group", PipelineConfigMother.pipelineConfig("pipeline2", new MaterialConfigs(hgMaterial.config()))); config.addPipeline("group", PipelineConfigMother.pipelineConfig("pipeline3")); serverHealthService.update(ServerHealthState.error("message", "description", HealthStateType.general(HealthStateScope.forFanin("pipeline2")))); Set<String> pipelines = (serverHealthService.logs().get(0)).getPipelineNames(config); assertEquals(Sets.newHashSet("pipeline2"), pipelines); } }
@Test public void materialStateRelatedPipelineNames() { HgMaterial hgMaterial = MaterialsMother.hgMaterial(); CruiseConfig config = new BasicCruiseConfig(); config.addPipeline("group", PipelineConfigMother.pipelineConfig(PIPELINE_NAME, new MaterialConfigs(hgMaterial.config()))); config.addPipeline("group", PipelineConfigMother.pipelineConfig("pipeline2", new MaterialConfigs(hgMaterial.config()))); config.addPipeline("group", PipelineConfigMother.pipelineConfig("pipeline3")); serverHealthService.update(ServerHealthState.error("message", "description", HealthStateType.general(forMaterial(hgMaterial)))); Set<String> pipelines = (serverHealthService.logs().get(0)).getPipelineNames(config); assertEquals(Sets.newHashSet("pipeline", "pipeline2"), pipelines); }