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

Set up file logging when shutting down the Jenkins test instance. #657

Merged
merged 5 commits into from
Sep 28, 2023

Conversation

Vlatombe
Copy link
Member

@Vlatombe Vlatombe commented Sep 21, 2023

Matching change to jenkinsci/jenkins#8513

This should help to identify race conditions during tests without causing too much noise as it only kicks in just before cleaning up the instance.

Testing done

Submitter checklist

This should help to identify race conditions
if (exception.getSuppressed().length > 0) {
throw exception;
}
}

private static final class TemporaryConsoleLogTweak implements AutoCloseable {
Copy link
Member

Choose a reason for hiding this comment

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

Why is this temporary, and how will we ensure that it does not become permanent?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is not meant to be temporary, I renamed the class to clarify the intent.

Copy link
Member

Choose a reason for hiding this comment

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

This is not meant to be temporary

What would its value be after we diagnose and fix the bug seen in https://github.com/jenkinsci/jenkins/pull/8511/checks?check_run_id=17000216956?

Copy link
Member Author

Choose a reason for hiding this comment

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

If there is no more race condition, I would fine removing it, but the thing is with this kind of issue is that it always pop up at an unexpected time and you often don't have enough data to investigate. On the other hand its impact is very light (under normal condition this adds one stacktrace writing queue.xml) since you wouldn't expect much xmlfile write being donc between stopping the test Jenkins instance and the cleanup sequence.

Copy link
Member

Choose a reason for hiding this comment

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

Fine with the merge of this PR if and only if it is reverted once its diagnostic value has been exhausted.

Clarify that this is not temporary, just applied within the block.
Copy link
Member

@jglick jglick left a comment

Choose a reason for hiding this comment

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

Looks helpful; has it be shown to work anywhere?

@Vlatombe
Copy link
Member Author

Looks helpful; has it be shown to work anywhere?

I tested this change locally against the test failing in https://github.com/jenkinsci/jenkins/pull/8511/checks?check_run_id=17000216956, it shows correctly the queue.xml being written just before cleanup, so I think it would be enough to show the race condition if it rehappens.

@jglick
Copy link
Member

jglick commented Sep 28, 2023

Ah so this is going to print

FINEST	hudson.XmlFile#write: Writing …/queue.xml
java.lang.Throwable
	at hudson.XmlFile.write(XmlFile.java:205)
	at hudson.model.Queue.save(Queue.java:472)
	at jenkins.model.Jenkins._cleanUpPersistQueue(Jenkins.java:3921)
	at jenkins.model.Jenkins.cleanUp(Jenkins.java:3676)
	at org.jvnet.hudson.test.JenkinsRule._stopJenkins(JenkinsRule.java:569)
	at org.jvnet.hudson.test.JenkinsRule.after(JenkinsRule.java:517)
	at org.jvnet.hudson.test.JenkinsRule$1.evaluate(JenkinsRule.java:665)

at the end of every test, which is not really desirable, since it is adding noise about a normal event. We would certainly want to know about writes after cleanUp. What this addition does not show is config.xml being written very late, which might be the issue according to the stack trace of the flake.

Copy link
Member

@jglick jglick left a comment

Choose a reason for hiding this comment

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

Might work. Hard to predict.

@Vlatombe
Copy link
Member Author

Might work. Hard to predict.

Yeah, at least this is not polluting every test log anymore.

@jglick
Copy link
Member

jglick commented Sep 28, 2023

I reran all of QuietDownCommandTest with this patch and did not see any XmlFile stack traces, so I think this is reasonable to merge as is, and we can hope it reveals something.

@jglick jglick merged commit ac531db into jenkinsci:master Sep 28, 2023
13 checks passed
@Vlatombe Vlatombe deleted the set-up-logging-on-stop branch September 28, 2023 13:14
@basil
Copy link
Member

basil commented Sep 28, 2023

#657 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants