Skip to content

Fix temporary offline state of computer is lost on config submit#26154

Merged
timja merged 1 commit intojenkinsci:masterfrom
mawinter69:issue-26146
Jan 23, 2026
Merged

Fix temporary offline state of computer is lost on config submit#26154
timja merged 1 commit intojenkinsci:masterfrom
mawinter69:issue-26146

Conversation

@mawinter69
Copy link
Contributor

@mawinter69 mawinter69 commented Jan 21, 2026

Fixes #26146

I suspect that #9855 is the cause for the issue.
I could reproduce the issue in version 2.492.3 so it exists since a while.

Root cause is that the config is based on the a Computer Object while the persistence is based on a Node object. Upon saving the configuration of a computer a new Node object is created based from the form fields but as the cause is not part of the form it is not persisted. Before #9855 the temporaryOfflineCcause was kept in the computer object directly, so a change in config didn't lead to a loss as the Computer object continues to live (might have caused a loss at restart though).
The fix is to set the cause after the new Node object is created before re-establishing the connection between computer and new Node object.

Testing done

  • Create a computer
  • set it to temporary offline
  • configure the computer (no change necessary) and save
  • computer is still set to temporary offline
  • restarted Jenkins and verified computer is still offline

Added a unit test that fails without the fix and succeeds with the fix

Screenshots (UI changes only)

Before

After

Proposed changelog entries

  • Fix temporary offline state of computer is lost on config submit

Proposed changelog category

/label bug,regression-fix

Proposed upgrade guidelines

N/A

Submitter checklist

  • The issue, if it exists, is well-described.
  • The changelog entries and upgrade guidelines are appropriate for the audience affected by the change (users or developers, depending on the change) and are in the imperative mood (see examples). Fill in the Proposed upgrade guidelines section only if there are breaking changes or changes that may require extra steps from users during upgrade.
  • There is automated testing or an explanation as to why this change has no tests.
  • New public classes, fields, and methods are annotated with @Restricted or have @since TODO Javadocs, as appropriate.
  • New deprecations are annotated with @Deprecated(since = "TODO") or @Deprecated(forRemoval = true, since = "TODO"), if applicable.
  • UI changes do not introduce regressions when enforcing the current default rules of Content Security Policy Plugin. In particular, new or substantially changed JavaScript is not defined inline and does not call eval to ease future introduction of Content Security Policy (CSP) directives (see documentation).
  • For dependency updates, there are links to external changelogs and, if possible, full differentials.
  • For new APIs and extension points, there is a link to at least one consumer.

Desired reviewers

@mention

Before the changes are marked as ready-for-merge:

Maintainer checklist

  • There are at least two (2) approvals for the pull request and no outstanding requests for change.
  • Conversations in the pull request are over, or it is explicit that a reviewer is not blocking the change.
  • Changelog entries in the pull request title and/or Proposed changelog entries are accurate, human-readable, and in the imperative mood.
  • Proper changelog labels are set so that the changelog can be generated automatically.
  • If the change needs additional upgrade steps from users, the upgrade-guide-needed label is set and there is a Proposed upgrade guidelines section in the pull request title (see example).
  • If it would make sense to backport the change to LTS, be a Bug or Improvement, and either the issue or pull request must be labeled as lts-candidate to be considered.

@comment-ops-bot comment-ops-bot bot added the bug For changelog: Minor bug. Will be listed after features label Jan 21, 2026
@comment-ops-bot comment-ops-bot bot added into-lts This PR is filed against an LTS branch regression-fix Pull request that fixes a regression in one of the previous Jenkins releases labels Jan 21, 2026
@mawinter69 mawinter69 marked this pull request as ready for review January 21, 2026 18:55
@MarkEWaite MarkEWaite removed the into-lts This PR is filed against an LTS branch label Jan 21, 2026
@MarkEWaite
Copy link
Contributor

MarkEWaite commented Jan 21, 2026

I've updated the label on the bug report to add lts-candidate and removed the into-lts label from this pull request. We use into-lts for pull requests that are targeting a backport branch (like stable-2.541).

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a bug where a computer's temporary offline state was lost when its configuration was submitted. The root cause was that configuration is based on a Computer object while persistence is based on a Node object - when saving configuration, a new Node object is created from form fields, but the temporary offline cause is not part of the form and was therefore lost.

Changes:

  • Preserve temporary offline cause during node reconfiguration by saving it before reconfiguration and restoring it to the new node
  • Add unit test to verify temporary offline cause persists through configuration roundtrip

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
core/src/main/java/hudson/model/Computer.java Added code to preserve and restore the temporary offline cause when reconfiguring a node
test/src/test/java/hudson/model/ComputerTest.java Added test case to verify temporary offline cause is preserved through configuration roundtrip

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@MarkEWaite MarkEWaite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is now ready for merge. We will merge it after approximately 24 hours if there is no negative feedback.

/label ready-for-merge

@comment-ops-bot comment-ops-bot bot added the ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback label Jan 22, 2026
@timja
Copy link
Member

timja commented Jan 22, 2026

I assume it also fixes jenkinsci/configuration-as-code-plugin#2682 ?

@mawinter69
Copy link
Contributor Author

likely

@timja timja merged commit 620b902 into jenkinsci:master Jan 23, 2026
25 checks passed
shalinisudarsan pushed a commit to shalinisudarsan/jenkins that referenced this pull request Jan 29, 2026
shalinisudarsan pushed a commit to shalinisudarsan/jenkins that referenced this pull request Jan 29, 2026
shalinisudarsan pushed a commit to shalinisudarsan/jenkins that referenced this pull request Jan 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug For changelog: Minor bug. Will be listed after features ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback regression-fix Pull request that fixes a regression in one of the previous Jenkins releases

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Offline nodes become online after config save or reload

5 participants