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

Logging improvements to Run related classes #8777

Merged
merged 1 commit into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions core/src/main/java/hudson/model/Run.java
Original file line number Diff line number Diff line change
Expand Up @@ -2480,10 +2480,12 @@
}
Jenkins j = Jenkins.getInstanceOrNull();
if (j == null) {
LOGGER.fine(() -> "Jenkins not running");
return null;
}
Job<?, ?> job = j.getItemByFullName(jobName, Job.class);
if (job == null) {
LOGGER.fine(() -> "no such job " + jobName + " when running as " + Jenkins.getAuthentication2().getName());

Check warning on line 2488 in core/src/main/java/hudson/model/Run.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 2483-2488 are not covered by tests
Copy link
Member

Choose a reason for hiding this comment

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

👍 common issue when using unexpected threads

Copy link
Member

Choose a reason for hiding this comment

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

(could also/instead log from whatever code returns null when principal lacks READ)

return null;
}
return job.getBuildByNumber(number);
Expand Down
1 change: 1 addition & 0 deletions core/src/main/java/hudson/model/RunMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ protected R retrieve(File d) throws IOException {
LOGGER.log(Level.WARNING, "could not load " + d, e);
}
}
LOGGER.fine(() -> "no config.xml in " + d);
return null;
}

Expand Down
15 changes: 12 additions & 3 deletions core/src/main/java/jenkins/model/lazy/AbstractLazyLoadRunMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -518,15 +518,21 @@
Index snapshot = index;
if (snapshot.byNumber.containsKey(n)) {
BuildReference<R> ref = snapshot.byNumber.get(n);
if (ref == null) return null; // known failure
if (ref == null) {

Check warning on line 521 in core/src/main/java/jenkins/model/lazy/AbstractLazyLoadRunMap.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 521 is only partially covered, one branch is missing
LOGGER.fine(() -> "known failure of #" + n + " in " + dir);
return null;

Check warning on line 523 in core/src/main/java/jenkins/model/lazy/AbstractLazyLoadRunMap.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 522-523 are not covered by tests
}
R v = unwrap(ref);
if (v != null) return v; // already in memory
if (v != null) {
return v; // already in memory
}
// otherwise fall through to load
}
synchronized (this) {
if (index.byNumber.containsKey(n)) { // JENKINS-22767: recheck inside lock
BuildReference<R> ref = index.byNumber.get(n);
if (ref == null) {
LOGGER.fine(() -> "known failure of #" + n + " in " + dir);

Check warning on line 535 in core/src/main/java/jenkins/model/lazy/AbstractLazyLoadRunMap.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 535 is not covered by tests
return null;
}
R v = unwrap(ref);
Expand Down Expand Up @@ -655,7 +661,10 @@
assert Thread.holdsLock(this);
try {
R r = retrieve(dataDir);
if (r == null) return null;
if (r == null) {
LOGGER.fine(() -> "nothing in " + dataDir);
return null;
}

Index copy = editInPlace != null ? editInPlace : new Index(index);

Expand Down
Loading