-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Capture pod events just before deleting the agent #946
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
214b5b3
Capture pod events just before deleting the agent
Vlatombe 84bc342
Fixup tests, organize imports
Vlatombe 6cbb60a
Apply suggestions from code review
Vlatombe 7343fa6
Add missing import
Vlatombe 254d6ae
Relax the test a bit
Vlatombe 61a655b
Use a single container
Vlatombe e768019
Merge branch 'master' into print-events-on-timeout
Vlatombe 41c3bda
Merge branch 'master' into print-events-on-timeout
Vlatombe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesEventsException.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| package org.csanchez.jenkins.plugins.kubernetes; | ||
|
|
||
| import io.fabric8.kubernetes.api.model.Event; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| /** | ||
| * Prints | ||
| */ | ||
| public class KubernetesEventsException extends Exception { | ||
| public KubernetesEventsException(List<Event> events) { | ||
| super(toMessage(events)); | ||
| } | ||
|
|
||
| private static String toMessage(List<Event> events) { | ||
| StringBuilder sb = new StringBuilder("Events follow:\n"); | ||
| for (Event event : events) { | ||
| String[] lines = event.getMessage().split("\n"); | ||
| for (String line : lines) { | ||
| sb.append(String.format("[%s][%s/%s][%s] %s%n", event.getType(), event.getInvolvedObject().getNamespace(), event.getInvolvedObject().getName(), event.getReason(), line)); | ||
| } | ||
| } | ||
| return sb.toString(); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/podEventsPrinted.groovy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| podTemplate(slaveConnectTimeout:10, yaml:''' | ||
| spec: | ||
| containers: | ||
| - name: neverready | ||
| image: busybox | ||
| command: ['sleep', '99999999'] | ||
| readinessProbe: | ||
| exec: | ||
| command: | ||
| - cat | ||
| - /tmp/healthy | ||
| initialDelaySeconds: 5 | ||
| periodSeconds: 5 | ||
| ''') { | ||
| node(POD_LABEL) { | ||
| sh 'true' | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.