Skip to content

Commit 49533b5

Browse files
authored
Bump kind dependency (#2888)
* go.*,vendor: Bump the sigs.k8s.io/kind testing dependency Signed-off-by: Alexander Greene <[email protected]> * Fix deprecated installPlan step resource test Signed-off-by: Alexander Greene <[email protected]> Signed-off-by: Alexander Greene <[email protected]>
1 parent a67c115 commit 49533b5

File tree

22 files changed

+359
-293
lines changed

22 files changed

+359
-293
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ e2e:
146146

147147
# See workflows/e2e-tests.yml See test/e2e/README.md for details.
148148
.PHONY: e2e-local
149-
e2e-local: BUILD_TAGS="json1 experimental_metrics"
149+
e2e-local: BUILD_TAGS="json1 e2e experimental_metrics"
150150
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
151151
e2e-local: run=bin/e2e-local.test
152152
e2e-local: bin/e2e-local.test test/e2e-local.image.tar

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ require (
5353
k8s.io/utils v0.0.0-20220823124924-e9cbc92d1a73
5454
sigs.k8s.io/controller-runtime v0.12.1
5555
sigs.k8s.io/controller-tools v0.8.0
56-
sigs.k8s.io/kind v0.14.0
56+
sigs.k8s.io/kind v0.16.0
5757
)
5858

5959
replace google.golang.org/grpc => google.golang.org/grpc v1.40.0

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -2072,8 +2072,8 @@ sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2/go.mod h1:B+TnT182UBxE84DiCz
20722072
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 h1:iXTIw73aPyC+oRdyqqvVJuloN1p0AC/kzH07hu3NE+k=
20732073
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0=
20742074
sigs.k8s.io/kind v0.11.1/go.mod h1:fRpgVhtqAWrtLB9ED7zQahUimpUXuG/iHT88xYqEGIA=
2075-
sigs.k8s.io/kind v0.14.0 h1:cNmI3jGBvp7UegEGbC5we8plDtCUmaNRL+bod7JoSCE=
2076-
sigs.k8s.io/kind v0.14.0/go.mod h1:UrFRPHG+2a5j0Q7qiR4gtJ4rEyn8TuMQwuOPf+m4oHg=
2075+
sigs.k8s.io/kind v0.16.0 h1:GFXyyxtPnHFKqXr3ZG8/X0+0K9sl69lejStlPn2WQyM=
2076+
sigs.k8s.io/kind v0.16.0/go.mod h1:cKTqagdRyUQmihhBOd+7p43DpOPRn9rHsUC08K1Jbsk=
20772077
sigs.k8s.io/kustomize v2.0.3+incompatible/go.mod h1:MkjgH3RdOWrievjo6c9T245dYlB5QeXV4WCbnt/PEpU=
20782078
sigs.k8s.io/kustomize/api v0.11.4 h1:/0Mr3kfBBNcNPOW5Qwk/3eb8zkswCwnqQxxKtmrTkRo=
20792079
sigs.k8s.io/kustomize/api v0.11.4/go.mod h1:k+8RsqYbgpkIrJ4p9jcdPqe8DprLxFUUO0yNOq8C+xI=

pkg/controller/operators/catalog/operator.go

-30
Original file line numberDiff line numberDiff line change
@@ -2532,33 +2532,3 @@ func (o *Operator) apiresourceFromGVK(gvk schema.GroupVersionKind) (metav1.APIRe
25322532
logger.Info("couldn't find GVK in api discovery")
25332533
return metav1.APIResource{}, olmerrors.GroupVersionKindNotFoundError{Group: gvk.Group, Version: gvk.Version, Kind: gvk.Kind}
25342534
}
2535-
2536-
const (
2537-
PrometheusRuleKind = "PrometheusRule"
2538-
ServiceMonitorKind = "ServiceMonitor"
2539-
PodDisruptionBudgetKind = "PodDisruptionBudget"
2540-
PriorityClassKind = "PriorityClass"
2541-
VerticalPodAutoscalerKind = "VerticalPodAutoscaler"
2542-
ConsoleYAMLSampleKind = "ConsoleYAMLSample"
2543-
ConsoleQuickStartKind = "ConsoleQuickStart"
2544-
ConsoleCLIDownloadKind = "ConsoleCLIDownload"
2545-
ConsoleLinkKind = "ConsoleLink"
2546-
)
2547-
2548-
var supportedKinds = map[string]struct{}{
2549-
PrometheusRuleKind: {},
2550-
ServiceMonitorKind: {},
2551-
PodDisruptionBudgetKind: {},
2552-
PriorityClassKind: {},
2553-
VerticalPodAutoscalerKind: {},
2554-
ConsoleYAMLSampleKind: {},
2555-
ConsoleQuickStartKind: {},
2556-
ConsoleCLIDownloadKind: {},
2557-
ConsoleLinkKind: {},
2558-
}
2559-
2560-
// isSupported returns true if OLM supports this type of CustomResource.
2561-
func isSupported(kind string) bool {
2562-
_, ok := supportedKinds[kind]
2563-
return ok
2564-
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package catalog
2+
3+
const (
4+
PrometheusRuleKind = "PrometheusRule"
5+
ServiceMonitorKind = "ServiceMonitor"
6+
PodDisruptionBudgetKind = "PodDisruptionBudget"
7+
PriorityClassKind = "PriorityClass"
8+
VerticalPodAutoscalerKind = "VerticalPodAutoscaler"
9+
ConsoleYAMLSampleKind = "ConsoleYAMLSample"
10+
ConsoleQuickStartKind = "ConsoleQuickStart"
11+
ConsoleCLIDownloadKind = "ConsoleCLIDownload"
12+
ConsoleLinkKind = "ConsoleLink"
13+
)
14+
15+
var supportedKinds = map[string]struct{}{
16+
PrometheusRuleKind: {},
17+
ServiceMonitorKind: {},
18+
PodDisruptionBudgetKind: {},
19+
PriorityClassKind: {},
20+
VerticalPodAutoscalerKind: {},
21+
ConsoleYAMLSampleKind: {},
22+
ConsoleQuickStartKind: {},
23+
ConsoleCLIDownloadKind: {},
24+
ConsoleLinkKind: {},
25+
}
26+
27+
// isSupported returns true if OLM supports this type of CustomResource.
28+
func isSupported(kind string) bool {
29+
_, ok := supportedKinds[kind]
30+
return ok
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//go:build e2e
2+
3+
package catalog
4+
5+
const (
6+
DeprecatedKind = "Deprecated"
7+
)
8+
9+
func init() {
10+
supportedKinds[DeprecatedKind] = struct{}{}
11+
}

test/e2e/installplan_e2e_test.go

+32-30
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"encoding/json"
77
"errors"
88
"fmt"
9+
"path/filepath"
910
"strconv"
1011
"strings"
1112
"sync"
@@ -20,7 +21,6 @@ import (
2021
appsv1 "k8s.io/api/apps/v1"
2122
authorizationv1 "k8s.io/api/authorization/v1"
2223
corev1 "k8s.io/api/core/v1"
23-
policyv1beta1 "k8s.io/api/policy/v1beta1"
2424
rbacv1 "k8s.io/api/rbac/v1"
2525
"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions"
2626
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
@@ -48,6 +48,11 @@ import (
4848
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/operatorclient"
4949
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/ownerutil"
5050
"github.com/operator-framework/operator-lifecycle-manager/test/e2e/ctx"
51+
"github.com/operator-framework/operator-lifecycle-manager/test/e2e/util"
52+
)
53+
54+
const (
55+
deprecatedCRDDir = "deprecated-crd"
5156
)
5257

5358
var _ = Describe("Install Plan", func() {
@@ -76,11 +81,11 @@ var _ = Describe("Install Plan", func() {
7681

7782
When("an InstallPlan step contains a deprecated resource version", func() {
7883
var (
79-
csv operatorsv1alpha1.ClusterServiceVersion
80-
plan operatorsv1alpha1.InstallPlan
81-
pdb policyv1beta1.PodDisruptionBudget
82-
manifest string
83-
counter float64
84+
csv operatorsv1alpha1.ClusterServiceVersion
85+
plan operatorsv1alpha1.InstallPlan
86+
deprecated client.Object
87+
manifest string
88+
counter float64
8489
)
8590

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

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

@@ -107,26 +107,21 @@ var _ = Describe("Install Plan", func() {
107107
counter = metric.Value
108108
}
109109
}
110+
deprecatedCRD, err := util.DecodeFile(filepath.Join(testdataDir, deprecatedCRDDir, "deprecated.crd.yaml"), &apiextensionsv1.CustomResourceDefinition{})
111+
Expect(err).NotTo(HaveOccurred())
112+
113+
Expect(ctx.Ctx().Client().Create(context.Background(), deprecatedCRD)).To(Succeed())
110114

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

114-
pdb = policyv1beta1.PodDisruptionBudget{
115-
ObjectMeta: metav1.ObjectMeta{
116-
Name: genName("test-pdb-"),
117-
},
118-
TypeMeta: metav1.TypeMeta{
119-
Kind: "PodDisruptionBudget",
120-
APIVersion: policyv1beta1.SchemeGroupVersion.String(),
121-
},
122-
Spec: policyv1beta1.PodDisruptionBudgetSpec{},
123-
}
118+
deprecated, err = util.DecodeFile(filepath.Join(testdataDir, deprecatedCRDDir, "deprecated.cr.yaml"), &unstructured.Unstructured{}, util.WithNamespace(ns.GetName()))
119+
Expect(err).NotTo(HaveOccurred())
124120

125121
scheme := runtime.NewScheme()
126-
Expect(policyv1beta1.AddToScheme(scheme)).To(Succeed())
127122
{
128123
var b bytes.Buffer
129-
Expect(k8sjson.NewSerializer(k8sjson.DefaultMetaFactory, scheme, scheme, false).Encode(&pdb, &b)).To(Succeed())
124+
Expect(k8sjson.NewSerializer(k8sjson.DefaultMetaFactory, scheme, scheme, false).Encode(deprecated, &b)).To(Succeed())
130125
manifest = b.String()
131126
}
132127

@@ -150,9 +145,9 @@ var _ = Describe("Install Plan", func() {
150145
Resolving: csv.GetName(),
151146
Status: operatorsv1alpha1.StepStatusUnknown,
152147
Resource: operatorsv1alpha1.StepResource{
153-
Name: pdb.GetName(),
154-
Version: pdb.APIVersion,
155-
Kind: pdb.Kind,
148+
Name: deprecated.GetName(),
149+
Version: "v1",
150+
Kind: "Deprecated",
156151
Manifest: manifest,
157152
},
158153
},
@@ -168,6 +163,14 @@ var _ = Describe("Install Plan", func() {
168163
Eventually(func() error {
169164
return client.IgnoreNotFound(ctx.Ctx().Client().Delete(context.Background(), &csv))
170165
}).Should(Succeed())
166+
Eventually(func() error {
167+
deprecatedCRD := &apiextensionsv1.CustomResourceDefinition{
168+
ObjectMeta: metav1.ObjectMeta{
169+
Name: "deprecateds.operators.io.operator-framework",
170+
},
171+
}
172+
return client.IgnoreNotFound(ctx.Ctx().Client().Delete(context.Background(), deprecatedCRD))
173+
}).Should(Succeed())
171174
})
172175

173176
It("creates an Event surfacing the deprecation warning", func() {
@@ -200,9 +203,8 @@ var _ = Describe("Install Plan", func() {
200203
FieldPath: "status.plan[0]",
201204
},
202205
Reason: "AppliedWithWarnings",
203-
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()),
206+
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()),
204207
}))
205-
206208
})
207209

208210
It("increments a metric counting the warning", func() {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
apiVersion: operators.io.operator-framework/v1
2+
kind: Deprecated
3+
metadata:
4+
namespace: placeholder
5+
name: foo
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
apiVersion: apiextensions.k8s.io/v1
2+
kind: CustomResourceDefinition
3+
metadata:
4+
annotations:
5+
e2e.testName: Install Plan when an InstallPlan step contains a deprecated resource
6+
version increments a metric counting the warning
7+
name: deprecateds.operators.io.operator-framework
8+
spec:
9+
conversion:
10+
strategy: None
11+
group: operators.io.operator-framework
12+
names:
13+
kind: Deprecated
14+
listKind: DeprecatedList
15+
plural: deprecateds
16+
singular: deprecated
17+
scope: Namespaced
18+
versions:
19+
- deprecated: true
20+
name: v1
21+
schema:
22+
openAPIV3Schema:
23+
properties:
24+
spec:
25+
description: Spec of a test object.
26+
properties:
27+
foo:
28+
type: string
29+
type: object
30+
status:
31+
description: Spec of a test object.
32+
type: object
33+
type: object
34+
served: true
35+
storage: true

test/e2e/util/decode.go

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package util
2+
3+
import (
4+
"os"
5+
"strings"
6+
7+
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/controller-runtime/client"
8+
utilyaml "k8s.io/apimachinery/pkg/util/yaml"
9+
)
10+
11+
type clientObjectOption func(client.Object)
12+
13+
func WithNamespace(namespace string) clientObjectOption {
14+
return func(obj client.Object) {
15+
obj.SetNamespace(namespace)
16+
}
17+
}
18+
19+
func DecodeFile(file string, to client.Object, options ...clientObjectOption) (client.Object, error) {
20+
manifest, err := yamlFromFilePath(file)
21+
if err != nil {
22+
return nil, err
23+
}
24+
dec := utilyaml.NewYAMLOrJSONDecoder(strings.NewReader(manifest), 10)
25+
if err := dec.Decode(to); err != nil {
26+
return nil, err
27+
}
28+
29+
return to, nil
30+
}
31+
32+
func yamlFromFilePath(fileName string) (string, error) {
33+
yaml, err := os.ReadFile(fileName)
34+
return string(yaml), err
35+
}

vendor/modules.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -2001,7 +2001,7 @@ sigs.k8s.io/controller-tools/pkg/webhook
20012001
## explicit; go 1.18
20022002
sigs.k8s.io/json
20032003
sigs.k8s.io/json/internal/golang/encoding/json
2004-
# sigs.k8s.io/kind v0.14.0
2004+
# sigs.k8s.io/kind v0.16.0
20052005
## explicit; go 1.14
20062006
sigs.k8s.io/kind/pkg/apis/config/defaults
20072007
sigs.k8s.io/kind/pkg/apis/config/v1alpha4

vendor/sigs.k8s.io/kind/pkg/apis/config/defaults/image.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)