-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
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
[JENKINS-30101][JENKINS-30175] Simplify persistence design for temporarily offline status #9855
Conversation
There were complex code to synchronize transient state of Computer from Node. But since any temporarily offline cause is being set by a user and should be persisted in a node, the Computer should actually delegate to Node instead of trying to synchronize it
getNodeOrDie().setTemporaryOfflineCause(temporarilyOfflineCause); | ||
if (temporarilyOfflineCause != null) { | ||
Listeners.notify(ComputerListener.class, false, l -> l.onTemporarilyOffline(this, temporarilyOfflineCause)); | ||
} else { | ||
Listeners.notify(ComputerListener.class, false, l -> l.onTemporarilyOnline(this)); | ||
} |
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.
The field offlineCause
is only for technical offline cause now. temporarilyOfflineCause
only exists in Node
now.
var temporaryOfflineCause = getNodeOrDie().getTemporaryOfflineCause(); | ||
return temporaryOfflineCause == null ? offlineCause : temporaryOfflineCause; |
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.
Retaining previous behaviour : if a temporary offline cause is defined, from outside PoV, it replaces the technical offline cause.
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.
getNodeOrDie
is probably wrong. Otherwise looks good.
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.
Just a nit in isOffline
.
Co-authored-by: Jesse Glick <jglick@cloudbees.com>
I think this will solve several issues that I also addressed in #6152. |
I think you will also need to adjust |
Retain the original message for setting the node temporary offline
Looks like a separate change impacting UX. |
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.
LGTM
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.
Previously setting an agent temporarily offline also set the offline cause itself.
With this change once you set the agent temporarily offline it is not possible to get the offline cause that might have been set when disconnecting the agent after it was set temp offline.
Not sure if this will have implications for plugins.
getOfflineCauseReason
will return an empty string now if an agent is only temp offline. This will break these tests I think:
https://github.com/jenkinsci/node-sharing-plugin/blob/ae54615d1213196f3ca91073caf7c2850758e85a/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/SharedNodeCloudTest.java#L531
https://github.com/jenkinsci/openstack-cloud-plugin/blob/fc5384db4d5f1f4f2ebdec2aec7e28ce312cf0df/plugin/src/test/java/jenkins/plugins/openstack/compute/SingleUseSlaveTest.java#L137
Maybe also tests in https://github.com/jenkinsci/java-client-api and others
@mawinter69 Addressed your remark |
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.
OK I think. Seems worth running tests of the plugins mentioned.
* Use {@link #setTemporaryOfflineCause(OfflineCause)} instead. | ||
*/ | ||
@Deprecated | ||
public void setTemporarilyOffline(boolean temporarilyOffline, OfflineCause cause) { |
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.
The javadoc is lost here especially that the second argument is only considered when the first is true. But maybe this doesn't matter as the method is now set to deprecated.
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.
Yes, I'm dropping existing javadoc to avoid repeats, and only refer to the current methods.
/label ready-for-merge This PR is now ready for merge, after ~24 hours, we will merge it if there's no negative feedback. Thanks! |
Can we mark this as fix for |
Keeping JENKINS-50313 out, since this PR doesn't cover showing both offline causes. |
@Vlatombe is there anything that we can do from Jenkins core to resolve the change in behavior that has been seen in the OpenStack cloud plugin or is a change needed in the plugin? |
The Filed jenkinsci/openstack-cloud-plugin#385, compatibility is retained when using the getter. |
There were complex code to synchronize transient state of
Computer
fromNode
and vice versa.But since any temporarily offline cause is being set by a user and should be persisted in a
Node
, theComputer
should actually delegate toNode
instead of trying to synchronize its state.Fixes JENKINS-30101 and JENKINS-30175
Testing done
Proposed changelog entries
Proposed upgrade guidelines
N/A
Submitter checklist
Desired reviewers
@mention
Before the changes are marked as
ready-for-merge
:Maintainer checklist