-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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
Display appropriate GUI that accurately displays offline by design #9883
Merged
timja
merged 3 commits into
jenkinsci:master
from
Vlatombe:computer-icon-depends-on-offline-cause
Oct 23, 2024
Merged
Changes from 2 commits
Commits
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
This file contains 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 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 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 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,108 @@ | ||
/* | ||
* The MIT License | ||
* | ||
* Copyright 2024 CloudBees, Inc. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
package jenkins.agents; | ||
|
||
import edu.umd.cs.findbugs.annotations.NonNull; | ||
import hudson.Util; | ||
import java.util.Date; | ||
import java.util.Objects; | ||
import jenkins.model.IComputer; | ||
|
||
/** | ||
* Represents a cause that puts a {@linkplain IComputer#isOffline() computer offline}. | ||
* @since TODO | ||
*/ | ||
public interface IOfflineCause { | ||
/** | ||
* @return The icon to use for the computer that has this offline cause. It will be displayed in the build executor status widget, as well as in nodes list screen. | ||
*/ | ||
@NonNull | ||
default String getComputerIcon() { | ||
return "symbol-computer-offline"; | ||
} | ||
|
||
/** | ||
* @return The alt text for the icon returned by {@link #getComputerIcon()}. | ||
*/ | ||
@NonNull | ||
default String getComputerIconAltText() { | ||
return "[offline]"; | ||
} | ||
|
||
/** | ||
* @return The icon to render this offline cause. It will be displayed in the build executor status widget. | ||
*/ | ||
@NonNull | ||
default String getIcon() { | ||
return "symbol-error"; | ||
} | ||
|
||
/** | ||
* @return The reason why this offline cause exists. | ||
* <p> | ||
* For implementers: this can use HTML formatting, so make sure to only include trusted content. | ||
*/ | ||
@NonNull | ||
default String getReason() { | ||
// fetch the localized string for "Disconnected By" | ||
String gsub_base = hudson.slaves.Messages.SlaveComputer_DisconnectedBy("", ""); | ||
// regex to remove commented reason base string | ||
String gsub1 = "^" + gsub_base + "[\\w\\W]* \\: "; | ||
// regex to remove non-commented reason base string | ||
String gsub2 = "^" + gsub_base + "[\\w\\W]*"; | ||
return Objects.requireNonNull(Util.escape(toString().replaceAll(gsub1, "").replaceAll(gsub2, ""))); | ||
} | ||
|
||
/** | ||
* @return A short message (one word) that summarizes the offline cause. | ||
* | ||
* <p> | ||
* For implementers: this can use HTML formatting, so make sure to only include trusted content. | ||
*/ | ||
@NonNull | ||
default String getMessage() { | ||
return Messages.IOfflineCause_offline(); | ||
} | ||
|
||
/** | ||
* @return the CSS class name that should be used to render the status. | ||
*/ | ||
@SuppressWarnings("unused") // jelly | ||
default String getStatusClass() { | ||
return "warning"; | ||
} | ||
|
||
/** | ||
* Timestamp in which the event happened. | ||
*/ | ||
long getTimestamp(); | ||
|
||
/** | ||
* Same as {@link #getTimestamp()} but in a different type. | ||
*/ | ||
@NonNull | ||
default Date getTime() { | ||
return new Date(getTimestamp()); | ||
} | ||
} |
This file contains 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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this wasn't shown before and now is I'd suggest changing the text from
computer
toagent
Offline because computer was idle
doesn't make sense as a computer isn't user facing terminology, (not mentioned in https://www.jenkins.io/doc/book/glossary/), it should be agent instead.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was already shown before, just not before the agent was online, then became offline again as instructed by the retention strategy.