Skip to content

Bump kind dependency #2888

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ e2e:

# See workflows/e2e-tests.yml See test/e2e/README.md for details.
.PHONY: e2e-local
e2e-local: BUILD_TAGS="json1 experimental_metrics"
e2e-local: BUILD_TAGS="json1 e2e experimental_metrics"
e2e-local: extra_args=-kind.images=../test/e2e-local.image.tar -test-data-dir=../test/e2e/testdata -gather-artifacts-script-path=../test/e2e/collect-ci-artifacts.sh
e2e-local: run=bin/e2e-local.test
e2e-local: bin/e2e-local.test test/e2e-local.image.tar
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ require (
k8s.io/utils v0.0.0-20220823124924-e9cbc92d1a73
sigs.k8s.io/controller-runtime v0.12.1
sigs.k8s.io/controller-tools v0.8.0
sigs.k8s.io/kind v0.14.0
sigs.k8s.io/kind v0.16.0
)

replace google.golang.org/grpc => google.golang.org/grpc v1.40.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2072,8 +2072,8 @@ sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2/go.mod h1:B+TnT182UBxE84DiCz
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 h1:iXTIw73aPyC+oRdyqqvVJuloN1p0AC/kzH07hu3NE+k=
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0=
sigs.k8s.io/kind v0.11.1/go.mod h1:fRpgVhtqAWrtLB9ED7zQahUimpUXuG/iHT88xYqEGIA=
sigs.k8s.io/kind v0.14.0 h1:cNmI3jGBvp7UegEGbC5we8plDtCUmaNRL+bod7JoSCE=
sigs.k8s.io/kind v0.14.0/go.mod h1:UrFRPHG+2a5j0Q7qiR4gtJ4rEyn8TuMQwuOPf+m4oHg=
sigs.k8s.io/kind v0.16.0 h1:GFXyyxtPnHFKqXr3ZG8/X0+0K9sl69lejStlPn2WQyM=
sigs.k8s.io/kind v0.16.0/go.mod h1:cKTqagdRyUQmihhBOd+7p43DpOPRn9rHsUC08K1Jbsk=
sigs.k8s.io/kustomize v2.0.3+incompatible/go.mod h1:MkjgH3RdOWrievjo6c9T245dYlB5QeXV4WCbnt/PEpU=
sigs.k8s.io/kustomize/api v0.11.4 h1:/0Mr3kfBBNcNPOW5Qwk/3eb8zkswCwnqQxxKtmrTkRo=
sigs.k8s.io/kustomize/api v0.11.4/go.mod h1:k+8RsqYbgpkIrJ4p9jcdPqe8DprLxFUUO0yNOq8C+xI=
Expand Down
30 changes: 0 additions & 30 deletions pkg/controller/operators/catalog/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -2532,33 +2532,3 @@ func (o *Operator) apiresourceFromGVK(gvk schema.GroupVersionKind) (metav1.APIRe
logger.Info("couldn't find GVK in api discovery")
return metav1.APIResource{}, olmerrors.GroupVersionKindNotFoundError{Group: gvk.Group, Version: gvk.Version, Kind: gvk.Kind}
}

const (
PrometheusRuleKind = "PrometheusRule"
ServiceMonitorKind = "ServiceMonitor"
PodDisruptionBudgetKind = "PodDisruptionBudget"
PriorityClassKind = "PriorityClass"
VerticalPodAutoscalerKind = "VerticalPodAutoscaler"
ConsoleYAMLSampleKind = "ConsoleYAMLSample"
ConsoleQuickStartKind = "ConsoleQuickStart"
ConsoleCLIDownloadKind = "ConsoleCLIDownload"
ConsoleLinkKind = "ConsoleLink"
)

var supportedKinds = map[string]struct{}{
PrometheusRuleKind: {},
ServiceMonitorKind: {},
PodDisruptionBudgetKind: {},
PriorityClassKind: {},
VerticalPodAutoscalerKind: {},
ConsoleYAMLSampleKind: {},
ConsoleQuickStartKind: {},
ConsoleCLIDownloadKind: {},
ConsoleLinkKind: {},
}

// isSupported returns true if OLM supports this type of CustomResource.
func isSupported(kind string) bool {
_, ok := supportedKinds[kind]
return ok
}
31 changes: 31 additions & 0 deletions pkg/controller/operators/catalog/supportedresources.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package catalog

const (
PrometheusRuleKind = "PrometheusRule"
ServiceMonitorKind = "ServiceMonitor"
PodDisruptionBudgetKind = "PodDisruptionBudget"
PriorityClassKind = "PriorityClass"
VerticalPodAutoscalerKind = "VerticalPodAutoscaler"
ConsoleYAMLSampleKind = "ConsoleYAMLSample"
ConsoleQuickStartKind = "ConsoleQuickStart"
ConsoleCLIDownloadKind = "ConsoleCLIDownload"
ConsoleLinkKind = "ConsoleLink"
)

var supportedKinds = map[string]struct{}{
PrometheusRuleKind: {},
ServiceMonitorKind: {},
PodDisruptionBudgetKind: {},
PriorityClassKind: {},
VerticalPodAutoscalerKind: {},
ConsoleYAMLSampleKind: {},
ConsoleQuickStartKind: {},
ConsoleCLIDownloadKind: {},
ConsoleLinkKind: {},
}

// isSupported returns true if OLM supports this type of CustomResource.
func isSupported(kind string) bool {
_, ok := supportedKinds[kind]
return ok
}
11 changes: 11 additions & 0 deletions pkg/controller/operators/catalog/supportedresourcesoveride.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//go:build e2e

package catalog

const (
DeprecatedKind = "Deprecated"
)

func init() {
supportedKinds[DeprecatedKind] = struct{}{}
}
62 changes: 32 additions & 30 deletions test/e2e/installplan_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"encoding/json"
"errors"
"fmt"
"path/filepath"
"strconv"
"strings"
"sync"
Expand All @@ -20,7 +21,6 @@ import (
appsv1 "k8s.io/api/apps/v1"
authorizationv1 "k8s.io/api/authorization/v1"
corev1 "k8s.io/api/core/v1"
policyv1beta1 "k8s.io/api/policy/v1beta1"
rbacv1 "k8s.io/api/rbac/v1"
"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions"
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
Expand Down Expand Up @@ -48,6 +48,11 @@ import (
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/operatorclient"
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/ownerutil"
"github.com/operator-framework/operator-lifecycle-manager/test/e2e/ctx"
"github.com/operator-framework/operator-lifecycle-manager/test/e2e/util"
)

const (
deprecatedCRDDir = "deprecated-crd"
)

var _ = Describe("Install Plan", func() {
Expand Down Expand Up @@ -76,11 +81,11 @@ var _ = Describe("Install Plan", func() {

When("an InstallPlan step contains a deprecated resource version", func() {
var (
csv operatorsv1alpha1.ClusterServiceVersion
plan operatorsv1alpha1.InstallPlan
pdb policyv1beta1.PodDisruptionBudget
manifest string
counter float64
csv operatorsv1alpha1.ClusterServiceVersion
plan operatorsv1alpha1.InstallPlan
deprecated client.Object
manifest string
counter float64
)

BeforeEach(func() {
Expand All @@ -90,13 +95,8 @@ var _ = Describe("Install Plan", func() {
v, err := dc.ServerVersion()
Expect(err).ToNot(HaveOccurred())

if minor, err := strconv.Atoi(v.Minor); err == nil && minor < 21 {
// This is a tactical can-kick with
// the expectation that the
// event-emitting behavior being
// tested in this context will have
// moved by the time 1.25 arrives.
Skip("hack: test is dependent on 1.21+ behavior")
if minor, err := strconv.Atoi(v.Minor); err == nil && minor < 16 {
Skip("test is dependent on CRD v1 introduced at 1.16")
}
})

Expand All @@ -107,26 +107,21 @@ var _ = Describe("Install Plan", func() {
counter = metric.Value
}
}
deprecatedCRD, err := util.DecodeFile(filepath.Join(testdataDir, deprecatedCRDDir, "deprecated.crd.yaml"), &apiextensionsv1.CustomResourceDefinition{})
Expect(err).NotTo(HaveOccurred())

Expect(ctx.Ctx().Client().Create(context.Background(), deprecatedCRD)).To(Succeed())

csv = newCSV(genName("test-csv-"), ns.GetName(), "", semver.Version{}, nil, nil, nil)
Expect(ctx.Ctx().Client().Create(context.Background(), &csv)).To(Succeed())

pdb = policyv1beta1.PodDisruptionBudget{
ObjectMeta: metav1.ObjectMeta{
Name: genName("test-pdb-"),
},
TypeMeta: metav1.TypeMeta{
Kind: "PodDisruptionBudget",
APIVersion: policyv1beta1.SchemeGroupVersion.String(),
},
Spec: policyv1beta1.PodDisruptionBudgetSpec{},
}
deprecated, err = util.DecodeFile(filepath.Join(testdataDir, deprecatedCRDDir, "deprecated.cr.yaml"), &unstructured.Unstructured{}, util.WithNamespace(ns.GetName()))
Expect(err).NotTo(HaveOccurred())

scheme := runtime.NewScheme()
Expect(policyv1beta1.AddToScheme(scheme)).To(Succeed())
{
var b bytes.Buffer
Expect(k8sjson.NewSerializer(k8sjson.DefaultMetaFactory, scheme, scheme, false).Encode(&pdb, &b)).To(Succeed())
Expect(k8sjson.NewSerializer(k8sjson.DefaultMetaFactory, scheme, scheme, false).Encode(deprecated, &b)).To(Succeed())
manifest = b.String()
}

Expand All @@ -150,9 +145,9 @@ var _ = Describe("Install Plan", func() {
Resolving: csv.GetName(),
Status: operatorsv1alpha1.StepStatusUnknown,
Resource: operatorsv1alpha1.StepResource{
Name: pdb.GetName(),
Version: pdb.APIVersion,
Kind: pdb.Kind,
Name: deprecated.GetName(),
Version: "v1",
Kind: "Deprecated",
Manifest: manifest,
},
},
Expand All @@ -168,6 +163,14 @@ var _ = Describe("Install Plan", func() {
Eventually(func() error {
return client.IgnoreNotFound(ctx.Ctx().Client().Delete(context.Background(), &csv))
}).Should(Succeed())
Eventually(func() error {
deprecatedCRD := &apiextensionsv1.CustomResourceDefinition{
ObjectMeta: metav1.ObjectMeta{
Name: "deprecateds.operators.io.operator-framework",
},
}
return client.IgnoreNotFound(ctx.Ctx().Client().Delete(context.Background(), deprecatedCRD))
}).Should(Succeed())
})

It("creates an Event surfacing the deprecation warning", func() {
Expand Down Expand Up @@ -200,9 +203,8 @@ var _ = Describe("Install Plan", func() {
FieldPath: "status.plan[0]",
},
Reason: "AppliedWithWarnings",
Message: fmt.Sprintf("1 warning(s) generated during installation of operator \"%s\" (PodDisruptionBudget \"%s\"): policy/v1beta1 PodDisruptionBudget is deprecated in v1.21+, unavailable in v1.25+; use policy/v1 PodDisruptionBudget", csv.GetName(), pdb.GetName()),
Message: fmt.Sprintf("1 warning(s) generated during installation of operator \"%s\" (Deprecated \"%s\"): operators.io.operator-framework/v1 Deprecated is deprecated", csv.GetName(), deprecated.GetName()),
}))

})

It("increments a metric counting the warning", func() {
Expand Down
5 changes: 5 additions & 0 deletions test/e2e/testdata/deprecated-crd/deprecated.cr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: operators.io.operator-framework/v1
kind: Deprecated
metadata:
namespace: placeholder
name: foo
35 changes: 35 additions & 0 deletions test/e2e/testdata/deprecated-crd/deprecated.crd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
e2e.testName: Install Plan when an InstallPlan step contains a deprecated resource
version increments a metric counting the warning
name: deprecateds.operators.io.operator-framework
spec:
conversion:
strategy: None
group: operators.io.operator-framework
names:
kind: Deprecated
listKind: DeprecatedList
plural: deprecateds
singular: deprecated
scope: Namespaced
versions:
- deprecated: true
name: v1
schema:
openAPIV3Schema:
properties:
spec:
description: Spec of a test object.
properties:
foo:
type: string
type: object
status:
description: Spec of a test object.
type: object
type: object
served: true
storage: true
35 changes: 35 additions & 0 deletions test/e2e/util/decode.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package util

import (
"os"
"strings"

"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/controller-runtime/client"
utilyaml "k8s.io/apimachinery/pkg/util/yaml"
)

type clientObjectOption func(client.Object)

func WithNamespace(namespace string) clientObjectOption {
return func(obj client.Object) {
obj.SetNamespace(namespace)
}
}

func DecodeFile(file string, to client.Object, options ...clientObjectOption) (client.Object, error) {
manifest, err := yamlFromFilePath(file)
if err != nil {
return nil, err
}
dec := utilyaml.NewYAMLOrJSONDecoder(strings.NewReader(manifest), 10)
if err := dec.Decode(to); err != nil {
return nil, err
}

return to, nil
}

func yamlFromFilePath(fileName string) (string, error) {
yaml, err := os.ReadFile(fileName)
return string(yaml), err
}
2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2001,7 +2001,7 @@ sigs.k8s.io/controller-tools/pkg/webhook
## explicit; go 1.18
sigs.k8s.io/json
sigs.k8s.io/json/internal/golang/encoding/json
# sigs.k8s.io/kind v0.14.0
# sigs.k8s.io/kind v0.16.0
## explicit; go 1.14
sigs.k8s.io/kind/pkg/apis/config/defaults
sigs.k8s.io/kind/pkg/apis/config/v1alpha4
Expand Down
2 changes: 1 addition & 1 deletion vendor/sigs.k8s.io/kind/pkg/apis/config/defaults/image.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading