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

fix for empty output from git-plan command #50

Merged
merged 3 commits into from
Sep 28, 2020
Merged

Conversation

jweibel22
Copy link
Contributor

We're seeing a sporadic issue when building projects with shuttle plans. Occasionally the tag of the docker image has an empty shuttlePlanHash (so the image tag would end up something like "master-e71d796c6e-")

This happens because the planHash() function in the shuttle.groovy file returns empty output. The function generates that output using './shuttle --skip-pull git-plan rev-parse HEAD'.

When looking at the source code of RunGitPlanCommand it looks like it might suffer from a race condition and exit prematurely before printing the output.

I had a look at the streaming example from https://github.com/go-cmd/cmd/blob/master/examples/blocking-streaming/main.go and basically copy-pasted that.

@jweibel22 jweibel22 changed the title Ensure that we're done reading output before exiting fix for empty output from git-plan command Sep 17, 2020
@jweibel22
Copy link
Contributor Author

I have no idea why the build is failing

@Crevil
Copy link
Member

Crevil commented Sep 17, 2020

Sweet 🙌 I’ll look into the build 👍

@jweibel22 jweibel22 marked this pull request as draft September 17, 2020 17:04
@jweibel22
Copy link
Contributor Author

this still needs a bit of love :-)
looks like it blocks forever because the stdOut and stdErr channels are not closed for some reason.
I'll have another look tomorrow

@jweibel22
Copy link
Contributor Author

Turns out the issue with the output channels not getting closed has been brought up here:
go-cmd/cmd#26
It has been resolved and fixed in version v1.2.0 (and I have verified this)

I can think of 3 options

  1. Bump version of go-cmd to v1.2.0 (just a minor version difference so probably no breaking changes)
  2. Disable streaming (streaming is beneficial when executing "long running" commands, I'm not sure if we're calling any git commands that are actually long running, where waiting for output to be printed is an actual issue)
  3. Close the stdOut and stdErr channels ourselves when the command has finished.

@Crevil
Copy link
Member

Crevil commented Sep 27, 2020

Let's just bump the dep instead of changing the functionality.

Further more, as it has been fixed upstream, let's not monkey patch it locally 🤓

This is done to support dependencies using new package errors functions, e.g.
errors.As.
@Crevil Crevil marked this pull request as ready for review September 28, 2020 09:41
Copy link
Member

@Crevil Crevil left a comment

Choose a reason for hiding this comment

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

Great. I'll cut a release right away 🥇

@Crevil Crevil merged commit dd2f8b3 into master Sep 28, 2020
@Crevil Crevil deleted the fix/git-plan-empty-output branch September 28, 2020 09:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants