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

Add support for declarative configs to "adm catalog mirror" #868

Merged
merged 3 commits into from Jul 21, 2021

Conversation

joelanford
Copy link
Member

See https://github.com/operator-framework/enhancements/blob/master/enhancements/declarative-index-config.md for background about OLM's declarative config indexes.

Signed-off-by: Joe Lanford joe.lanford@gmail.com

Signed-off-by: Joe Lanford <joe.lanford@gmail.com>
@openshift-ci openshift-ci bot requested review from deads2k and ecordell June 23, 2021 13:33
Signed-off-by: Joe Lanford <joe.lanford@gmail.com>
@joelanford
Copy link
Member Author

/test e2e-metal-ipi-ovn-ipv6

1 similar comment
@joelanford
Copy link
Member Author

/test e2e-metal-ipi-ovn-ipv6

}
return err
}
if blob.Schema != "olm.bundle" {
Copy link
Contributor

Choose a reason for hiding this comment

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

we might get some nice future-proofing by just checking for .Image or .RelatedImages and adding if they exist (so we don't have to update this when we have olm.bundle.v2 or olm.staticbundles etc)

Signed-off-by: Joe Lanford <joe.lanford@gmail.com>
@joelanford
Copy link
Member Author

/retest

1 similar comment
@joelanford
Copy link
Member Author

/retest

@joelanford
Copy link
Member Author

/assign @mfojtik

@ecordell
Copy link
Contributor

ecordell commented Jul 2, 2021

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jul 2, 2021
@ecordell
Copy link
Contributor

ecordell commented Jul 2, 2021

/approve

Copy link
Member

@soltysh soltysh left a comment

Choose a reason for hiding this comment

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

/hold
until I get answers about additional libraries this brings in

func (_ declcfgRelatedImagesParser) Parse(root string) (map[string]struct{}, error) {
rootFS := os.DirFS(root)

matcher, err := ignore.NewMatcher(rootFS, ".indexignore")
Copy link
Member

Choose a reason for hiding this comment

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

If this is the only call for the matcher I don't see any reason why we want to include 2 more packages, which of one is single-method helper and another is a transient dependency. Can't this be replaced with a simple file matcher?

Copy link
Member Author

Choose a reason for hiding this comment

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

In github.com/operator-framework/operator-registry, we decided to use the .gitignore style file matching for two reasons:

  1. Almost all users are familiar with it
  2. It supports multiple ignore files at multiple levels in a directory structure, which is important with declarative config based indexes for composability reasons.

Regardless of the choice of matcher, the matching semantics need to be consistent between opm and oc.

One alternative would be to inline the joelanford/ignore library directly into oc. I made that library as a simple shim over go-git's gitignore library.

Copy link
Member

Choose a reason for hiding this comment

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

Can you verify if one of the pre-existing libraries already included in oc doesn't have identical functionality, quick grep lead me to https://github.com/openshift/oc/blob/master/vendor/github.com/monochromegane/go-gitignore/gitignore.go although I haven't checked its functionality

Copy link
Member Author

Choose a reason for hiding this comment

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

From https://github.com/monochromegane/go-gitignore#features

go-gitignore use filepath.Match for matching meta char pattern, so not support recursive pattern (path/**/file).

Also, it doesn't appear to have built-in support for building a hierarchical matcher based on multiple gitignore files found in a directory tree, so we'd have to implement/test/maintain that as a wrapper library somewhere anyway, I think.

Looks like monochromegane/go-gitignore is brought in by https://github.com/openshift/oc/blob/master/vendor/sigs.k8s.io/kustomize/kyaml/kio/ignorefilesmatcher.go#L11, so not something we could directly control and switch over to go-git's gitignore library.

Copy link
Member

Choose a reason for hiding this comment

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

Also, it doesn't appear to have built-in support for building a hierarchical matcher based on multiple gitignore files found in a directory tree, so we'd have to implement/test/maintain that as a wrapper library somewhere anyway, I think.

I'd like to see that verified do you actually need this. I skimmed through the proposal and it wasn't explicitly obvious that you do.

Looks like monochromegane/go-gitignore is brought in by https://github.com/openshift/oc/blob/master/vendor/sigs.k8s.io/kustomize/kyaml/kio/ignorefilesmatcher.go#L11, so not something we could directly control and switch over to go-git's gitignore library.

yeah, I wasn't proposing switching that in kustomize's kyaml 😉

One alternative would be to inline the joelanford/ignore library directly into oc. I made that library as a simple shim over go-git's gitignore library.

yeah, if anything I'd prefer do it this way.

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'd like to see that verified do you actually need this. I skimmed through the proposal and it wasn't explicitly obvious that you do.

We do need this. One of the design ideas (not explicitly covered in the proposal) is that multiple DC-based indexes can be combined into a composite index. So for example, I can have the following, where indexComposite, indexA, indexB, pkg1, and pkg2 are all valid indexes:

$ tree -a indexComposite
indexComposite
├── DOC.md
├── indexA
│   ├── .indexignore
│   └── index.yaml
├── indexB
│   ├── .indexignore
│   ├── pkg1
│   │   ├── .indexignore
│   │   └── index.json
│   ├── pkg2
│   │   ├── .indexignore
│   │   └── index.yaml
│   └── README.md
└── .indexignore

The idea is that operator authors will be able to build a single-package index (e.g. pkg1 and pkg2), and catalog maintainers will be able to build indexes containing multiple packages and/or other indexes (e.g. indexComposite, indexA, and indexB). Each index maintainer should be able to include a .indexignore file in their index such that when their index is included in another index, their ignore patterns still apply, and apply in their index only without affecting other sibling or parent indexes.

yeah, if anything I'd prefer do it this way.

I can update the PR to avoid the joelanford/ignore dependency. The only concern I have with this is that oc and opm will be slightly harder to keep in sync. In the current setup, I would make a change in joelanford/ignore and then bump go.mod files. If I inline the code here, what was a go.mod bump becomes a copy/paste of whatever changed.

I don't anticipate changes to joelanford/ignore often (if ever), so probably no big deal, but I wanted to call this out at least to put all my cards on the table.

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 12, 2021
Copy link
Member

@soltysh soltysh left a comment

Choose a reason for hiding this comment

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

/hold cancel
/approve

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 21, 2021
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jul 21, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ecordell, joelanford, soltysh

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-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 21, 2021
@openshift-merge-robot openshift-merge-robot merged commit 4df50be into openshift:master Jul 21, 2021
@joelanford joelanford deleted the adm-ctlg-declcfg branch July 21, 2021 19:24
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants