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

Move the schema/ package to the toplevel #3069

Merged
merged 2 commits into from
Sep 9, 2022
Merged

Conversation

cgwalters
Copy link
Member

@cgwalters cgwalters commented Sep 2, 2022

Today, we have three Go modules in this repository:

  • /
  • schema/
  • mantle/

And as of recently, both the toplevel / and mantle/ vendor the schema/.
This causes "vendor amplification", where a vendored dependency
of schema/ gets triplicated.

Now that gangplank/ is out of the picture, it makes sense to move
the bits from schema/ into the toplevel module.

This really helps make operating on coreos-assembler stuff
feel like a "first class" operation.

Also, we no longer have two copies of the schema file!


@openshift-ci
Copy link

openshift-ci bot commented Sep 2, 2022

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@cgwalters cgwalters force-pushed the schema-top branch 3 times, most recently from b2c59d0 to 169772c Compare September 6, 2022 12:04
@cgwalters cgwalters marked this pull request as ready for review September 6, 2022 12:04
@cgwalters cgwalters force-pushed the schema-top branch 2 times, most recently from 70af286 to dbd5ad7 Compare September 6, 2022 13:08
@cgwalters
Copy link
Member Author

cgwalters commented Sep 6, 2022

One way to look at this is if it'd merged before #2985 the number of files changed there would have been closer to 4, not 400+. The 400+ files removed here are the (re-)vendored dependencies there.

@cgwalters
Copy link
Member Author

OK cool, passing FCOS/Jenkins CI now, I'd assume RHCOS will pass too. Should be good to review

@cgwalters
Copy link
Member Author

/retest

@dustymabe
Copy link
Member

A few things.

  • Are there any consumers of this package outside of this repo?
  • I wonder if we should consider naming here more critically.
    • I don't know if having a ./cosa top level directory in this repo is best. Maybe ./schema? i.e. github.com/coreos/coreos-assembler/pkg/cosa has both coreos-assembler and cosa so it's hard to infer what it even is. github.com/coreos/coreos-assembler/pkg/schema may be a bit more intuitive?

@cgwalters
Copy link
Member Author

The "schema" package before also had code to parse builds.json etc. (duplicating what we have in the python side of course) so it isn't just schema.

@cgwalters
Copy link
Member Author

Are there any consumers of this package outside of this repo?

Not to my knowledge, but certainly as we make the transition more into being a Go project, we should think about this.

It's worth looking at https://github.com/golang-standards/project-layout

However actually, because mantle is a separate Go module, even though it lives in the same git repository we need to make packages it uses public - for now.

@cgwalters
Copy link
Member Author

I don't know if having a ./cosa top level directory in this repo is best. Maybe ./schema? i.e. github.com/coreos/coreos-assembler/pkg/cosa has both coreos-assembler and cosa so it's hard to infer what it even is.

Perhaps pkg/builds is best? That seems to match the naming we use on the python side.

@dustymabe
Copy link
Member

I don't know if having a ./cosa top level directory in this repo is best. Maybe ./schema? i.e. github.com/coreos/coreos-assembler/pkg/cosa has both coreos-assembler and cosa so it's hard to infer what it even is.

Perhaps pkg/builds is best? That seems to match the naming we use on the python side.

It's as good as any I can think of. Maybe we can get input from others?

Side note: I'm not going to lie, the word schema invokes a clear idea of what it is so I liked that. I didn't realize there was much else bundled in there with it. I'm guessing it's outside the scope here to peel off the builds part into pkg/builds and leave the schema part in a pkg/schema?

@cgwalters
Copy link
Member Author

I'm guessing it's outside the scope here to peel off the builds part into pkg/builds and leave the schema part in a pkg/schema?

Right...there's always more cleanup to do. As a baseline I tend to ask "is this PR making things objectively better?" And if so then I prefer merging and doing followup changes, especially from people I know are likely to stick around to do those changes. Actually even for drive by contributors, merging slightly-less-than-perfect changes helps avoid the case where they're pulled away by life events or whatever and the PR doesn't get merged at all (or not for a while).

@cgwalters
Copy link
Member Author

OK renamed to pkg/builds

@@ -31,7 +31,7 @@ import (
"github.com/pkg/errors"
"github.com/spf13/cobra"

"github.com/coreos/coreos-assembler-schema/cosa"
cosa "github.com/coreos/coreos-assembler/pkg/builds"
Copy link
Member

Choose a reason for hiding this comment

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

random aside: I'm wondering if we should not rename the import here.. not sure. I'm definitely don't have this all in my head.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's a matter of taste; I chose not to here to avoid inflating the diff more. Probably in most code we wouldn't rename it though.

@dustymabe
Copy link
Member

there is a build.goe file in the diff now. was that on purpose?

@dustymabe
Copy link
Member

there is a build.goe file in the diff now. was that on purpose?

nvm - there's a bunch of them. Something new for me to learn I guess.

Any go experts want to review this PR along with me?

@cgwalters
Copy link
Member Author

there is a build.goe file in the diff now. was that on purpose?

Oops definitely not, it was apparently a misfired sed command to try to s/package cosa/package builds/...

@cgwalters
Copy link
Member Author

While it's not related to this PR in a logical sense, I pushed an additional commit here which should fix cosa build-extensions-container on aarch64. The commit would textually conflict with the move otherwise.

@dustymabe
Copy link
Member

Is the src/v1.json file needed? We didn't have that before, right?

@cgwalters
Copy link
Member Author

Is the src/v1.json file needed? We didn't have that before, right?

We did; see https://github.com/coreos/coreos-assembler/blob/main/src/v1.json
in current git main.

What changes in this PR is we no longer have two separate copies.

@dustymabe
Copy link
Member

Is the src/v1.json file needed? We didn't have that before, right?

We did; see https://github.com/coreos/coreos-assembler/blob/main/src/v1.json in current git main.

Ahh. Yep. The diff view here in GH didn't make that obvious.

What changes in this PR is we no longer have two separate copies.

It's great that we now don't have two separate copies, but I am worried this is going to break a common COSA workflow where someone sets the COREOS_ASSEMBLER_GIT env var.

@cgwalters
Copy link
Member Author

I am worried this is going to break ... the COREOS_ASSEMBLER_GIT env var.

With the move to Go, that workflow will slowly become obsolete and break. Eventually I think what we want is that literally all of the logic lives in /usr/bin/coreos-assembler as a big static binary that you can just...copy around or bind mount in or whatever.

But specifically regarding the schema, even before this PR that problem already existed because you couldn't modify it and still invoke e.g. cosa run. It'd only work as long as the only things reading/writing were python and shell.

@dustymabe
Copy link
Member

It'd only work as long as the only things reading/writing were python and shell.

which is the use case that COREOS_ASSEMBLER_GIT satisfies.

I'd say until we get a better strategy for how we support that use case in the future maybe let's just make the schema generation Makefile put a copy in both places.. Alternatively put the actual file in src/v1.json and symlink the other one.

Today, we have *three* Go modules in this repository:

- /
- schema/
- mantle/

And as of recently, both the toplevel / and mantle/ vendor the schema/.
This causes "vendor amplification", where a vendored dependency
of schema/ gets *triplicated*.

Now that gangplank/ is out of the picture, it makes sense to move
the bits from schema/ into the toplevel module.

This really helps make operating on coreos-assembler stuff
feel like a "first class" operation.

Also, we no longer have two copies of the schema file!
A perfect example of the enormous technical debt we've accrued
in the python/shell/Go duplication, not to mention separate
Go modules for mantle and gangplank.

The gangplank code reimplemented logic to get the RPM architecture,
and missed converting `arm64` from Go's arch to `aarch64`.

Use the standard API we have for this in stream-metadata-go,
the same as mantle does.

This will fix extensions builds on aarch64.
@cgwalters
Copy link
Member Author

Alternatively put the actual file in src/v1.json and symlink the other one.

Sure, done - that actually makes the install logic simpler.

Copy link
Member

@dustymabe dustymabe left a comment

Choose a reason for hiding this comment

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

LGTM

@cgwalters cgwalters enabled auto-merge (rebase) September 9, 2022 18:05
@cgwalters
Copy link
Member Author

I'd say until we get a better strategy for how we support that use case in the future

The future is now ➡️ #3087

@cgwalters cgwalters merged commit 493c480 into coreos:main Sep 9, 2022
cgwalters added a commit to cgwalters/coreos-assembler that referenced this pull request Sep 12, 2022
Fixes: coreos#3069

I am pretty sure I had this working in some point in that PR, but
in reworking for feedback I broke having `make schema` actually work.

Put the target files in the right place, and fix the namespace.
dustymabe pushed a commit that referenced this pull request Sep 13, 2022
Fixes: #3069

I am pretty sure I had this working in some point in that PR, but
in reworking for feedback I broke having `make schema` actually work.

Put the target files in the right place, and fix the namespace.
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.

3 participants