Skip to content

Commit 18aa3be

Browse files
authored
Merge pull request openshift#627 from openshift-bot/synchronize-upstream
NO-ISSUE: Synchronize From Upstream Repositories
2 parents 844fc22 + 62087f0 commit 18aa3be

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+198
-1031
lines changed

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ require (
8585
github.com/felixge/httpsnoop v1.0.3 // indirect
8686
github.com/fsnotify/fsnotify v1.6.0 // indirect
8787
github.com/fvbommel/sortorder v1.0.1 // indirect
88-
github.com/ghodss/yaml v1.0.0 // indirect
8988
github.com/go-air/gini v1.0.4 // indirect
9089
github.com/go-errors/errors v1.4.2 // indirect
9190
github.com/go-git/gcfg v1.5.0 // indirect

manifests/0000_50_olm_07-olm-operator.deployment.ibm-cloud-managed.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ metadata:
1010
capability.openshift.io/name: "OperatorLifecycleManager"
1111
spec:
1212
strategy:
13-
type: RollingUpdate
13+
type: Recreate
1414
replicas: 1
1515
selector:
1616
matchLabels:

manifests/0000_50_olm_07-olm-operator.deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ metadata:
1010
capability.openshift.io/name: "OperatorLifecycleManager"
1111
spec:
1212
strategy:
13-
type: RollingUpdate
13+
type: Recreate
1414
replicas: 1
1515
selector:
1616
matchLabels:

manifests/0000_50_olm_08-catalog-operator.deployment.ibm-cloud-managed.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ metadata:
1010
capability.openshift.io/name: "OperatorLifecycleManager"
1111
spec:
1212
strategy:
13-
type: RollingUpdate
13+
type: Recreate
1414
replicas: 1
1515
selector:
1616
matchLabels:

manifests/0000_50_olm_08-catalog-operator.deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ metadata:
1010
capability.openshift.io/name: "OperatorLifecycleManager"
1111
spec:
1212
strategy:
13-
type: RollingUpdate
13+
type: Recreate
1414
replicas: 1
1515
selector:
1616
matchLabels:

microshift-manifests/0000_50_olm_07-olm-operator.deployment.ibm-cloud-managed.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ metadata:
1010
capability.openshift.io/name: "OperatorLifecycleManager"
1111
spec:
1212
strategy:
13-
type: RollingUpdate
13+
type: Recreate
1414
replicas: 1
1515
selector:
1616
matchLabels:

microshift-manifests/0000_50_olm_07-olm-operator.deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ metadata:
1010
capability.openshift.io/name: "OperatorLifecycleManager"
1111
spec:
1212
strategy:
13-
type: RollingUpdate
13+
type: Recreate
1414
replicas: 1
1515
selector:
1616
matchLabels:

microshift-manifests/0000_50_olm_08-catalog-operator.deployment.ibm-cloud-managed.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ metadata:
1010
capability.openshift.io/name: "OperatorLifecycleManager"
1111
spec:
1212
strategy:
13-
type: RollingUpdate
13+
type: Recreate
1414
replicas: 1
1515
selector:
1616
matchLabels:

microshift-manifests/0000_50_olm_08-catalog-operator.deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ metadata:
1010
capability.openshift.io/name: "OperatorLifecycleManager"
1111
spec:
1212
strategy:
13-
type: RollingUpdate
13+
type: Recreate
1414
replicas: 1
1515
selector:
1616
matchLabels:

staging/operator-lifecycle-manager/deploy/chart/templates/0000_50_olm_07-olm-operator.deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ metadata:
77
app: olm-operator
88
spec:
99
strategy:
10-
type: RollingUpdate
10+
type: Recreate
1111
replicas: {{ .Values.olm.replicaCount }}
1212
selector:
1313
matchLabels:

staging/operator-lifecycle-manager/deploy/chart/templates/0000_50_olm_08-catalog-operator.deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ metadata:
77
app: catalog-operator
88
spec:
99
strategy:
10-
type: RollingUpdate
10+
type: Recreate
1111
replicas: {{ .Values.catalog.replicaCount }}
1212
selector:
1313
matchLabels:

staging/operator-lifecycle-manager/pkg/controller/operators/catalog/operator.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -581,11 +581,20 @@ func NewOperator(ctx context.Context, kubeconfigPath string, clock utilclock.Clo
581581
sharedIndexInformers = append(sharedIndexInformers, buPodInformer.Informer())
582582

583583
// Wire ConfigMaps
584-
configMapInformer := informers.NewSharedInformerFactoryWithOptions(op.opClient.KubernetesInterface(), resyncPeriod(), informers.WithTweakListOptions(func(options *metav1.ListOptions) {
585-
options.LabelSelector = install.OLMManagedLabelKey
586-
})).Core().V1().ConfigMaps()
584+
configMapInformer := k8sInformerFactory.Core().V1().ConfigMaps()
587585
op.lister.CoreV1().RegisterConfigMapLister(metav1.NamespaceAll, configMapInformer.Lister())
588586
sharedIndexInformers = append(sharedIndexInformers, configMapInformer.Informer())
587+
configmapsgvk := corev1.SchemeGroupVersion.WithResource("configmaps")
588+
if err := labelObjects(configmapsgvk, configMapInformer.Informer(), labeller.ObjectLabeler[*corev1.ConfigMap, *corev1applyconfigurations.ConfigMapApplyConfiguration](
589+
ctx, op.logger, labeller.Filter(configmapsgvk),
590+
configMapInformer.Lister().List,
591+
corev1applyconfigurations.ConfigMap,
592+
func(namespace string, ctx context.Context, cfg *corev1applyconfigurations.ConfigMapApplyConfiguration, opts metav1.ApplyOptions) (*corev1.ConfigMap, error) {
593+
return op.opClient.KubernetesInterface().CoreV1().ConfigMaps(namespace).Apply(ctx, cfg, opts)
594+
},
595+
)); err != nil {
596+
return nil, err
597+
}
589598

590599
// Wire Jobs
591600
jobInformer := k8sInformerFactory.Batch().V1().Jobs()

staging/operator-lifecycle-manager/pkg/controller/operators/catalog/subscription/reconciler.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,9 @@ func (c *catalogHealthReconciler) updateDeprecatedStatus(ctx context.Context, su
128128
if c.sourceProvider == nil {
129129
return false, nil
130130
}
131-
132-
source, ok := c.sourceProvider.Sources(sub.Namespace)[cache.SourceKey{
131+
source, ok := c.sourceProvider.Sources(sub.Spec.CatalogSourceNamespace)[cache.SourceKey{
133132
Name: sub.Spec.CatalogSource,
134-
Namespace: sub.Namespace,
133+
Namespace: sub.Spec.CatalogSourceNamespace,
135134
}]
136135
if !ok {
137136
return false, nil

staging/operator-lifecycle-manager/pkg/controller/operators/labeller/filters.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ func ServiceAccountFilter(isServiceAccountReferenced func(namespace, name string
5959
}
6060

6161
var filters = map[schema.GroupVersionResource]func(metav1.Object) bool{
62-
corev1.SchemeGroupVersion.WithResource("services"): HasOLMOwnerRef,
62+
corev1.SchemeGroupVersion.WithResource("configmaps"): HasOLMOwnerRef,
63+
corev1.SchemeGroupVersion.WithResource("services"): HasOLMOwnerRef,
6364
corev1.SchemeGroupVersion.WithResource("pods"): func(object metav1.Object) bool {
6465
_, ok := object.GetLabels()[reconciler.CatalogSourceLabelKey]
6566
return ok

staging/operator-lifecycle-manager/pkg/controller/registry/reconciler/configmap.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,11 @@ func (c *ConfigMapRegistryReconciler) EnsureRegistryServer(logger *logrus.Entry,
290290

291291
if source.Spec.SourceType == v1alpha1.SourceTypeConfigmap || source.Spec.SourceType == v1alpha1.SourceTypeInternal {
292292
// fetch configmap first, exit early if we can't find it
293-
configMap, err := c.Lister.CoreV1().ConfigMapLister().ConfigMaps(source.GetNamespace()).Get(source.Spec.ConfigMap)
293+
// we use the live client here instead of a lister since our listers are scoped to objects with the olm.managed label,
294+
// and this configmap is a user-provided input to the catalog source and will not have that label
295+
configMap, err := c.OpClient.KubernetesInterface().CoreV1().ConfigMaps(source.GetNamespace()).Get(context.TODO(), source.Spec.ConfigMap, metav1.GetOptions{})
294296
if err != nil {
295-
return fmt.Errorf("unable to get configmap %s/%s from cache", source.GetNamespace(), source.Spec.ConfigMap)
297+
return fmt.Errorf("unable to find configmap %s/%s: %w", source.GetNamespace(), source.Spec.ConfigMap, err)
296298
}
297299

298300
if source.ConfigMapChanges(configMap) {
@@ -459,9 +461,11 @@ func (c *ConfigMapRegistryReconciler) CheckRegistryServer(logger *logrus.Entry,
459461
}
460462

461463
if source.Spec.SourceType == v1alpha1.SourceTypeConfigmap || source.Spec.SourceType == v1alpha1.SourceTypeInternal {
462-
configMap, err := c.Lister.CoreV1().ConfigMapLister().ConfigMaps(source.GetNamespace()).Get(source.Spec.ConfigMap)
464+
// we use the live client here instead of a lister since our listers are scoped to objects with the olm.managed label,
465+
// and this configmap is a user-provided input to the catalog source and will not have that label
466+
configMap, err := c.OpClient.KubernetesInterface().CoreV1().ConfigMaps(source.GetNamespace()).Get(context.TODO(), source.Spec.ConfigMap, metav1.GetOptions{})
463467
if err != nil {
464-
return false, fmt.Errorf("unable to get configmap %s/%s from cache", source.GetNamespace(), source.Spec.ConfigMap)
468+
return false, fmt.Errorf("unable to find configmap %s/%s: %w", source.GetNamespace(), source.Spec.ConfigMap, err)
465469
}
466470

467471
if source.ConfigMapChanges(configMap) {

staging/operator-lifecycle-manager/pkg/controller/registry/reconciler/configmap_test.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,13 +299,17 @@ func TestConfigMapRegistryReconciler(t *testing.T) {
299299
in: in{
300300
cluster: cluster{},
301301
catsrc: &v1alpha1.CatalogSource{
302+
ObjectMeta: metav1.ObjectMeta{
303+
Namespace: "test-ns",
304+
},
302305
Spec: v1alpha1.CatalogSourceSpec{
303306
SourceType: v1alpha1.SourceTypeConfigmap,
307+
ConfigMap: "test-cm",
304308
},
305309
},
306310
},
307311
out: out{
308-
err: fmt.Errorf("unable to get configmap / from cache"),
312+
err: fmt.Errorf(`unable to find configmap test-ns/test-cm: configmaps "test-cm" not found`),
309313
},
310314
},
311315
{
@@ -463,7 +467,11 @@ func TestConfigMapRegistryReconciler(t *testing.T) {
463467

464468
err := rec.EnsureRegistryServer(logrus.NewEntry(logrus.New()), tt.in.catsrc)
465469

466-
require.Equal(t, tt.out.err, err)
470+
if tt.out.err != nil {
471+
require.EqualError(t, err, tt.out.err.Error())
472+
} else {
473+
require.NoError(t, err)
474+
}
467475
require.Equal(t, tt.out.status, tt.in.catsrc.Status.RegistryServiceStatus)
468476

469477
if tt.out.err != nil {

staging/operator-lifecycle-manager/test/e2e/subscription_e2e_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,13 +159,21 @@ var _ = Describe("Subscription", func() {
159159
It("creation if not installed", func() {
160160

161161
defer func() {
162+
if env := os.Getenv("SKIP_CLEANUP"); env != "" {
163+
fmt.Printf("Skipping cleanup of subscriptions in namespace %s\n", generatedNamespace.GetName())
164+
return
165+
}
162166
require.NoError(GinkgoT(), crc.OperatorsV1alpha1().Subscriptions(generatedNamespace.GetName()).DeleteCollection(context.Background(), metav1.DeleteOptions{}, metav1.ListOptions{}))
163167
}()
168+
169+
By("creating a catalog")
164170
require.NoError(GinkgoT(), initCatalog(GinkgoT(), generatedNamespace.GetName(), c, crc))
165171

172+
By(fmt.Sprintf("creating a subscription: %s/%s", generatedNamespace.GetName(), testSubscriptionName))
166173
cleanup, _ := createSubscription(GinkgoT(), crc, generatedNamespace.GetName(), testSubscriptionName, testPackageName, betaChannel, operatorsv1alpha1.ApprovalAutomatic)
167174
defer cleanup()
168175

176+
By("waiting for the subscription to have a current CSV and be at latest")
169177
var currentCSV string
170178
Eventually(func() bool {
171179
fetched, err := crc.OperatorsV1alpha1().Subscriptions(generatedNamespace.GetName()).Get(context.Background(), testSubscriptionName, metav1.GetOptions{})
@@ -3121,6 +3129,7 @@ func initCatalog(t GinkgoTInterface, namespace string, c operatorclient.ClientIn
31213129
}
31223130
return err
31233131
}
3132+
t.Logf("created configmap %s/%s", dummyCatalogConfigMap.Namespace, dummyCatalogConfigMap.Name)
31243133

31253134
dummyCatalogSource.SetNamespace(namespace)
31263135
if _, err := crc.OperatorsV1alpha1().CatalogSources(namespace).Create(context.Background(), &dummyCatalogSource, metav1.CreateOptions{}); err != nil {
@@ -3129,6 +3138,7 @@ func initCatalog(t GinkgoTInterface, namespace string, c operatorclient.ClientIn
31293138
}
31303139
return err
31313140
}
3141+
t.Logf("created catalog source %s/%s", dummyCatalogSource.Namespace, dummyCatalogSource.Name)
31323142

31333143
fetched, err := fetchCatalogSourceOnStatus(crc, dummyCatalogSource.GetName(), dummyCatalogSource.GetNamespace(), catalogSourceRegistryPodSynced())
31343144
require.NoError(t, err)
@@ -3312,6 +3322,7 @@ func createSubscription(t GinkgoTInterface, crc versioned.Interface, namespace,
33123322

33133323
subscription, err := crc.OperatorsV1alpha1().Subscriptions(namespace).Create(context.Background(), subscription, metav1.CreateOptions{})
33143324
Expect(err).ToNot(HaveOccurred())
3325+
t.Logf("created subscription %s/%s", subscription.Namespace, subscription.Name)
33153326
return buildSubscriptionCleanupFunc(crc, subscription), subscription
33163327
}
33173328

staging/operator-lifecycle-manager/test/e2e/util.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1073,11 +1073,13 @@ func SetupGeneratedTestNamespaceWithOperatorGroup(name string, og operatorsv1.Op
10731073
return ctx.Ctx().E2EClient().Create(context.Background(), &ns)
10741074
}).Should(Succeed())
10751075

1076+
ctx.Ctx().Logf("created the %s testing namespace", ns.GetName())
1077+
10761078
Eventually(func() error {
10771079
return ctx.Ctx().E2EClient().Create(context.Background(), &og)
10781080
}).Should(Succeed())
10791081

1080-
ctx.Ctx().Logf("created the %s testing namespace", ns.GetName())
1082+
ctx.Ctx().Logf("created the %s/%s operator group", og.Namespace, og.Name)
10811083

10821084
return ns
10831085
}

staging/operator-registry/Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,12 @@ $(LOCALBIN):
148148
## Tool Binaries
149149
GORELEASER ?= $(LOCALBIN)/goreleaser
150150
GINKGO ?= $(LOCALBIN)/ginkgo
151+
PROTOC_VERSION ?= $(LOCALBIN)/protoc-gen-go-grpc
151152

152153
## Tool Versions
153154
GORELEASER_VERSION ?= v1.8.3
154155
GINKGO_VERSION ?= v2.1.3
156+
PROTOC_VERSION ?= v1.3.0
155157

156158
.PHONY: goreleaser
157159
goreleaser: $(GORELEASER) ## Download goreleaser locally if necessary.
@@ -162,3 +164,8 @@ $(GORELEASER): $(LOCALBIN)
162164
ginkgo: $(GINKGO) ## Download ginkgo locally if necessary.
163165
$(GINKGO): $(LOCALBIN)
164166
GOBIN=$(LOCALBIN) go install $(GO_INSTALL_OPTS) github.com/onsi/ginkgo/v2/ginkgo@$(GINKGO_VERSION)
167+
168+
.PHONY: protoc-gen-go-grpc
169+
protoc-gen-go-grpc: $(protoc-gen-go-grpc) ## Download protoc-gen-go-grpc locally if necessary.
170+
$(protoc-gen-go-grpc): $(LOCALBIN)
171+
GOBIN=$(LOCALBIN) go install $(GO_INSTALL_OPTS) google.golang.org/grpc/cmd/protoc-gen-go-grpc@$(PROTOC_VERSION)

staging/operator-registry/alpha/declcfg/write.go

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,26 @@ func (writer *MermaidWriter) WriteChannels(cfg DeclarativeConfig, out io.Writer)
106106

107107
minEdgePackage := writer.getMinEdgePackage(&cfg)
108108

109+
depByPackage := sets.Set[string]{}
110+
depByChannel := sets.Set[string]{}
111+
depByBundle := sets.Set[string]{}
112+
113+
for _, d := range cfg.Deprecations {
114+
for _, e := range d.Entries {
115+
switch e.Reference.Schema {
116+
case SchemaPackage:
117+
depByPackage.Insert(d.Package)
118+
case SchemaChannel:
119+
depByChannel.Insert(e.Reference.Name)
120+
case SchemaBundle:
121+
depByBundle.Insert(e.Reference.Name)
122+
}
123+
}
124+
}
125+
126+
var deprecatedPackage string
127+
deprecatedChannels := []string{}
128+
109129
for _, c := range cfg.Channels {
110130
filteredChannel := writer.filterChannel(&c, versionMap, minVersion, minEdgePackage)
111131
if filteredChannel != nil {
@@ -119,10 +139,23 @@ func (writer *MermaidWriter) WriteChannels(cfg DeclarativeConfig, out io.Writer)
119139
pkgBuilder.WriteString(fmt.Sprintf(" %%%% channel %q\n", filteredChannel.Name))
120140
pkgBuilder.WriteString(fmt.Sprintf(" subgraph %s[%q]\n", channelID, filteredChannel.Name))
121141

142+
if depByPackage.Has(filteredChannel.Package) {
143+
deprecatedPackage = filteredChannel.Package
144+
}
145+
146+
if depByChannel.Has(filteredChannel.Name) {
147+
deprecatedChannels = append(deprecatedChannels, channelID)
148+
}
149+
122150
for _, ce := range filteredChannel.Entries {
123151
if versionMap[ce.Name].GE(minVersion) {
152+
bundleDeprecation := ""
153+
if depByBundle.Has(ce.Name) {
154+
bundleDeprecation = ":::deprecated"
155+
}
156+
124157
entryId := fmt.Sprintf("%s-%s", channelID, ce.Name)
125-
pkgBuilder.WriteString(fmt.Sprintf(" %s[%q]\n", entryId, ce.Name))
158+
pkgBuilder.WriteString(fmt.Sprintf(" %s[%q]%s\n", entryId, ce.Name, bundleDeprecation))
126159

127160
if len(ce.Replaces) > 0 {
128161
replacesId := fmt.Sprintf("%s-%s", channelID, ce.Replaces)
@@ -154,6 +187,7 @@ func (writer *MermaidWriter) WriteChannels(cfg DeclarativeConfig, out io.Writer)
154187
}
155188

156189
out.Write([]byte("graph LR\n"))
190+
out.Write([]byte(fmt.Sprintf(" classDef deprecated fill:#E8960F\n")))
157191
pkgNames := []string{}
158192
for pname := range pkgs {
159193
pkgNames = append(pkgNames, pname)
@@ -168,6 +202,16 @@ func (writer *MermaidWriter) WriteChannels(cfg DeclarativeConfig, out io.Writer)
168202
out.Write([]byte(" end\n"))
169203
}
170204

205+
if deprecatedPackage != "" {
206+
out.Write([]byte(fmt.Sprintf("style %s fill:#989695\n", deprecatedPackage)))
207+
}
208+
209+
if len(deprecatedChannels) > 0 {
210+
for _, deprecatedChannel := range deprecatedChannels {
211+
out.Write([]byte(fmt.Sprintf("style %s fill:#DCD0FF\n", deprecatedChannel)))
212+
}
213+
}
214+
171215
return nil
172216
}
173217

0 commit comments

Comments
 (0)