Skip to content

Commit

Permalink
Merge pull request #70 from Dohbedoh/JENKINS-69927
Browse files Browse the repository at this point in the history
[JENKINS-69927] Display only one monitor instead of duplicates when i…
  • Loading branch information
jtnord authored Oct 24, 2022
2 parents c51bc08 + b9926c9 commit 3087448
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,15 @@ public void startWatchingForSecrets() {
if (reconnectClientOnException) {
reconnectLater();
}
// Only report the latest failure
clearAdminMonitors(initAdminMonitorId);
new AdministrativeError(initAdminMonitorId,
"Failed to initialize Kubernetes secret provider",
"Credentials from Kubernetes Secrets will not be available.", kex);
} catch (LabelSelectorParseException lex) {
LOG.log(Level.SEVERE, "Failed to initialise k8s secret provider, secrets from Kubernetes will not be available", lex);
// Only report the latest failure
clearAdminMonitors(labelSelectorAdminMonitorId);
new AdministrativeError(labelSelectorAdminMonitorId,
"Failed to parse Kubernetes secret label selector",
"Failed to parse Kubernetes secret <a href=\"https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors\" _target=\"blank\">label selector</a> " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,16 @@ public void startWatchingForSecretsKubernetesClientException() throws IOExceptio
KubernetesCredentialProvider provider = new MockedKubernetesCredentialProvider();
provider.startWatchingForSecrets();
assertEquals("expect administrative error", 1, getInitAdministrativeMonitorCount());
provider.startWatchingForSecrets();
assertEquals("expect at most 1 administrative error", 1, getInitAdministrativeMonitorCount());

// enable default responses
defaultMockKubernetesResponses();
// restart with success should clear errors
provider.startWatchingForSecrets();
// verify we schedule reconnect task
ArgumentCaptor<Runnable> reconnectTask = ArgumentCaptor.forClass(Runnable.class);
verify(jenkinsTimer).schedule(reconnectTask.capture(), eq(5L), eq(TimeUnit.MINUTES));
verify(jenkinsTimer, times(2)).schedule(reconnectTask.capture(), eq(5L), eq(TimeUnit.MINUTES));
reconnectTask.getValue().run();
assertEquals("expect administrative error to be cleared", 0, getInitAdministrativeMonitorCount());
}
Expand Down

0 comments on commit 3087448

Please sign in to comment.