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

feat(opm): add unprivileged registry add #213

Merged
merged 6 commits into from
Apr 2, 2020

Conversation

njhale
Copy link
Member

@njhale njhale commented Mar 12, 2020

Add the ability to pull and unpack bundle images without using an external tool or daemon. Make this the only supported mode by removing the --container-tool option from the registry add subcommand.

Ex.

$ opm registry add --bundle-images "quay.io/olmtest/kiali:1.2.4"
INFO[0000] adding to the registry                        bundles="[quay.io/olmtest/kiali:1.2.4]"
INFO[0000] resolved name: quay.io/olmtest/kiali:1.2.4
INFO[0000] fetched                                       digest="sha256:a1bec450c104ceddbb25b252275eb59f1f1e6ca68e0ced76462042f72f7057d8"
INFO[0000] fetched                                       digest="sha256:8b19d5ea2c56e663fb886d9ca273dd1f8e20b107c9b6817dedd35aac90e16494"
INFO[0000] fetched                                       digest="sha256:1c019331644e2e826b6b8f11328b31a1c2f4aa2ae6ee225f0ab19a14af086d2b"
INFO[0000] fetched                                       digest="sha256:d9c98a446dd77b5e7cb1394748c2279d83668a519b2badda1259cd64cb3beb3f"
INFO[0000] unpacking layer: {application/vnd.docker.image.rootfs.diff.tar.gzip sha256:1c019331644e2e826b6b8f11328b31a1c2f4aa2ae6ee225f0ab19a14af086d2b 5916 [] map[] <nil>}
INFO[0000] unpacking layer: {application/vnd.docker.image.rootfs.diff.tar.gzip sha256:8b19d5ea2c56e663fb886d9ca273dd1f8e20b107c9b6817dedd35aac90e16494 296 [] map[] <nil>}
INFO[0000] found annotations file searching for csv      dir=bundle_tmp146087939 file=bundle_tmp146087939/metadata load=annotations
INFO[0000] found csv, loading bundle                     dir=bundle_tmp146087939 file=bundle_tmp146087939/manifests load=bundle
INFO[0000] loading bundle file                           dir=bundle_tmp146087939/manifests file=kiali.crd.yaml load=bundle
INFO[0000] loading bundle file                           dir=bundle_tmp146087939/manifests file=kiali.monitoringdashboards.crd.yaml load=bundle
INFO[0000] loading bundle file                           dir=bundle_tmp146087939/manifests file=kiali.package.yaml load=bundle
INFO[0000] loading bundle file                           dir=bundle_tmp146087939/manifests file=kiali.v1.4.2.clusterserviceversion.yaml load=bundle

Also, introduce a new bundle oriented image interface to decouple actions (pull, push, pack, unpack) from their underlying implementation.

@openshift-ci-robot openshift-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 12, 2020
@openshift-ci-robot openshift-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Mar 12, 2020
@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 12, 2020
@njhale njhale force-pushed the daemonless branch 4 times, most recently from 456c309 to 0db37f3 Compare March 12, 2020 15:36
@njhale njhale marked this pull request as ready for review March 12, 2020 15:38
@njhale njhale changed the title feat(opm): add unprivileged registry add WIP: feat(opm): add unprivileged registry add Mar 12, 2020
@njhale
Copy link
Member Author

njhale commented Mar 12, 2020

/retest

@openshift-ci-robot openshift-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. and removed do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels Mar 12, 2020

type Registry interface {
// Pull fetches and stores an image by reference.
Pull(ctx context.Context, ref string) error
Copy link
Member

Choose a reason for hiding this comment

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

One thing I like is using custom types for specificity such a type ImageReference string and then in the interface it would take in a ref ImageReference type as the arg. I'm not sure how appropriate it is here but something worth noting as it makes the code more readable IMO.

Copy link
Contributor

Choose a reason for hiding this comment

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

I wouldn't insist on it, but I also appreciate the extra compile-time safety of derived types for this kind of thing.

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay -- I'll change this

@@ -0,0 +1,38 @@
package shellout
Copy link
Contributor

Choose a reason for hiding this comment

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

@njhale while reading through the code I realized that I understand what unprivileged means in the context on this PR due to the commit message, but I'm not sure what shellout is for. What are your thoughts on adding comments that summaries the intent of a package/it's name?
Even with unprivileged I guess I'd have to go back and open up the PR to understand the motive behind it.

Copy link
Member Author

Choose a reason for hiding this comment

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

@anik120 I totally understand -- I actually spent a long time thinking about the naming here without coming up with anything better.

FYI: "shellout" is for shelling out to an external tool.

@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 15, 2020
@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 16, 2020
@njhale njhale changed the title WIP: feat(opm): add unprivileged registry add feat(opm): add unprivileged registry add Mar 17, 2020
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 17, 2020
Copy link
Member

@ecordell ecordell left a comment

Choose a reason for hiding this comment

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

looking great - left comments inline.

go.mod Outdated
gopkg.in/yaml.v2 v2.2.8
k8s.io/api v0.17.3
k8s.io/apiextensions-apiserver v0.17.3
k8s.io/apimachinery v0.17.3
k8s.io/client-go v0.17.3
k8s.io/klog v1.0.0
k8s.io/kubectl v0.17.3
rsc.io/letsencrypt v0.0.3 // indirect
Copy link
Member

Choose a reason for hiding this comment

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

this is unexpected

Copy link
Member Author

Choose a reason for hiding this comment

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

this should be gone now

Pack(ctx context.Context, ref string, from io.Reader) (next string, err error)
}

// We also need to generate Dockerfiles
Copy link
Member

Choose a reason for hiding this comment

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

I know this isn't final yet, but there are a few left over comments like this

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 should be cleaned up now.

return nil, err
}

bdb, err := bolt.Open(config.DBPath, 0644, nil)
Copy link
Member

Choose a reason for hiding this comment

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

At least we got bolt in here somehow!

We don't expect to have endianness concerns with this because this is a generated always at runtime and never persisted, correct?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup, it's always generated at runtime unless you really want to use an existing file.

@@ -27,7 +27,6 @@ func newRegistryAddCmd() *cobra.Command {
rootCmd.Flags().StringP("database", "d", "bundles.db", "relative path to database file")
rootCmd.Flags().StringSliceP("bundle-images", "b", []string{}, "comma separated list of links to bundle image")
rootCmd.Flags().Bool("permissive", false, "allow registry load errors")
rootCmd.Flags().StringP("container-tool", "c", "podman", "tool to interact with container images (save, build, etc.). One of: [docker, podman]")
Copy link
Member

Choose a reason for hiding this comment

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

we should consider making this a hidden flag in case anyone was relying on it existing (instead of throwing an error about not knowing the flag).

If we're confident no one is relying on it yet, we can remove.

Copy link
Member Author

@njhale njhale Mar 17, 2020

Choose a reason for hiding this comment

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

@benluddy and I were discussing this in an earlier review. Within Red Hat, I know there's some unreleased automation making use of the default value (not specifying --container-tool). However, I do think it's safer to use a hidden flag. Can we meet in the middle with a hidden flag that logs a warning when specified and continues with the daemonless implementation?

Copy link
Member Author

Choose a reason for hiding this comment

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

I made it a deprecated flag, which is both hidden and gives a warning when used.

@@ -31,3 +39,5 @@ require (
k8s.io/klog v1.0.0
k8s.io/kubectl v0.17.3
)

replace github.com/docker/distribution => github.com/docker/distribution v0.0.0-20191216044856-a8371794149d
Copy link
Member

Choose a reason for hiding this comment

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

is there any way to resolve this? we just got these all cleaned up...

Copy link
Member Author

Choose a reason for hiding this comment

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

We could just not run an in-process docker registry, which I expect would make the tests more complex.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is also a test dependency, which I think means it's not required by dependents to use the operator-registry module.


func NewResolver(username, password string, configs ...string) (remotes.Resolver, error) {
// TODO(njhale): make plainHTTP and insecure optional
plainHTTP := true
Copy link
Member

Choose a reason for hiding this comment

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

We should figure out these options before we merge - not supporting tls verification will be an issue.

@njhale njhale force-pushed the daemonless branch 4 times, most recently from b709f6b to aa29131 Compare March 19, 2020 13:46
@njhale
Copy link
Member Author

njhale commented Mar 19, 2020

I received some internal feedback to implement this with opencontainers instead of containerd if possible.

/hold

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 19, 2020
@openshift-ci-robot openshift-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Mar 27, 2020
njhale and others added 5 commits April 1, 2020 22:25

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
- Add the ability to pull and unpack bundle images without using to an external tool or daemon
- Introduce a new set of bundle image oriented interfaces to decouple image interaction from shelling out to external tools
- Add testdata dir and dot-import ginkgo
- Add pull and unpack unit tests
- Deprecate registry add container-tool opt
- Add skip-tls option to registry add

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
this still requires some refactoring and does not implement Unpack

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
- Add image.Reference interface and SimpleReference implementation as
  parameters of image.Registry methods (in place of strings)
- Refactor image.Registry tests into suite
- Add registry implementation notes
- Remove buildah from builds (Note: should be re-added once it's
  complete)

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
Update vendor directory to include dependencies needed for the
containerd image.Registry implementation.
@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 2, 2020
@ecordell
Copy link
Member

ecordell commented Apr 2, 2020

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Apr 2, 2020
@njhale
Copy link
Member Author

njhale commented Apr 2, 2020

/hold

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Apr 2, 2020
@njhale
Copy link
Member Author

njhale commented Apr 2, 2020

/hold cancel

Now I'm ready :)

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 2, 2020
@njhale
Copy link
Member Author

njhale commented Apr 2, 2020

/retest

@ecordell
Copy link
Member

ecordell commented Apr 2, 2020

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Apr 2, 2020
@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ecordell, njhale

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants