Skip to content

Commit 1550bc4

Browse files
Merge pull request #648 from tmshort/synchronize
NO-ISSUE: Synchronize From Upstream Repositories
2 parents 86d68ab + b9377ae commit 1550bc4

11 files changed

Lines changed: 106 additions & 37 deletions

File tree

commitchecker.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
expectedMergeBase: dfd25de92909f8a72869cfd0b1377b4fd524df8c
1+
expectedMergeBase: 25704ad1e1d3dd9029d01b918829850f7139a63a
22
upstreamBranch: main
33
upstreamOrg: operator-framework
44
upstreamRepo: operator-controller

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/operator-framework/operator-controller
22

3-
go 1.25.3
3+
go 1.25.7
44

55
require (
66
github.com/BurntSushi/toml v1.6.0

hack/kind-config/containerd/certs.d/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module hack-cert.d
22

3-
go 1.25.3
3+
go 1.25.7
44

55
// This file is present in the certs.d directory to ensure that
66
// certs.d/host:port directories are not included in the main go

internal/operator-controller/rukpak/render/registryv1/registryv1.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ var BundleValidator = render.BundleValidator{
2929
validators.CheckConversionWebhookCRDReferenceUniqueness,
3030
validators.CheckConversionWebhooksReferenceOwnedCRDs,
3131
validators.CheckWebhookRules,
32+
validators.CheckObjectSupport,
3233
}
3334

3435
// ResourceGenerators a slice of ResourceGenerators required to generate plain resource manifests for

internal/operator-controller/rukpak/render/registryv1/registryv1_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ func Test_BundleValidatorHasAllValidationFns(t *testing.T) {
3434
validators.CheckConversionWebhookCRDReferenceUniqueness,
3535
validators.CheckConversionWebhooksReferenceOwnedCRDs,
3636
validators.CheckWebhookRules,
37+
validators.CheckObjectSupport,
3738
}
3839
actualValidationFns := registryv1.BundleValidator
3940

internal/operator-controller/rukpak/render/registryv1/validators/validator.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"k8s.io/apimachinery/pkg/util/validation"
1313

1414
"github.com/operator-framework/api/pkg/operators/v1alpha1"
15+
regv1bundle "github.com/operator-framework/operator-registry/pkg/lib/bundle"
1516

1617
"github.com/operator-framework/operator-controller/internal/operator-controller/rukpak/bundle"
1718
)
@@ -348,3 +349,16 @@ func CheckWebhookRules(rv1 *bundle.RegistryV1) []error {
348349
}
349350
return errs
350351
}
352+
353+
// CheckObjectSupport checks that the non-CRD and non-CSV bundle objects are supported by the
354+
// registry+v1 standard
355+
func CheckObjectSupport(rv1 *bundle.RegistryV1) []error {
356+
var errs []error
357+
for _, obj := range rv1.Others {
358+
kind := obj.GetObjectKind().GroupVersionKind().Kind
359+
if ok, _ := regv1bundle.IsSupported(kind); !ok {
360+
errs = append(errs, fmt.Errorf("unsupported resource %q with kind %q", obj.GetName(), kind))
361+
}
362+
}
363+
return errs
364+
}

internal/operator-controller/rukpak/render/registryv1/validators/validator_test.go

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import (
88
admissionregistrationv1 "k8s.io/api/admissionregistration/v1"
99
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
1010
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
11+
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
12+
"k8s.io/apimachinery/pkg/runtime/schema"
1113

1214
"github.com/operator-framework/api/pkg/operators/v1alpha1"
1315

@@ -1171,3 +1173,82 @@ func Test_CheckWebhookNameIsDNS1123SubDomain(t *testing.T) {
11711173
})
11721174
}
11731175
}
1176+
1177+
func newUnstructuredObject(gvk schema.GroupVersionKind, name string) unstructured.Unstructured {
1178+
obj := unstructured.Unstructured{}
1179+
obj.SetGroupVersionKind(gvk)
1180+
obj.SetName(name)
1181+
return obj
1182+
}
1183+
1184+
func Test_CheckObjectSupport(t *testing.T) {
1185+
for _, tc := range []struct {
1186+
name string
1187+
bundle *bundle.RegistryV1
1188+
expectedErrs []error
1189+
}{
1190+
{
1191+
name: "accepts bundles with no other objects",
1192+
bundle: &bundle.RegistryV1{},
1193+
expectedErrs: nil,
1194+
},
1195+
{
1196+
name: "accepts bundles with supported object kinds",
1197+
bundle: &bundle.RegistryV1{
1198+
Others: []unstructured.Unstructured{
1199+
newUnstructuredObject(schema.GroupVersionKind{Group: "", Version: "v1", Kind: "Secret"}, "my-secret"),
1200+
newUnstructuredObject(schema.GroupVersionKind{Group: "", Version: "v1", Kind: "ConfigMap"}, "my-configmap"),
1201+
newUnstructuredObject(schema.GroupVersionKind{Group: "", Version: "v1", Kind: "ServiceAccount"}, "my-sa"),
1202+
newUnstructuredObject(schema.GroupVersionKind{Group: "", Version: "v1", Kind: "Service"}, "my-service"),
1203+
newUnstructuredObject(schema.GroupVersionKind{Group: "rbac.authorization.k8s.io", Version: "v1", Kind: "ClusterRole"}, "my-clusterrole"),
1204+
newUnstructuredObject(schema.GroupVersionKind{Group: "rbac.authorization.k8s.io", Version: "v1", Kind: "ClusterRoleBinding"}, "my-clusterrolebinding"),
1205+
newUnstructuredObject(schema.GroupVersionKind{Group: "rbac.authorization.k8s.io", Version: "v1", Kind: "Role"}, "my-role"),
1206+
newUnstructuredObject(schema.GroupVersionKind{Group: "rbac.authorization.k8s.io", Version: "v1", Kind: "RoleBinding"}, "my-rolebinding"),
1207+
},
1208+
},
1209+
expectedErrs: nil,
1210+
},
1211+
{
1212+
name: "rejects bundles with unsupported object kinds",
1213+
bundle: &bundle.RegistryV1{
1214+
Others: []unstructured.Unstructured{
1215+
newUnstructuredObject(schema.GroupVersionKind{Group: "apps", Version: "v1", Kind: "Deployment"}, "my-deployment"),
1216+
},
1217+
},
1218+
expectedErrs: []error{
1219+
errors.New(`unsupported resource "my-deployment" with kind "Deployment"`),
1220+
},
1221+
},
1222+
{
1223+
name: "reports errors for each unsupported object",
1224+
bundle: &bundle.RegistryV1{
1225+
Others: []unstructured.Unstructured{
1226+
newUnstructuredObject(schema.GroupVersionKind{Group: "apps", Version: "v1", Kind: "Deployment"}, "my-deployment"),
1227+
newUnstructuredObject(schema.GroupVersionKind{Group: "apps", Version: "v1", Kind: "StatefulSet"}, "my-statefulset"),
1228+
},
1229+
},
1230+
expectedErrs: []error{
1231+
errors.New(`unsupported resource "my-deployment" with kind "Deployment"`),
1232+
errors.New(`unsupported resource "my-statefulset" with kind "StatefulSet"`),
1233+
},
1234+
},
1235+
{
1236+
name: "accepts supported objects and rejects unsupported objects in the same bundle",
1237+
bundle: &bundle.RegistryV1{
1238+
Others: []unstructured.Unstructured{
1239+
newUnstructuredObject(schema.GroupVersionKind{Group: "", Version: "v1", Kind: "ConfigMap"}, "my-configmap"),
1240+
newUnstructuredObject(schema.GroupVersionKind{Group: "batch", Version: "v1", Kind: "Job"}, "my-job"),
1241+
newUnstructuredObject(schema.GroupVersionKind{Group: "", Version: "v1", Kind: "Secret"}, "my-secret"),
1242+
},
1243+
},
1244+
expectedErrs: []error{
1245+
errors.New(`unsupported resource "my-job" with kind "Job"`),
1246+
},
1247+
},
1248+
} {
1249+
t.Run(tc.name, func(t *testing.T) {
1250+
errs := validators.CheckObjectSupport(tc.bundle)
1251+
require.Equal(t, tc.expectedErrs, errs)
1252+
})
1253+
}
1254+
}

openshift/tests-extension/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/openshift/operator-framework-operator-controller/openshift/tests-extension
22

3-
go 1.25.3
3+
go 1.25.7
44

55
require (
66
github.com/blang/semver/v4 v4.0.0

openshift/tests-extension/test/olmv1-catalog.go

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111

1212
batchv1 "k8s.io/api/batch/v1"
1313
corev1 "k8s.io/api/core/v1"
14-
apierrors "k8s.io/apimachinery/pkg/api/errors"
1514
"k8s.io/apimachinery/pkg/api/meta"
1615
"k8s.io/apimachinery/pkg/api/resource"
1716
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -77,38 +76,12 @@ func verifyCatalogEndpoint(ctx SpecContext, catalog, endpoint, query string) {
7776
strings.ReplaceAll(endpoint, "?", ""),
7877
strings.ReplaceAll(catalog, "-", ""))
7978

80-
// create service account object
81-
serviceAccount := &corev1.ServiceAccount{
82-
ObjectMeta: metav1.ObjectMeta{
83-
Name: jobNamePrefix,
84-
Namespace: "default",
85-
},
86-
}
87-
88-
err = k8sClient.Create(ctx, serviceAccount)
89-
90-
Expect(err).To(Or(BeNil(), Satisfy(apierrors.IsAlreadyExists)),
91-
"Failed to ensure ServiceAccount %s", jobNamePrefix)
92-
93-
DeferCleanup(func(ctx SpecContext) {
94-
_ = k8sClient.Delete(ctx, serviceAccount)
95-
})
96-
97-
job := buildCurlJob(jobNamePrefix, "default", serviceURL, serviceAccount)
98-
79+
job := buildCurlJob(jobNamePrefix, "default", serviceURL)
9980
err = k8sClient.Create(ctx, job)
10081
Expect(err).NotTo(HaveOccurred(), "failed to create Job")
10182

10283
DeferCleanup(func(ctx SpecContext) {
10384
_ = k8sClient.Delete(ctx, job)
104-
// We poll for deletion success so that the cleanup succeeds only when
105-
// the job is deleted. Then, we can move onto deleting the service
106-
// account without issue.
107-
Eventually(func(g Gomega) {
108-
recheck := &batchv1.Job{}
109-
err := k8sClient.Get(ctx, client.ObjectKeyFromObject(job), recheck)
110-
g.Expect(apierrors.IsNotFound(err)).To(BeTrue(), fmt.Sprintf("Job %v should be deleted", job.Name))
111-
}).WithTimeout(helpers.DefaultTimeout).WithPolling(helpers.DefaultPolling).Should(Succeed())
11285
})
11386

11487
By("Waiting for Job to succeed")
@@ -230,7 +203,7 @@ var _ = Describe("[sig-olmv1][OCPFeatureGate:NewOLM][Skipped:Disconnected] OLMv1
230203
})
231204
})
232205

233-
func buildCurlJob(prefix, namespace, url string, serviceAccount *corev1.ServiceAccount) *batchv1.Job {
206+
func buildCurlJob(prefix, namespace, url string) *batchv1.Job {
234207
backoff := int32(1)
235208
// This means the k8s garbage collector will automatically delete the job 5 minutes
236209
// after it has completed or failed.
@@ -259,8 +232,7 @@ func buildCurlJob(prefix, namespace, url string, serviceAccount *corev1.ServiceA
259232
BackoffLimit: &backoff,
260233
Template: corev1.PodTemplateSpec{
261234
Spec: corev1.PodSpec{
262-
ServiceAccountName: serviceAccount.Name,
263-
RestartPolicy: corev1.RestartPolicyNever,
235+
RestartPolicy: corev1.RestartPolicyNever,
264236
Containers: []corev1.Container{{
265237
Name: "api-tester",
266238
Image: "registry.redhat.io/rhel8/httpd-24:latest",

openshift/tests-extension/vendor/modules.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ github.com/openshift/client-go/user/clientset/versioned/typed/user/v1
282282
## explicit; go 1.24.0
283283
github.com/openshift/origin/test/extended/util/image
284284
# github.com/operator-framework/operator-controller v1.5.1 => ../../
285-
## explicit; go 1.25.3
285+
## explicit; go 1.25.7
286286
github.com/operator-framework/operator-controller/api/v1
287287
# github.com/pborman/uuid v1.2.1
288288
## explicit

0 commit comments

Comments
 (0)