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

Expose bundle data from bundle image #94

Merged

Conversation

jpeeler
Copy link

@jpeeler jpeeler commented Oct 1, 2019

This provides a command to expose data in a bundle image and parses both /manifests and /metadata as proposed in operator-framework/operator-lifecycle-manager#1054.

This might need some shuffling around as I'm not sure the sqlite package is the best place for this code to live. Also, currently it includes another WIP PR which is likely to change.

This includes functionality for launching the container to execute the new serve command, to be called from OLM once this and other PRs are pulled in.

OLM-1275

@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 Oct 1, 2019
@openshift-ci-robot openshift-ci-robot added 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 Oct 1, 2019
@jpeeler jpeeler force-pushed the expose-bundle-data branch from a133142 to 33248b4 Compare October 3, 2019 20:33
@jpeeler
Copy link
Author

jpeeler commented Oct 3, 2019

This update includes the code for launching a container to execute the new serve command and is feature complete, minus the tests.

@jpeeler jpeeler force-pushed the expose-bundle-data branch from 33248b4 to d18f84f Compare October 9, 2019 21:10
@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 9, 2019
@jpeeler jpeeler force-pushed the expose-bundle-data branch from d18f84f to ec6e3c0 Compare October 9, 2019 21:11
@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 9, 2019
@jpeeler jpeeler changed the title WIP: Expose bundle data from bundle image Expose bundle data from bundle image Oct 9, 2019
@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 Oct 9, 2019
@jpeeler
Copy link
Author

jpeeler commented Oct 9, 2019

I just need to plumb the e2e test (potentially) into the makefile and CI. The WIP commit (related to CLI handling) referenced above has been removed.

Copy link
Member

@awgreene awgreene left a comment

Choose a reason for hiding this comment

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

Great work! I had a few nits and general question but the logic looks great!

)

// configmap keys can contain underscores, but configmap names can not
var unallowedKeyChars = regexp.MustCompile("[^-A-Za-z0-9_.]")
Copy link
Member

Choose a reason for hiding this comment

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

Rather than whitelisting valid characters wouldn't it be better to check for valid k8s object names?

Copy link
Member

Choose a reason for hiding this comment

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

For example, a-- would get through this. I understand that this is being used to fix invalid configmap names, but I'm not sure if that's something the tool should be responsible for.

Copy link
Author

Choose a reason for hiding this comment

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

There was some discussion as to whether or not the code here should be responsible for validating "valid" file names ("valid" because technically it's a configmap implementation detail leaking into what's considered valid from a user perspective). However, given how short this code is, I personally like ensuring that things don't explode. And since the resource names aren't in play here, I believe the chosen regex is best.

}

func TranslateInvalidChars(input string) string {
validConfigMapKey := unallowedKeyChars.ReplaceAllString(input, "~")
Copy link
Member

Choose a reason for hiding this comment

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

It is not apparent to me why you are providing ~ as an input (even after googling). Could you explain?

Copy link
Author

Choose a reason for hiding this comment

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

This ties into the above comment. If you want to argue that failing instead of translating to valid is best, then this code is up for potential removal. But I randomly chose the tilda character as a character that is typically rarely used to replace any invalid characters. In practice, I hope the string is not modified, but did make sure to include a warning message to point out the potential issue.

@jpeeler jpeeler force-pushed the expose-bundle-data branch from ec6e3c0 to e59b816 Compare October 11, 2019 18:46
@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 11, 2019
@jpeeler jpeeler force-pushed the expose-bundle-data branch from e59b816 to b40c9b8 Compare October 11, 2019 18:49
@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 11, 2019
@jpeeler jpeeler force-pushed the expose-bundle-data branch from b40c9b8 to 220ec6a Compare October 14, 2019 14:22
@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 14, 2019
@jpeeler jpeeler force-pushed the expose-bundle-data branch from 220ec6a to a98ec3c Compare October 14, 2019 14:23
@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 14, 2019
@jpeeler jpeeler force-pushed the expose-bundle-data branch from a98ec3c to ef47feb Compare October 14, 2019 16:09
@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 14, 2019
@jpeeler jpeeler force-pushed the expose-bundle-data branch from ef47feb to c94d43f Compare October 14, 2019 16:09
@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 14, 2019
@jpeeler
Copy link
Author

jpeeler commented Oct 14, 2019

/retest

jpeeler pushed a commit to tkashem/operator-registry that referenced this pull request Oct 14, 2019
This verifies that the configmap is being properly read from the
extracted data of a bundle image (from operator-framework#94).
@@ -0,0 +1,3 @@
annotations:
operators.coreos.com.bundle.resources: "manifests+metadata"
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 the only change I think we need. Please see my comment on Vu's PR: #97 (comment)

This should be a minor change, otherwise everything looks great!

Before I lgtm, do you want to hold this for further testing on the OLM side? Or would you rather merge and make new PRs if something comes up?

Copy link
Author

Choose a reason for hiding this comment

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

I think it's easier to go ahead and get in. Hopefully any follow ups are pretty minor.

@jpeeler jpeeler force-pushed the expose-bundle-data branch from c94d43f to f6fb0e4 Compare October 18, 2019 16:46
@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 18, 2019
@jpeeler jpeeler force-pushed the expose-bundle-data branch from f6fb0e4 to 05cd9a9 Compare October 18, 2019 16:47
@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 18, 2019
jpeeler pushed a commit to tkashem/operator-registry that referenced this pull request Oct 23, 2019
Previously, the package manifest data was going to be included as a file
within the bundle. The planning changed and this updates the
implementation to match. (This commit can be squashed, but was left as
separate for review purposes.)

The configmap annotations for manifest data has been made as a
requirement.

Also, this PR now depends on operator-framework#94.
jpeeler pushed a commit to tkashem/operator-registry that referenced this pull request Oct 28, 2019
This verifies that the configmap is being properly read from the
extracted data of a bundle image (from operator-framework#94).
@jpeeler jpeeler force-pushed the expose-bundle-data branch from 05cd9a9 to 371a5c2 Compare October 28, 2019 21:51
@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 28, 2019
Jeff Peeler added 5 commits October 28, 2019 17:51
Allows code reuse throughout operator-registry.
This implements "Populate" for writing bundle data to a configmap. Both
subdirectories manifests and metadata are parsed for files to be stored
in the configmap.

Also implements a function for deploying the bundle image via a job.
This command serves the manifest data from an image bundle into a
configmap via `opm alpha bundle extract`.
Essentially what is produced by `ginkgo bootstrap`, but without using
dot-imports. The package name is intentionally chosen to be outside of
the code under test in order to encourage not reaching into the
internals.
The image-bundle directory contains files for the data inside a bundle
image in addition to buildling both the bundle and init container
images.
@jpeeler jpeeler force-pushed the expose-bundle-data branch from 371a5c2 to 2c7ba05 Compare October 28, 2019 21:52
@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 28, 2019
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.

/lgtm

I had some nits, but they can be resolved in followups.

clientset *kubernetes.Clientset
}

func NewConfigMapLoaderForDirectory(configMapName, namespace, manifestsDir, kubeconfig string) *ConfigMapWriter {
Copy link
Member

@ecordell ecordell Oct 29, 2019

Choose a reason for hiding this comment

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

nit: NewConfigMapWriterForDirectory

nit: might want to use the functional option pattern for arguments we've been using elsewhere

// the responsibility of the caller to delete the job, the pod, and the configmap
// when done. This function is intended to be called from OLM, but is put here
// for locality.
func LaunchBundleImage(kubeclient kubernetes.Interface, bundleImage, initImage, namespace string) (*corev1.ConfigMap, *batchv1.Job, error) {
Copy link
Member

Choose a reason for hiding this comment

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

nit: should be able to set the path to find opm in initImage?

@@ -0,0 +1,773 @@
package e2e_test
Copy link
Member

Choose a reason for hiding this comment

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

👍

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 29, 2019
@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

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

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 8df762a into operator-framework:master Oct 29, 2019
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

5 participants