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

[feature] Understanding packages from bundle directory #241

Conversation

Bowenislandsong
Copy link
Member

@Bowenislandsong Bowenislandsong commented Mar 29, 2020

This commit adds a feature to interpret bundle name and channels
based on a given bundle directory and update bundle's annotation
YAML. This feature is triggered when opm alpha generate/build is
not supplying packageName, channels, and defaultChannels information.
This Bundle directory needs to be inside a Package directory
that contains all bundles.

The previous reverted commit 13373cb
accidentally changed opm command.
This commit removes the duplicated package flag.
This commit corrects bundle dir from pakcgae directory.
This commit adds an error message for getting empty channels for a bundle.
This commit skipes error for trying to parse anyfile as Json or Yaml format.

Description of the change:

Motivation for the change:

Reviewer Checklist

  • Implementation matches the proposed design, or proposal is updated to match implementation
  • Sufficient unit test coverage
  • Sufficient end-to-end test coverage
  • Docs updated or added to /docs
  • Commit messages sensible and descriptive

@Bowenislandsong
Copy link
Member Author

/retest

1 similar comment
@Bowenislandsong
Copy link
Member Author

/retest

@Bowenislandsong Bowenislandsong force-pushed the understand-packages branch 3 times, most recently from e99aaa9 to ed35d3d Compare March 30, 2020 01:41
@Bowenislandsong
Copy link
Member Author

Bowenislandsong commented Mar 30, 2020

@Bowenislandsong Bowenislandsong changed the title [feature] Understanding packages from directory [feature] Understanding packages from bundle directory Mar 30, 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.

/hold

The package inference looks good, but I have concerns about using the graph loader here - please see comments inline.


return &csv, nil
}
return nil, fmt.Errorf("csv typed YAML file not found in %s", bundleDir)
Copy link
Member

Choose a reason for hiding this comment

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

nit: no ClusterServiceVersion object found in %s (since this parses yaml/json, don't indicate to users that it must be yaml)

return nil, fmt.Errorf("error loading CSV from bundle directory, %v", err)
}

pkgDir, err := registry.NewPackageGraphLoaderFromDir(path.Join(bundleDir, ".."))
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure this is what we want to do here.

This reads in the directory of files and generates a graph, and tells you if there are problems.

But the generate command is used for a single bundle. That single bundle may be applied to any target index, and has nothing to do with the bundles that happen to be in in the filesystem next to it.

I think this would be fine without the graph loader in this PR at all. Thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

But I thought the whole purpose of this though is to automagically decide what channels a given bundle is. How can we do that without attempting to build the graph for a given package?

Copy link
Member Author

Choose a reason for hiding this comment

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

Same ask!

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the explanation - commented before ☕️ !

I think there's a slight impedance mismatch here - this option is now only really useful if you're attempting convert an entire directory of the old format, right?

Should this really be part of the normal command for generating/buliding single bundles when it's so tied to the set?

Copy link
Member

Choose a reason for hiding this comment

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

I think the trigger for it should be "if you didn't pass in these parameters explicitly, let's go see if we can find them for you" rather than it being an explicit opt in/opt out feature. IMO that's a better experience

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 second that this should be an experience enhancement type of feature based on the fact that you have the full-blown format with bundles nested in a package along with other bundles. Without it, it does not have any information we would be looking for. The default channel and channels are only obtainable in the *.package.yaml file. To figure out which channels a bundle belongs to require relationships of this bundle with respect to every channel heads and see if it is directly/transitively replaced by those channel heads to be included as part of that channel. Without the package and rest of the bundles, all we can be certain from a single bundle is the package name.

After all, this feature is just auto-filling package name, channels, and default channels for a bundle.

@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 30, 2020
This commit adds a feature to interpret bundle name and channels
based on a given bundle directory and update bundle's annotation
YAML. This feature is triggered when opm alpha generate/build is
not supplying packageName, channels, and defaultChannels information.
This Bundle directory needs to be inside a Package directory
that contains all bundles.

The previous reverted commit 13373cb
accidentally changed opm command.
This commit removes the duplicated package flag.
This commit corrects bundle dir from pakcgae directory.
This commit adds an error message for getting empty channels for a bundle.
This commit skipes error for trying to parse anyfile as Json or Yaml format.

The output directory of the annotation file is not the bundle directory rather its parent directory. This fix resolves it.
Copy link
Member Author

@Bowenislandsong Bowenislandsong left a comment

Choose a reason for hiding this comment

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

@kevinrizza @ecordell log info added for inference.

INFO[0000] Bundle channels and package name information not provided, inferring from parent package directory 
INFO[0000] Inferred channels: beta                      
INFO[0000] Inferred package name: banzaicloud-kafka-operator 
INFO[0000] Inferred default channel: beta               
INFO[0000] Building annotations.yaml                    
INFO[0000] Building Dockerfile      

if packageName == "" {
notProvided = append(notProvided, "package name")
}
log.Infof("Bundle %s information not provided, inferring from parent package directory",
Copy link
Member Author

Choose a reason for hiding this comment

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

log/notification added at the info level to suggestion inference took place.

if channels == "" {
return fmt.Errorf("error interpreting channels, please manually input channels instead")
}
log.Infof("Inferred channels: %s", channels)
Copy link
Member Author

Choose a reason for hiding this comment

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

The inference results are also posted.

@kevinrizza
Copy link
Member

/lgtm

@openshift-ci-robot openshift-ci-robot added lgtm Indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Apr 1, 2020
@ecordell
Copy link
Member

ecordell commented Apr 1, 2020

/lgtm

@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Bowenislandsong, ecordell, kevinrizza

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:
  • OWNERS [ecordell,kevinrizza]

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

@Bowenislandsong
Copy link
Member Author

/retest

@Bowenislandsong
Copy link
Member Author

/hold cancel

@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 1, 2020
@Bowenislandsong
Copy link
Member Author

/retest

@openshift-merge-robot openshift-merge-robot merged commit d5f8836 into operator-framework:master Apr 1, 2020
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