Skip to content

Updates to publishing: flags, invocation image tagging#1405

Merged
vdice merged 8 commits intogetporter:mainfrom
vdice:ref/update-publish-flags
Jan 12, 2021
Merged

Updates to publishing: flags, invocation image tagging#1405
vdice merged 8 commits intogetporter:mainfrom
vdice:ref/update-publish-flags

Conversation

@vdice
Copy link
Copy Markdown
Member

@vdice vdice commented Jan 8, 2021

What does this change

Updates porter publish per the manifest update epic in #1151:

  • Effectively renames the former tag flag to reference for specifying a full bundle reference for publishing
    • Note: as this flag is part of the BundlePullOptions, the name changes for other commands as well, e.g. porter install --reference mybuns:v0.1.0
  • Updates the tag flag to just designate the Docker tag portion of the published bundle
  • Adds the registry flag to designate the Docker registry (and org/subdomain) portion of the published bundle
  • Updates logic in publish to tag (as in docker tag) an updated invocation image (say, if a new registry value is provided on publish), so that the image is found for publishing. Previously, a new invocation image name would trigger a full new re-build.

Ref #1335

What issue does it fix

Closes #1335
Closes #1151

Notes for the reviewer

Checklist

  • Unit Tests
  • Documentation
  • Schema (porter.yaml)

If this is your first pull request, please add your name to the bottom of our Contributors list. Thank you for making Porter better! 🙇‍♀️

vdice added 3 commits January 7, 2021 09:51
Signed-off-by: Vaughn Dice <vadice@microsoft.com>
Signed-off-by: Vaughn Dice <vadice@microsoft.com>
Signed-off-by: Vaughn Dice <vadice@microsoft.com>
@carolynvs
Copy link
Copy Markdown
Member

Looks like the stamp constant changed for one of the tests, once that's updated the tests should pass.

@carolynvs carolynvs self-assigned this Jan 8, 2021
Signed-off-by: Vaughn Dice <vadice@microsoft.com>
Copy link
Copy Markdown
Member

@carolynvs carolynvs left a comment

Choose a reason for hiding this comment

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

Looks great! Thank you for the massive rename and logic switcharoo. Just had some questions to make sure I fully understand the change and then we are good to go.

data = append(data, v...)

// (for instance, during publish), so add this to the data
data = append(data, c.Manifest.Image...)
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.

Sorry I know we talked about this but I've gotten fuzzy over the holidays. Can you remind me why we can remove this? I am just wondering if the info is now in the generate manifest, or if we can't put it in anymore because the flag may have changed the value?

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.

I/we had added this previously to automatically trigger a rebuild whenever a bundle's image was updated. (Say, when a new registry or tag value is supplied on publish.) However, in this PR, instead of rebuilding the bundle, we re-tag images/bundle references and use these for publishing.

As noted elsewhere, it does mean that the actual contents (bundle.json/porter.yaml) included in the installer/invocation image may have different registry/reference values from the final published versions. For instance, the built bundle might have registry: myregistry.com but if I publish the bundle via porter publish --registry localhost:5000, the published invocation image (localhost:5000/mybuns:v0.1.0) will have a porter.yaml file with the original registry: myregistry.com field.

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.

Thanks for clearing that up. I know some users want to be able to publish to alternate locations, either because they moved it across an airgap or something else, and have the bundle not contain the original information. One workaround in that case would be to use non-sensitive information when building the bundle and then always set a --registry, etc during publish.

Comment thread pkg/manifest/manifest.go
@@ -47,6 +47,10 @@ type Manifest struct {
// and isn't meant to be user-specified
BundleTag string `yaml:"-"`
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.

Do we use this field, BundleTag, to hold the final computed bundle reference? Or can we remove it?

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.

I see it used in code but it's super confusing and I think a relic from a previous config setting we removed. Now may be a real good time to get rid of it completely (in a follow-up).

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.

Do we use this field, BundleTag, to hold the final computed bundle reference? Or can we remove it?

Not anymore - now we use Reference to track the bundle reference. Indeed, BundleTag is ripe for removal. I can create an issue.

Comment thread pkg/porter/build.go
if err := p.LoadManifestFrom(build.LOCAL_MANIFEST); err != nil {
return err
}
if err := p.LoadManifestFrom(build.LOCAL_MANIFEST); err != nil {
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.

What is the flow when someone does publish --reference. Do we do a full rebuild, or do we only retag? I'm wondering why it's safe now to unconditionally load the generated manifest.

I'm not you asking to change anything, just making sure I understand the new workflow with these tags.

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.

Good question. Now, when a --reference override is supplied, we only retag (invocation image and final bundle reference). This does mean the bundle.json and porter.yaml files in the invocation image will be from the unchanged internal manifest.

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.

Can you document this new "re-tag not rebuild" behavior in the LongDescription of the porter publish command?

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.

👍 Added.

Comment thread cmd/porter/bundle.go
porter bundle publish --file myapp/porter.yaml
porter bundle publish --archive /tmp/mybuns.tgz --tag myrepo/my-buns:0.1.0
porter bundle publish --archive /tmp/mybuns.tgz --reference myrepo/my-buns:0.1.0
porter bundle publish --tag latest
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.

It's going to be a rough transition because we changed the meaning of this flag. How about in a follow-up we add validation for the publish options that checks if they are using --tag to specify the entire reference and error out explaining that the flags have changed?

We can identify that --tag contains a reference by checking for :/@, neither of which are allowed in a docker tag.

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.

Good point. I almost think it's warranted to delay this PR until another commit including this logic is pushed. WDYT? I can work on this.

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.

If you are up for it, that's great.

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.

Ok, I added logic to error accordingly for the tag option on publish.

Do we want to do something similar for the other commands that previously also had a tag opt (courtesy BundlePullOptions)? As it stands, users who try to invoke porter install --tag mybuns:v0.1.0 will just see a standard Error: unknown flag: --tag after this is merged (and need to check the docs to see --reference is the new opt). Naturally, in the release notes, we can note this breaking cli opt change... not sure if we should also bake in a deprecation warning or error.

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.

Yeah, we could add back a Tag field and flag definitions and then check if it was populated and give a better error message. It would just be temporary until 1.0 when hopefully we stop making breaking changes for a bit.

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.

Ok, added it back as a deprecated flag (in Cobra terms this means it'll hide the flag by default and produce a deprecation warning when a value is provided). When provided, we just assign reference to the value instead of explicitly erroring out -- WDYT?

vdice added 2 commits January 12, 2021 11:08
Signed-off-by: Vaughn Dice <vadice@microsoft.com>
Signed-off-by: Vaughn Dice <vadice@microsoft.com>
Comment thread pkg/porter/publish.go
// A previous iteration of this flag was used to designate an entire bundle
// reference. If we detect this attempted use, we return an error and
// explanation
func (o *PublishOptions) validateTag() error {
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.

Thanks for adding this! It will really help avoid a bunch of very unhappy users.

Signed-off-by: Vaughn Dice <vadice@microsoft.com>
Comment thread cmd/porter/main.go

func addDeprecatedTagFlag(f *pflag.FlagSet, opts *porter.BundlePullOptions) {
f.StringVar(&opts.Tag, "tag", "", "")
f.MarkDeprecated("tag", "use --reference to declare a full bundle reference")
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.

Will this print a warning so that they know it's been deprecated and that they should stop using it? If not, let's an the warning to where you do the reference = tag assignment.

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.

It will. This is what it currently looks like:

 $ p install --tag localhost:5000/cert-manager:v0.1.0 -c mk -p cert-manager
Flag --tag has been deprecated, use --reference to declare a full bundle reference
installing cert-manager...
...

Do we want stronger verbiage (e.g. WARNING ...)?

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.

Nope! I just hadn't used the cobra deprecation flag and wasn't sure how it worked. 👍

Copy link
Copy Markdown
Member

@carolynvs carolynvs left a comment

Choose a reason for hiding this comment

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

One step closer to 1.0!

Signed-off-by: Vaughn Dice <vadice@microsoft.com>
@vdice vdice merged commit 0fa366e into getporter:main Jan 12, 2021
@vdice vdice deleted the ref/update-publish-flags branch January 12, 2021 22:41
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.

Publish: Update/support tag and repository flags Proposal: Naming/Versioning Manifest updates

2 participants