diff --git a/changes/add_inhibit_on_workflow_run_id_alert.md b/changes/add_inhibit_on_workflow_run_id_alert.md new file mode 100644 index 00000000..986b3f42 --- /dev/null +++ b/changes/add_inhibit_on_workflow_run_id_alert.md @@ -0,0 +1 @@ +Inhibit workflow run launch if AutoInhibit alert contains workflow run ID in its job or scope diff --git a/vidarr-prometheus/README.md b/vidarr-prometheus/README.md index 2fd2c097..b0fdacc0 100644 --- a/vidarr-prometheus/README.md +++ b/vidarr-prometheus/README.md @@ -52,8 +52,8 @@ Alertmanager times out. workflow run inhibition. `"valuesOfInterest"` is the set of label values that will be assessed for -workflow run inhibition. Internally, the _workflow name_ and _workflow name and version_* -are added to this list of values of interest. +workflow run inhibition. Internally, the _workflow name_ and _workflow name and version_*, +and _workflow run ID_ are added to this list of values of interest. ### Workflow run inhibition In order for a match and a workflow run inhibition to occur, the alert must @@ -63,10 +63,11 @@ have the following: * one or more of the labels in `` whose value is: * one of the ``; or * _workflow name_; or - * _workflow name and version_* + * _workflow name and version_* ; or + * _workflow run ID_ *(formatted like _bcl2fastq_3_2_0_, where any periods in the version are converted to underscores) The workflow run inhibition will last as long as the AutoInhibit alert is -firing. \ No newline at end of file +firing. diff --git a/vidarr-prometheus/src/main/java/ca/on/oicr/gsi/vidarr/prometheus/AlertmanagerAutoInhibitConsumableResource.java b/vidarr-prometheus/src/main/java/ca/on/oicr/gsi/vidarr/prometheus/AlertmanagerAutoInhibitConsumableResource.java index 5d556d4c..05c2e990 100644 --- a/vidarr-prometheus/src/main/java/ca/on/oicr/gsi/vidarr/prometheus/AlertmanagerAutoInhibitConsumableResource.java +++ b/vidarr-prometheus/src/main/java/ca/on/oicr/gsi/vidarr/prometheus/AlertmanagerAutoInhibitConsumableResource.java @@ -147,6 +147,7 @@ public ConsumableResourceResponse request( Stream.of( valuesOfInterest.stream(), Stream.of(workflowName), + Stream.of(vidarrId), Stream.of( String.format( "%s_%s", workflowName, workflowVersionWithUnderscores))) diff --git a/vidarr-prometheus/src/test/java/ca.on.oicr.gsi.vidarr.prometheus/AlertDtoTest.java b/vidarr-prometheus/src/test/java/ca.on.oicr.gsi.vidarr.prometheus/AlertDtoTest.java index 4113de3c..cbd34b2c 100644 --- a/vidarr-prometheus/src/test/java/ca.on.oicr.gsi.vidarr.prometheus/AlertDtoTest.java +++ b/vidarr-prometheus/src/test/java/ca.on.oicr.gsi.vidarr.prometheus/AlertDtoTest.java @@ -27,7 +27,7 @@ public void whenEnvAndJobMatch_matchesShouldMatch() { var matches = sut.matches(autoInhibit, "testing", configLabels, Stream.of("vidarr-clinical", "bamqc4")) - .collect(Collectors.toList()); + .toList(); assertEquals(1, matches.size()); } @@ -44,7 +44,7 @@ public void whenEnvAndWorkflowMatch_matchesShouldMatch() { var matches = sut.matches(autoInhibit, "testing", configLabels, Stream.of("vidarr-clinical", "bamqc4")) - .collect(Collectors.toList()); + .toList(); assertEquals(1, matches.size()); } @@ -61,7 +61,7 @@ public void whenEnvAndScopeMatch_matchesShouldMatch() { var matches = sut.matches(autoInhibit, "testing", configLabels, Stream.of("vidarr-clinical", "bamqc4")) - .collect(Collectors.toList()); + .toList(); assertEquals(1, matches.size()); } @@ -78,7 +78,7 @@ public void whenEnvDoesNotMatch_matchesShouldNotMatch() { var matches = sut.matches(autoInhibit, "testing", configLabels, Stream.of("vidarr-clinical", "bamqc4")) - .collect(Collectors.toList()); + .toList(); assertEquals(0, matches.size()); } @@ -95,7 +95,24 @@ public void whenAlertnameDoesNotMatch_matchesShouldNotMatch() { var matches = sut.matches(autoInhibit, "testing", configLabels, Stream.of("vidarr-clinical", "bamqc4")) - .collect(Collectors.toList()); + .toList(); assertEquals(0, matches.size()); } + + @Test + public void whenAlertScopeIsWorkflowRunId_matchesShouldMatch() { + AlertDto sut = new AlertDto(); + + ObjectNode labels = mapper.createObjectNode(); + labels.put("environment", "testing"); + labels.put("job", "bamqc4"); + labels.put("scope", "615ed228fad3ae6193d5279dc689e83fa4225cd69c929e266dd84ef2ed96e719"); + labels.put("alertname", "AutoInhibit"); + sut.setLabels(labels); + + var matches = + sut.matches(autoInhibit, "testing", configLabels, Stream.of("vidarr-clinical", "615ed228fad3ae6193d5279dc689e83fa4225cd69c929e266dd84ef2ed96e719")) + .toList(); + assertEquals(1, matches.size()); + } }