Description of problem: Version-Release number of selected component (if applicable): [jzhang@dhcp-140-36 operator-registry]$ git log commit 0652a729aa32fc5b217cbddb11ea7c90af1532da (HEAD -> master, origin/master, origin/HEAD) Merge: e517d18 147c4b8 Author: OpenShift Merge Robot <openshift-merge-robot.github.com> Date: Fri Jan 31 09:00:42 2020 -0800 How reproducible: always Steps to Reproduce: 1. Build the `opm` binary: 1) $ git clone git:operator-framework/operator-registry.git 2) $ cd operator-registry && go build ./cmd/opm [jzhang@dhcp-140-36 operator-registry]$ ls -l opm -rwxrwxr-x 1 jzhang jzhang 48847080 Feb 6 16:46 opm 2. Run `./opm alpha bundle validate -t quay.io/jiazha/learn-operator-image:v0.0.1` Actual results: [jzhang@dhcp-140-36 operator-registry]$ ./opm alpha bundle validate -t quay.io/jiazha/learn-operator-image:v0.0.1 INFO[0000] Create a temp directory at /tmp/bundle-383780032 container-tool=docker DEBU[0000] Pulling and unpacking container image container-tool=docker INFO[0000] running docker pull container-tool=docker DEBU[0000] [docker pull quay.io/jiazha/learn-operator-image:v0.0.1] container-tool=docker INFO[0005] running docker save container-tool=docker DEBU[0005] [docker save quay.io/jiazha/learn-operator-image:v0.0.1 -o bundle_staging_719432991/bundle.tar] container-tool=docker INFO[0005] Unpacked image layers, validating bundle image format & contents container-tool=docker DEBU[0005] Found manifests directory container-tool=docker DEBU[0005] Found metadata directory container-tool=docker DEBU[0005] Getting mediaType info from manifests directory container-tool=docker DEBU[0005] Validating annotations.yaml container-tool=docker DEBU[0005] Found annotation "operators.operatorframework.io.bundle.package.v1" with value "learn-operator" container-tool=docker DEBU[0005] Found annotation "operators.operatorframework.io.bundle.channels.v1" with value "alpha" container-tool=docker DEBU[0005] Found annotation "operators.operatorframework.io.bundle.channel.default.v1" with value "alpha" container-tool=docker DEBU[0005] Found annotation "operators.operatorframework.io.bundle.mediatype.v1" with value "registry+v1" container-tool=docker DEBU[0005] Found annotation "operators.operatorframework.io.bundle.manifests.v1" with value "manifests/" container-tool=docker DEBU[0005] Found annotation "operators.operatorframework.io.bundle.metadata.v1" with value "metadata/" container-tool=docker DEBU[0005] Validating bundle contents container-tool=docker DEBU[0005] Validating "operators.coreos.com/v1alpha1, Kind=ClusterServiceVersion" from file "learn-operator.v0.0.1.clusterserviceversion.yaml" container-tool=docker DEBU[0005] Validating "apiextensions.k8s.io/v1beta1, Kind=CustomResourceDefinition" from file "learn.crd.yaml" container-tool=docker Error: Bundle validation errors: error unmarshaling JSON: while decoding JSON: Object 'Kind' is missing in '{"channels":[{"currentCSV":"learn-operator.v0.0.1","name":"alpha"}],"defaultChannel":"alpha","packageName":"learn-operator"}' Usage: opm alpha bundle validate [flags] Expected results: Since there is no Kind field for the package object. So, it should skip the `Kind` validation. mac:learn jianzhang$ cat 0.0.1/learn.package.yaml packageName: learn-operator channels: - currentCSV: learn-operator.v0.0.1 name: alpha defaultChannel: alpha Additional info: This is the manifests of this bundle image: quay.io/jiazha/learn-operator-image:v0.0.1 https://github.com/jianzhangbjz/learn-operator/tree/master/manifests/learn
The manifest directory of a bundle image should only contain Kubernetes manifests. opm is reporting a valid error in this case.
Hi, Ben Do you mean I should remove the package definition from the manifest? If so, the manifest cannot work as a bundle. And, the error opm reports here is confusing for the user.
Yes, bundle images shouldn't contain a package YAML file. Package and channel name are present as key-value pairs in the required annotations.yaml file. The documentation for the new bundle image type is here: https://github.com/operator-framework/operator-registry/blob/master/docs/design/operator-bundle.md and a sample is here: https://github.com/operator-framework/bundle-example. Do you have any suggestions for how to improve the validation error message? The validation tool doesn't know what a package file is, so it's not able to explain precisely why this is failing. It expects all manifests/*.yaml files to be valid Kubernetes manifests, which is why the error says that the required field "Kind" is missing.
Hi, I would like to clarify couple things and reinstate the fact this is not a bug. The bundle manifest means Kubernetes manifests such as CRD or OLM internal type such as CSV and they are meant to be installed on the cluster. They need to have `Kind` and `apiVersion` in their YAML. The package.yaml is metadata manifest which contains information about the bundle itself and it is not installed on the cluster so technically speaking it should be in the metadata folder. For the new bundle format, we are moving away from package.yaml (deprecated) as all information regarding bundle is now in annotations.yaml. Those channel, default channel and package name are supplied via parameters on opm build command. So when you include the package.yaml in bundle manifests folder, it is expected that validation library will error out as this is not a valid/supported type. What we can do here is to improve the documentation to include which types are supported and make that information explicitly clear so users are aware. Would that be a good way to resolve this issue? Thanks, Vu
Hi, Vu, Ben > What we can do here is to improve the documentation to include which types are supported and make that information explicitly clear so users are aware. Would that be a good way to resolve this issue? Yes, great! I see now, I think so too, thanks very much! Verify it first. Now, the users are confused with "bundle image" in the output of the "opm alpha bundle validate". It's not the image that stores the operator manifests. It's better if we can give more details on this output. mac:operator-registry jianzhang$ ./opm alpha bundle validate --help The "opm alpha bundle validate" command will validate bundle image from a remote source to determine if its format and content information are accurate. Usage: opm alpha bundle validate [flags] Examples: $ opm alpha bundle validate --tag quay.io/test/test-operator:latest --image-builder docker Flags: -h, --help help for validate -b, --image-builder string Tool to build container images. One of: [docker, podman] (default "docker") -t, --tag string The path of a registry to pull from, image name and its tag that present the bundle image (e.g. quay.io/test/test-operator:latest)
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHBA-2020:0581