Skip to content

Commit

Permalink
Merge pull request #42576 from Dr15Jones/fjrTempError_13_0
Browse files Browse the repository at this point in the history
Add temporary failure element to Framework Job Report [13_0]
  • Loading branch information
cmsbuild authored Aug 16, 2023
2 parents 3e4730a + dddfd09 commit 6f67be2
Show file tree
Hide file tree
Showing 19 changed files with 45 additions and 2 deletions.
1 change: 1 addition & 0 deletions FWCore/MessageLogger/interface/JobReport.h
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@ namespace edm {
void temporarilyCloseXML();
edm::propagate_const<std::unique_ptr<JobReportImpl>> impl_;
std::mutex write_mutex;
bool errorLogged_ = false;
};

std::ostream& operator<<(std::ostream& os, JobReport::InputFile const& f);
Expand Down
28 changes: 26 additions & 2 deletions FWCore/MessageLogger/src/JobReport.cc
Original file line number Diff line number Diff line change
Expand Up @@ -302,18 +302,41 @@ namespace edm {
}
}

static constexpr std::string_view kJobReportEndElement = "</FrameworkJobReport>\n";
static constexpr int kMinSizeOfComment = 8;

JobReport::~JobReport() {
impl_->flushFiles();
if (impl_->ost_) {
*(impl_->ost_) << "</FrameworkJobReport>\n" << std::flush;
//are we actually at the end of the file?
auto pos = impl_->ost_->tellp();
impl_->ost_->seekp(0, std::ios_base::end);
auto endpos = impl_->ost_->tellp();
impl_->ost_->seekp(pos);
if ((endpos - pos) > static_cast<long int>(kJobReportEndElement.size())) {
//need to add some padding so use a comment element
// comment is used since white spaces are converted to a special node
// while comments are usually ignored by xml parsers
auto padding = (endpos - pos) - (kJobReportEndElement.size() + kMinSizeOfComment);
*(impl_->ost_) << "<!--";
for (int i = padding; i > 0; --i) {
(*impl_->ost_) << ' ';
}
*(impl_->ost_) << "-->\n";
}
*(impl_->ost_) << kJobReportEndElement << std::flush;
}
}

void JobReport::temporarilyCloseXML() {
if (impl_->ost_) {
//remember where we were
auto pos = impl_->ost_->tellp();
*(impl_->ost_) << "</FrameworkJobReport>\n" << std::flush;
if (not errorLogged_) {
*(impl_->ost_) << "<FrameworkError ExitStatus=\"8901\" Type=\"UnexpectedJobTermination\"/>\n";
}
*(impl_->ost_) << kJobReportEndElement << std::flush;

//overwrite above during next write.
impl_->ost_->seekp(pos);
}
Expand Down Expand Up @@ -507,6 +530,7 @@ namespace edm {
if (impl_->ost_) {
{
std::lock_guard<std::mutex> lock(write_mutex);
errorLogged_ = true;
std::ostream& msg = *(impl_->ost_);
msg << "<FrameworkError ExitStatus=\"" << exitCode << "\" Type=\"" << shortDesc << "\" >\n";
msg << "<![CDATA[\n" << longDesc << "\n]]>\n";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@

<GeneratorInfo>
</GeneratorInfo>
<!-- -->
</FrameworkJobReport>
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
<FrameworkJobReport>
<!-- -->
</FrameworkJobReport>
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
<FrameworkJobReport>
<!-- -->
</FrameworkJobReport>
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
<FrameworkJobReport>
<!-- -->
</FrameworkJobReport>
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
<FrameworkJobReport>
<!-- -->
</FrameworkJobReport>
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
<FrameworkJobReport>
<!-- -->
</FrameworkJobReport>
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
<FrameworkJobReport>
<!-- -->
</FrameworkJobReport>
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
<FrameworkJobReport>
<!-- -->
</FrameworkJobReport>
1 change: 1 addition & 0 deletions FWCore/MessageService/test/unit_test_outputs/u27FJR.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
<LogSystem_LogAbsolute Value="0" />
<LogWarnng_LogPrint Value="0" />
</MessageSummary>
<!-- -->
</FrameworkJobReport>
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
<FrameworkJobReport>
<!-- -->
</FrameworkJobReport>
2 changes: 2 additions & 0 deletions FWCore/Utilities/interface/EDMException.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ namespace edm {

EventGenerationFailure = 8501,

UnexpectedJobTermination = 8901,

CaughtSignal = 9000
};

Expand Down
1 change: 1 addition & 0 deletions FWCore/Utilities/src/EDMException.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ namespace edm {
FILLENTRY(UnavailableAccelerator),
FILLENTRY(ExternalFailure),
FILLENTRY(EventGenerationFailure),
FILLENTRY(UnexpectedJobTermination),
FILLENTRY(CaughtSignal)};
static const std::string kUnknownCode("unknownCode");
} // namespace errors
Expand Down
1 change: 1 addition & 0 deletions IOPool/Common/test/proper_RLfjr_output
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,5 @@
<ReadBranches>
</ReadBranches>

<!-- -->
</FrameworkJobReport>
1 change: 1 addition & 0 deletions IOPool/Common/test/proper_Rfjr_output
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,5 @@
<ReadBranches>
</ReadBranches>

<!-- -->
</FrameworkJobReport>
1 change: 1 addition & 0 deletions IOPool/Common/test/proper_fjr_output
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,5 @@
<Branch Name="edmtestThings_Thing__TESTPROD." ReadCount="35"/>
</ReadBranches>

<!-- -->
</FrameworkJobReport>
1 change: 1 addition & 0 deletions IOPool/Common/test/proper_fjrx_output
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,5 @@
<Branch Name="edmtestThings_Thing__TESTPROD." ReadCount="35"/>
</ReadBranches>

<!-- -->
</FrameworkJobReport>
1 change: 1 addition & 0 deletions IOPool/Common/test/proper_fjrx_second_output
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,5 @@
</Input>
</Inputs>
</File>
<!-- -->
</FrameworkJobReport>

0 comments on commit 6f67be2

Please sign in to comment.