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

cosa2stream: Rework to better optimize openshift/installer flow #2052

Merged

Conversation

cgwalters
Copy link
Member

@cgwalters cgwalters commented Feb 22, 2021

When I was writing this originally I was focused on the goal
of converting cosa metadata to stream format, hence the name etc.

However upon trying to use this for openshift/installer I realized
something important: after we do the switch, the installer git
will be a "source of truth" for the pinned bootimages.

The expected user story here will be e.g. "update x86_64 to <version>".

So now we support this flow:

$ plume cosa2stream --distro rhcos --output data/data/rhcos.json x86_64=48.83.202102192019-0 s390x=47.83.202102090311-0

which hardcodes the URL we use now, and makes the arch+version mapping
explicit. We also paper over the fact that currently for RHCOS
there are separate cosa builds per architecture; the non-x86_64 ones
are named e.g rhcos-4.8-s390x instead of just rhcos-4.8.

@@ -37,10 +41,12 @@ def get_extension(path, modifier, arch):
parser = ArgumentParser()
parser.add_argument("--workdir", help="cosa workdir")
parser.add_argument("--build-id", help="build id")
parser.add_argument("--distro", help="Distro selects stream defaults such as baseurl and format", choices=['fcos', 'rhcos'])
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
parser.add_argument("--distro", help="Distro selects stream defaults such as baseurl and format", choices=['fcos', 'rhcos'])
parser.add_argument("--distro", help="Distro selects stream defaults such as baseurl and format", choices=['fcos', 'rhcos'], default='fcos')

Looks like it doesn't default to the first choice:

In [8]: parser = argparse.ArgumentParser()

In [9]: parser.add_argument('--foo', choices=['bar', 'baz'])
Out[9]: _StoreAction(option_strings=['--foo'], dest='foo', nargs=None, const=None, default=None, type=None, choices=['bar', 'baz'], help=None, metavar=None)

In [10]: parser.parse_args([])
Out[10]: Namespace(foo=None)

vs

In [14]: parser = argparse.ArgumentParser()

In [15]: parser.add_argument('--foo', choices=['bar', 'baz'], default='bar')
Out[15]: _StoreAction(option_strings=['--foo'], dest='foo', nargs=None, const=None, default='bar', type=None, choices=['bar', 'baz'], help=None, metavar=None)

In [16]: parser.parse_args([])
Out[16]: Namespace(foo='bar')

Copy link
Member Author

Choose a reason for hiding this comment

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

Well...we could default, but it's kind of intentional not to. We don't need to special case fcos here right now.

The idea here is that while some parts of cosa default to fcos, it's cleaner if it's more "mechanism" here. So after this PR lands we could change the pipeline to pass --distro fcos explicitly?

Copy link
Member

Choose a reason for hiding this comment

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

Ahh right OK. Just wanted to make sure this doesn't break FCOS as soon as it merges. But yeah, this doesn't.

Passing --distro fcos SGTM.

Copy link
Member Author

Choose a reason for hiding this comment

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

One thing I wanted to comment that's related - while we could hardcode/default FCOS in cosa and have rhcos be overrides, I think as a general rule it's good to split mechanism from configuration/policy.

Because even if all we cared about was FCOS, we'd still have the problem of e.g. CI on pull requests may need to behave differently, as well as supporting multiple streams with different possible tweaks between them, etc.

)

func init() {
cmdCosaBuildToStream.Flags().StringVar(&streamBaseURL, "url", "", "Base URL for build")
cmdCosaBuildToStream.Flags().StringVar(&streamName, "name", "", "Stream name")
cmdCosaBuildToStream.MarkFlagRequired("name")
cmdCosaBuildToStream.Flags().StringVar(&distro, "distro", "", "Distribution (fcos, rhcos)")
cmdCosaBuildToStream.Flags().StringVar(&output, "output", "", "Use this file as baseline and target for output (default: no baseline, print to stdout)")
Copy link
Member

Choose a reason for hiding this comment

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

Bikeshed: wonder if e.g. target is a better name for this? Since it's actually both an input and an output.

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, renamed.

@cgwalters cgwalters force-pushed the rhcos-endpoint-schema branch from 0001c53 to ab7da26 Compare February 23, 2021 20:07
mantle/cmd/plume/cosa2stream.go Outdated Show resolved Hide resolved
@@ -37,10 +41,12 @@ def get_extension(path, modifier, arch):
parser = ArgumentParser()
parser.add_argument("--workdir", help="cosa workdir")
parser.add_argument("--build-id", help="build id")
parser.add_argument("--distro", help="Distro selects stream defaults such as baseurl and format", choices=['fcos', 'rhcos'])
Copy link
Member

Choose a reason for hiding this comment

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

Ahh right OK. Just wanted to make sure this doesn't break FCOS as soon as it merges. But yeah, this doesn't.

Passing --distro fcos SGTM.

parser.add_argument("--stream-name", help="Override the stream ID (default is derived from coreos-assembler)")
parser.add_argument("--stream-baseurl", help="Prefix URL for stream content", default=FCOS_STREAM_ENDPOINT)
parser.add_argument("--stream-baseurl", help="Override prefix URL for stream content")
Copy link
Member

Choose a reason for hiding this comment

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

But OTOH dropping the default= on this one would break FCOS. Hmm, let's just have it key off of --distro if unspecified and then we definitely do follow up this PR with one for the pipeline?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah yep, good catch! I actually had a "dispatch on distro" code but then removed it, this change was an artifact of that. For now to keep things even clearer and minimize distro-dispatching I just reverted it.

@cgwalters cgwalters force-pushed the rhcos-endpoint-schema branch from ab7da26 to e6d3613 Compare February 23, 2021 20:53
Copy link
Member

@jlebon jlebon left a comment

Choose a reason for hiding this comment

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

/lgtm

When I was writing this originally I was focused on the goal
of converting cosa metadata to stream format, hence the name etc.

However upon trying to use this for openshift/installer I realized
something important: *after* we do the switch, the installer git
will be a "source of truth" for the pinned bootimages.

The expected user story here will be e.g. "update x86_64 to <version>".

So now we support this flow:
```
$ plume cosa2stream --distro rhcos --output data/data/rhcos.json x86_64=48.83.202102192019-0 s390x=47.83.202102090311-0
```

which hardcodes the URL we use now, and makes the arch+version mapping
explicit.  We also paper over the fact that currently for RHCOS
there are separate cosa builds per architecture; the non-x86_64 ones
are named e.g `rhcos-4.8-s390x` instead of just `rhcos-4.8`.
@jlebon
Copy link
Member

jlebon commented Feb 23, 2021

/lgtm

We should add a call to cosa generate-release-meta to CI here.

@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cgwalters, jlebon

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-robot openshift-merge-robot merged commit 44e519c into coreos:master Feb 23, 2021
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