Skip to content
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-57273] Jenkins/Nodes.addNode could replace an existing node, but always fired onCreated #4004

Merged
merged 1 commit into from
May 3, 2019

Conversation

jglick
Copy link
Member

@jglick jglick commented Apr 30, 2019

JENKINS-57273

Buglet I noticed while working on something else.

Proposed changelog entries

  • NodeListener.onCreated was called when Jenkins.addNode or Nodes.addNode actually replaced an existing node.

@@ -210,6 +215,7 @@ public Boolean call() throws Exception {
if (exists) {
// TODO there is a theoretical race whereby the node instance is updated/removed after lock release
persistNode(node);
// TODO should this fireOnUpdated?
Copy link
Member

Choose a reason for hiding this comment

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

It looks like the only use of this method in core is via Node.save, and even in other cases, since old and new would be the same object, it seems a bit weird to call fireOnUpdated. That said, the only NodeListener I could find that even uses NodeListener.onUpdated is in audit-log, so it's hard to say how the event is used in practice or if the change would be problematic.

Copy link
Member Author

Choose a reason for hiding this comment

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

OK. Feel free to suggest an update to the comment with your research.

@@ -131,10 +131,11 @@ public void addNode(final @Nonnull Node node) throws IOException {
if (node != oldNode) {
// TODO we should not need to lock the queue for adding nodes but until we have a way to update the
// computer list for just the new node
AtomicReference<Node> old = new AtomicReference<>();
Copy link
Member

Choose a reason for hiding this comment

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

AIUI you are introducing this variable because oldNode is obtained without a lock and so might not be the actual node that we end up replacing. If so, then I think on line 152 oldNode should be replaced with old.get() for the same reason (although that could still be incorrect as mentioned on line 143).

Copy link
Member Author

Choose a reason for hiding this comment

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

AIUI you are introducing this variable because oldNode is obtained without a lock and so might not be the actual node that we end up replacing.

Not as such, I just needed a writable cell to stash the result of put, and the Queue.withLock overrides take closures rather than the AutoCloseable trick so I could not just use a blank final variable.

on line 152 oldNode should be replaced with old.get() for the same reason

Perhaps. That would be a different change though. This PR is merely fixing the notification.

@oleg-nenashev oleg-nenashev added the needs-jira-issue A JIRA issue should be created for this PR. It is usually needed for the LTS backporting process label May 1, 2019
Copy link
Member

@oleg-nenashev oleg-nenashev left a comment

Choose a reason for hiding this comment

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

Needs a new JIRA issue IMO

@jglick jglick changed the title Jenkins/Nodes.addNode could replace an existing node, but always fired onCreated [JENKINS-57273] Jenkins/Nodes.addNode could replace an existing node, but always fired onCreated May 1, 2019
@jglick jglick removed the needs-jira-issue A JIRA issue should be created for this PR. It is usually needed for the LTS backporting process label May 1, 2019
@jglick jglick added the ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback label May 2, 2019
@oleg-nenashev
Copy link
Member

Will merge tomorrow if there is no negative feedback

@oleg-nenashev oleg-nenashev merged commit 45573ce into jenkinsci:master May 3, 2019
@jglick jglick deleted the NodeListener branch May 3, 2019 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants