Skip to content

Conversation

kevinrizza
Copy link
Member

No description provided.

@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 13, 2020
@kevinrizza kevinrizza force-pushed the remove-registry-dep branch from a2e7b64 to 2ce8cb5 Compare May 13, 2020 14:57
@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 13, 2020
@kevinrizza kevinrizza force-pushed the remove-registry-dep branch from 2ce8cb5 to 6348456 Compare May 13, 2020 15:06
Copy link
Member

@estroz estroz left a comment

Choose a reason for hiding this comment

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

On first pass, looks good. Some questions/nits.

Channels []string
DefaultChannel string
BundleImage string
Csv *operatorsv1alpha1.ClusterServiceVersion
Copy link
Member

Choose a reason for hiding this comment

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

Nit:

Suggested change
Csv *operatorsv1alpha1.ClusterServiceVersion
CSV *operatorsv1alpha1.ClusterServiceVersion

DefaultChannel string
BundleImage string
Csv *operatorsv1alpha1.ClusterServiceVersion
V1beta1crds []*apiextensionsv1beta1.CustomResourceDefinition
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
V1beta1crds []*apiextensionsv1beta1.CustomResourceDefinition
V1beta1CRDs []*apiextensionsv1beta1.CustomResourceDefinition

BundleImage string
Csv *operatorsv1alpha1.ClusterServiceVersion
V1beta1crds []*apiextensionsv1beta1.CustomResourceDefinition
V1crds []*apiextensionsv1.CustomResourceDefinition
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
V1crds []*apiextensionsv1.CustomResourceDefinition
V1CRDs []*apiextensionsv1.CustomResourceDefinition

}

decoder := yaml.NewYAMLOrJSONDecoder(fileReader, 30)
csv := unstructured.Unstructured{}
Copy link
Member

Choose a reason for hiding this comment

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

There could be more than one manifest per file.

Copy link
Member Author

Choose a reason for hiding this comment

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

While this is a totally fair point, and one we should address, currently the registry doesn't parse multi manifest yaml files either. IMO if we want to allow them we should update the registry first so that we aren't allowing things that won't work on the unpacking side.

@@ -0,0 +1,13 @@
apiVersion: apiextensions.k8s.io/v1beta1
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 rename pkg/validation/test_data to pkg/validation/testdata?

@@ -0,0 +1,37 @@
package manifests
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps this makes more sense in a metadata package?

return utilerrors.NewAggregate(errs)
}

/*
Copy link
Member

Choose a reason for hiding this comment

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

Is this going away because it's still WIP?

Or is it going away because we now treat the union of CRDs in the bundle and spec.customresourcedefinitions as "provided", so this is less useful?

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 think it is still valid as a validation of the CSV itself to say "Hey you said you provided these APIs, is that actually the case in your bundle?"

My intention was actually that this check should be defined as part of the validation. It seems very weird to do this specifically for this subset when many of the other bundle validations are implemented in the validation package. It only happened initially that way, I assume, because this code was originally embedded into the registry serialization code.

Commenting it out was supposed to remind me to do that, but it seems like I just overlooked it. I'll update this to reimplement it.

// GetManifestsDir parses all bundles and a package manifest from dir, which
// are returned if found along with any errors or warnings encountered while
// parsing/validating found manifests.
func GetManifestsDir(dir string) (registry.PackageManifest, []*registry.Bundle, []errors.ManifestResult) {
Copy link
Member

@estroz estroz May 13, 2020

Choose a reason for hiding this comment

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

This is still something the SDK needs for run packagemanifests. Will a function that returns a PackageManifest and []Bundle exist somewhere else?

Worst case the SDK can implement it, but seeing as the package manifests format will be supported indefinitely and GetBundleFromDir is implemented here, this should probably stick around right?

)

// PackageManifestValidator implements Validator to validate package manifests.
var PackageManifestValidator = internal.PackageManifestValidator
Copy link
Member

Choose a reason for hiding this comment

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

I assume this will be moved to operator-registry, like the bundle validator was? The SDK uses this validator but not the PackageUpdateGraphValidator.

Copy link
Member

@estroz estroz left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label May 20, 2020

var errs []error
bundle := &Bundle{
Name: csvName,
Copy link
Member

Choose a reason for hiding this comment

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

Quick q: would this make more sense as a plain semver string?

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 the future, definitely, especially given the future where a csv is no longer required in future bundle versions. For backwards compatibility though, we need to use this as the unique identifier because version itself is an optional field.

return nil, fmt.Errorf("unsupported CRD version %s for %s", version, f.Name())
}
default:
bundle.Objects = append(bundle.Objects, obj)
Copy link
Member

Choose a reason for hiding this comment

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

One difference I found between this implementation and that in OR: all objects in a bundle, including CSVs and CRDs, are appended to Bundle.Objects. Is it reasonable to have the same behavior here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, yes, it is totally reasonable and the correct behavior. I'll push a change to this pr

@kevinrizza kevinrizza force-pushed the remove-registry-dep branch from 6175388 to 6deb059 Compare May 21, 2020 13:50
@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label May 21, 2020
@estroz
Copy link
Member

estroz commented May 21, 2020

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label May 21, 2020
var PackageManifestValidator interfaces.Validator = interfaces.ValidatorFunc(validatePackageManifests)

func validatePackageManifests(objs ...interface{}) (results []errors.ManifestResult) {
fmt.Println("trying to validate package manifests")
Copy link
Member

Choose a reason for hiding this comment

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

@kevinrizza some leftover print statements

Copy link
Member Author

Choose a reason for hiding this comment

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

ouch, okay updated :)

switch v := obj.(type) {
case *registry.PackageManifest:
case *manifests.PackageManifest:
fmt.Println("found a package manifest in the list of objects")
Copy link
Member

Choose a reason for hiding this comment

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

Here too

* Remove all references to operator-framework/operator-registry
* Update the type serialization and validation to use a new external api
type for operator bundle, which now explicitly parses the public
CRD and CSV types
* Redefine the serialization functions to simply provide the types
without explicitly running validation against them
@kevinrizza kevinrizza force-pushed the remove-registry-dep branch from 6deb059 to eb083ab Compare May 21, 2020 16:16
@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label May 21, 2020
Copy link
Member

@dinhxuanvu dinhxuanvu left a comment

Choose a reason for hiding this comment

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

Looking good but one comment.

version := obj.GetAPIVersion()
if version == apiextensionsv1beta1.SchemeGroupVersion.String() {
crd := apiextensionsv1beta1.CustomResourceDefinition{}
err := runtime.DefaultUnstructuredConverter.FromUnstructured(
Copy link
Member

Choose a reason for hiding this comment

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

This string-to-unstructured-to-crd conversion is the root cause of int64 to float64 error. So we should avoid converting unstructured to a specific type. Should only use unstructured to determine the object type and then convert string data straight to the object type like CRD. See: https://github.com/operator-framework/operator-registry/pull/334/files#diff-b754381164690e8ba263f719136845d3R320

Copy link
Member

Choose a reason for hiding this comment

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

Is this behavior defined for unstructured conversion?

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 this issue can be addressed in a follow-up.

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 fine with fixing this at another time. Please make a note somewhere so it won't get lost.

Copy link
Member

@dinhxuanvu dinhxuanvu left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label May 22, 2020
@kevinrizza kevinrizza merged commit 197407c into operator-framework:master May 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants