-
Notifications
You must be signed in to change notification settings - Fork 68
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
Make the Shredder ignore empty lines #1088
Conversation
In the mean time you might be able to skip using |
I said might ;) I am not the main developer of the shredders, but I thought we had some code in there that would at least catch this, but I could be wrong... I also might have been thinking of an incident we had where I had to fix old files that had this issue... https://github.com/ubccr/xdmod/blob/xdmod8.5/tools/dev/format-slurm/ |
classes/OpenXdmod/Shredder.php
Outdated
} else { | ||
throw $e; | ||
// Skip empty lines | ||
if ($line !== '') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the line is skipped then the record count should not be updated.
classes/OpenXdmod/Shredder.php
Outdated
try { | ||
$this->shredLine($line); | ||
} catch (PDOException $e) { | ||
|
||
// Ignore duplicate key errors. | ||
if ($e->getCode() == 23000) { | ||
$msg = 'Skipping duplicate data: ' . $e->getMessage(); | ||
$this->logger->debug(array( | ||
'message' => $msg, | ||
'file' => $file, | ||
'line_number' => $lineNumber, | ||
'line' => $line, | ||
)); | ||
$duplicateCount++; | ||
continue; | ||
} else { | ||
throw $e; | ||
// Skip empty lines | ||
if ($line !== '') { | ||
|
||
try { | ||
$this->shredLine($line); | ||
} catch (PDOException $e) { | ||
|
||
// Ignore duplicate key errors. | ||
if ($e->getCode() == 23000) { | ||
$msg = 'Skipping duplicate data: ' . $e->getMessage(); | ||
$this->logger->debug(array( | ||
'message' => $msg, | ||
'file' => $file, | ||
'line_number' => $lineNumber, | ||
'line' => $line, | ||
)); | ||
$duplicateCount++; | ||
continue; | ||
} else { | ||
throw $e; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd also like to see some debug logging in this change. You can also simplify the change and address @jpwhite4 's comment with something like this:
- $recordCount++;
+ if ($line === '') {
+ $this->logger->debug([
+ 'message' => 'Skipping blank line',
+ 'file' => $file,
+ 'line_number' => $lineNumber
+ ));
+ continue;
+ }
+
+ $recordCount++;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes, good suggestions! Let me try this.
switched back to the 8.5 branch so tests can hopefully pass since we dont have the new branch completely upgraded |
Well, thinking about it a little more, this will only solve the case where the job name contains
the job name will be split over 2 lines in the So I guess special characters should be escaped earlier, directly at the |
When the job accounting file contains empty lines, the shredder fails.
xdmod-slurm-helper
fails when a job name contains a carriage-return character. The generatedsacct
output contains a blank line that makesxdmod-slurm-helper
fail.Here's an example:
Note how the job name sends the last pipe delimiter to the next line. Because of this, the temporary file that
sacct
output is sent to contains a blank line. Andxdmod-slurm-helper
fails with the following error:Description
Check that the line is not empty before processing it. Skip empty lines
Motivation and Context
https://help.xdmod.org/support/tickets/22127
Tests performed
Run
xdmod-slurm-helper
on job records with job names containing carriage returns. The job records are correctly processed.Types of changes
Checklist: