-
Notifications
You must be signed in to change notification settings - Fork 187
Make /usr/bin/coreos-assembler a Go program, implement clean in Go
#2919
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
Conversation
|
To restate, the high level goal here is:
There's a ton of clear next steps here; the biggest is merging mantle/ to the toplevel, so that e.g. |
I don't think there's consensus for this part. Restructuring for convenience is one thing; setting policy is another. Let's not block the former on the latter? |
Definitely agreed! I'm just setting out my goals/perspective. |
|
Would this be something that would be better suited for a dedicated branch? Maybe it is better to keep this silo'ed from |
Hmm...this PR is really small I think and unlikely to break anything - CI covers almost everything. The corner case I wrestled with turned out to be Now if you're talking about the followups to this PR...I'm personally not planning on doing any wholesale or risky further followup changes in the short term. It could make sense though to branch if anyone chose to do that kind of thing. I think it makes the most sense to land incremental changes to |
Thanks for sharing your perspective, Colin! |
|
I'm +1 for this but maybe we should have at least one command making use of it as an example? |
jlebon
left a comment
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'm also 👍 to this.
While I strongly agree we shouldn't start trying to rewrite everything in Go, I'd say at least the bash entrypoint itself would be worthwhile to rewrite to make this less confusing (and it's not large anyway).
|
OK rebased 🏄 |
Also, this is done now! |
1704b08 to
b0a840b
Compare
Huh, fascinating 🕵️ |
c7dd06c to
8f94d61
Compare
|
OK so it took me a while to realize that this bit of bash code was...buggy: The thing is apparently because I adjusted the new Go logic to have a cleaner fallback here. |
|
(also, this latest push faithfully ports the existing shell logic for |
- Converts the entrypoint into Go code - Add an internal library that exposes/wraps `cmdlib.sh` because we have a lot of stuff in there that can't be ported to Go yet. - Add an internal library for running inline (named) bash scripts - Port `clean` to Go This is a pattern I think we'll use to aid the transition; rather than trying to rewrite things wholesale in Go, we'll continue to exec some shell scripts. Gradually perhaps, we may invert some things and change both `cmdlib.sh` and `cmdlib.py` to exec the cosa Go process in some cases too. Closes: coreos#2821
|
Nice, of course it randomly failed with a seemingly unrelated dynamic Python traceback... |
|
CI failure is unrelated, I think openshift/os#889 will fix it |
|
Hmm, timeout |
|
@travier @mike-nguyen as TLs mind weighing in officially on this? 👍 / 👎 / 0 / other? |
jlebon
left a comment
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.
Didn't do an in-depth review, but high-level LGTM! Thanks for tackling the entrypoint and cosa clean to get the ball rolling.
| return nil, err | ||
| } | ||
|
|
||
| bashCmd := fmt.Sprintf("%s\n. /proc/self/fd/3\n", StrictMode) |
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.
Minor: strict mode can be passed in on the cmdline directly, e.g. bash -euo pipefail -c ....
| // Package cosash implements a "co-processing" proxy that is primarily | ||
| // designed to expose a Go API that is currently implemented by `src/cmdlib.sh`. | ||
| // A lot of the code in that file is stateful - e.g. APIs set environment variables | ||
| // and allocate temporary directories. So it wouldn't work very well to fork | ||
| // a new shell process each time. | ||
| // | ||
| // The "co-processing" here is a way to describe that there's intended to be | ||
| // a one-to-one relationship of the child bash process and the current one, | ||
| // although this is not strictly required. The Go APIs here call dynamically | ||
| // into the bash process by writing to its stdin, and can receive serialized | ||
| // data back over a pipe on file descriptor 3. |
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.
This is pretty cool! It borders on the "too magic" line, but I definitely see the appeal for our purposes here. I think one risk factor is the increased mental complexity of reading, writing, and debugging code leveraging this. Whereas if you have a whole cosa command you know is 100% Go, that's more straightforward to work with. That said, I think it's still worth trying out as we evaluate how best to clean up this codebase.
|
I noticed this is marked as closing #2821 but I'm not sure we should tie the two. That cosa issue seems more to be a project policy decision. |
There's a lot of fuzzy lines here...the title of that issue is just "default to Go" which one could interpret in multiple ways. To me, "default to Go" is literally that the first code executed by We did have discussions about the "policy" question of e.g. trying to actively discourage other languages which I think is still separate from that issue. (But I admit it can be read in that way) |
dustymabe
left a comment
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.
Let's get the CI failure cleaned up and this merged.
|
CI is probably fixed by openshift/os#891 |
|
/retest |
I'm late here but I've already agreed in principle in #2919 (comment) and in general I'm in favor of us moving code from Bash or Python to Go. |
We recently did some golang migration [1] and happened to add the `cosa remote-session` pieces [2] after that migration. This makes it not easy to backport to ther branches. For a period of time let's use the latest COSA for our COSA pod for multi-arch builds instead of the versioned COSA. We will still use the versioned COSA on the remote so the actual building will happened with the correctly versioned COSA (substituted below and passed as an argument to `cosa remote-session create --image=`). [1] coreos/coreos-assembler#2919 [2] coreos/coreos-assembler#2979
We recently did some golang migration [1] and happened to add the `cosa remote-session` pieces [2] after that migration. This makes it not easy to backport to ther branches. For a period of time let's use the latest COSA for our COSA pod for multi-arch builds instead of the versioned COSA. We will still use the versioned COSA on the remote so the actual building will happened with the correctly versioned COSA (substituted below and passed as an argument to `cosa remote-session create --image=`). [1] coreos/coreos-assembler#2919 [2] coreos/coreos-assembler#2979
We recently did some golang migration [1] and happened to add the `cosa remote-session` pieces [2] after that migration. This makes it not easy to backport to ther branches. For a period of time let's use the latest COSA for our COSA pod for multi-arch builds instead of the versioned COSA. We will still use the versioned COSA on the remote so the actual building will happened with the correctly versioned COSA (substituted below and passed as an argument to `cosa remote-session create --image=`). [1] coreos/coreos-assembler#2919 [2] coreos/coreos-assembler#2979
We recently did some golang migration [1] and happened to add the `cosa remote-session` pieces [2] after that migration. This makes it not easy to backport to ther branches. For a period of time let's use the latest COSA for our COSA pod for multi-arch builds instead of the versioned COSA. We will still use the versioned COSA on the remote so the actual building will happened with the correctly versioned COSA (substituted below and passed as an argument to `cosa remote-session create --image=`). [1] coreos/coreos-assembler#2919 [2] coreos/coreos-assembler#2979
We recently did some golang migration [1] and happened to add the `cosa remote-session` pieces [2] after that migration. This makes it not easy to backport to ther branches. For a period of time let's use the latest COSA for our COSA pod for multi-arch builds instead of the versioned COSA. We will still use the versioned COSA on the remote so the actual building will happened with the correctly versioned COSA (substituted below and passed as an argument to `cosa remote-session create --image=`). [1] coreos/coreos-assembler#2919 [2] coreos/coreos-assembler#2979
We recently did some golang migration [1] and happened to add the `cosa remote-session` pieces [2] after that migration. This makes it not easy to backport to ther branches. For a period of time let's use the latest COSA for our COSA pod for multi-arch builds instead of the versioned COSA. We will still use the versioned COSA on the remote so the actual building will happened with the correctly versioned COSA (substituted below and passed as an argument to `cosa remote-session create --image=`). [1] coreos/coreos-assembler#2919 [2] coreos/coreos-assembler#2979
We recently did some golang migration [1] and happened to add the `cosa remote-session` pieces [2] after that migration. This makes it not easy to backport to other branches. For a period of time let's use the latest COSA for our COSA pod for multi-arch builds instead of the versioned COSA. We will still use the versioned COSA on the remote so the actual building will happened with the correctly versioned COSA (substituted below and passed as an argument to `cosa remote-session create --image=`). [1] coreos/coreos-assembler#2919 [2] coreos/coreos-assembler#2979
We recently did some golang migration [1] and happened to add the `cosa remote-session` pieces [2] after that migration. This makes it not easy to backport to other branches. For a period of time let's use the latest COSA for our COSA pod for multi-arch builds instead of the versioned COSA. We will still use the versioned COSA on the remote so the actual building will happened with the correctly versioned COSA (substituted below and passed as an argument to `cosa remote-session create --image=`). [1] coreos/coreos-assembler#2919 [2] coreos/coreos-assembler#2979
mantle: Display stderr from
ssh-keygenThis is failing in CI, but on general principle we don't want
to swallow stderr.
Make
/usr/bin/coreos-assemblera Go program, implementcleanin Gocmdlib.shbecause we have a lot of stuff in there that can't be ported
to Go yet.
cleanto GoThis is a pattern I think we'll use to aid the transition; rather
than trying to rewrite things wholesale in Go, we'll continue
to exec some shell scripts.
Gradually perhaps, we may invert some things and change both
cmdlib.shandcmdlib.pyto exec the cosa Go process in somecases too.
Closes: #2821