Skip to content

Return result code when process is stopping [M147]#824

Merged
jrbriggs merged 1 commit into
microsoft:releases/shippedfrom
jeschu1:NullFix
Feb 21, 2019
Merged

Return result code when process is stopping [M147]#824
jrbriggs merged 1 commit into
microsoft:releases/shippedfrom
jeschu1:NullFix

Conversation

@jeschu1
Copy link
Copy Markdown
Member

@jeschu1 jeschu1 commented Feb 21, 2019

Return result code instead of null, fixing a null reference

There will be a further change (not needed for this release) to better log / audit return codes consistently across maintenance jobs.

@jeschu1 jeschu1 changed the title Return result code when process is stopping Return result code when process is stopping [M147] Feb 21, 2019
public bool ExitCodeIsFailure
{
get { return !this.ExitCodeIsSuccess; }
get { return !this.ExitCodeIsSuccess && this.ExitCode != ExitDueToShutDownCode; }
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why isn't ExitDueToShutDownCode considered a failure?

Copy link
Copy Markdown
Member

@wilbaker wilbaker Feb 21, 2019

Choose a reason for hiding this comment

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

To add more context, my concern is that callers might think that the git command has succeeded when it hasn't and then react incorrectly.

Did you check how callers are treating ExitCodeIsFailure?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We were looking at the code in PackfileMaintenanceStep where it would log "multi-pack-index is corrupt after write. Deleting and rewriting." on a failure. Which was not the case if we never even invoked git to run.

if (this.Stopping)
{
	this.Context.Tracer.RelatedWarning(
		metadata: null,
		message: this.Area + ": Not launching Git process because the mount is stopping",
		keywords: Keywords.Telemetry);
	return null;
}

GitProcess.Result result = work.Invoke(this.GitProcess);

So it seems that this exit code is not a failure of git but an explicit choice or not running the git command. I understand your concern about assuming success and we should audit where this is checked to make sure. But we also have the ExitCodeIsSuccess which if we really care about it succeeding should be checking that. I would be good to know if we have discrepancies in our logic though.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Exactly what @kewillford said :-)

Further that the only place we have a result of ExitDueToShutDownCode is in MaintenanceJobs and there we'd only want to log if we have a failure. We already log (as shown above) when the process isn't launced due to stopping.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@kewillford good point thanks!

@jeschu1 and I discussed this offline and agreed that the changes in this PR are good to go into releases/shipped, but that we'll want to take some time to see if there is a better solution before merging to master.

One specific concern we discussed was that ExitDueToShutDownCode is a GitMaintenanceStep specific type of result, and so it probably should not be added to GitProcess.Result (which is used in lots of places, not just in GitMaintenanceStep).

@jrbriggs jrbriggs added this to the M147 milestone Feb 21, 2019
@jrbriggs jrbriggs merged commit 445f1f3 into microsoft:releases/shipped Feb 21, 2019
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