Skip to content
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
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ require (
github.com/felixge/httpsnoop v1.0.3 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/fvbommel/sortorder v1.0.1 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/go-air/gini v1.0.4 // indirect
github.com/go-errors/errors v1.4.2 // indirect
github.com/go-git/gcfg v1.5.0 // indirect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ metadata:
capability.openshift.io/name: "OperatorLifecycleManager"
spec:
strategy:
type: RollingUpdate
type: Recreate
replicas: 1
selector:
matchLabels:
Expand Down
2 changes: 1 addition & 1 deletion manifests/0000_50_olm_07-olm-operator.deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ metadata:
capability.openshift.io/name: "OperatorLifecycleManager"
spec:
strategy:
type: RollingUpdate
type: Recreate
replicas: 1
selector:
matchLabels:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ metadata:
capability.openshift.io/name: "OperatorLifecycleManager"
spec:
strategy:
type: RollingUpdate
type: Recreate
replicas: 1
selector:
matchLabels:
Expand Down
2 changes: 1 addition & 1 deletion manifests/0000_50_olm_08-catalog-operator.deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ metadata:
capability.openshift.io/name: "OperatorLifecycleManager"
spec:
strategy:
type: RollingUpdate
type: Recreate
replicas: 1
selector:
matchLabels:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ metadata:
capability.openshift.io/name: "OperatorLifecycleManager"
spec:
strategy:
type: RollingUpdate
type: Recreate
replicas: 1
selector:
matchLabels:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ metadata:
capability.openshift.io/name: "OperatorLifecycleManager"
spec:
strategy:
type: RollingUpdate
type: Recreate
replicas: 1
selector:
matchLabels:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ metadata:
capability.openshift.io/name: "OperatorLifecycleManager"
spec:
strategy:
type: RollingUpdate
type: Recreate
replicas: 1
selector:
matchLabels:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ metadata:
capability.openshift.io/name: "OperatorLifecycleManager"
spec:
strategy:
type: RollingUpdate
type: Recreate
replicas: 1
selector:
matchLabels:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
app: olm-operator
spec:
strategy:
type: RollingUpdate
type: Recreate
replicas: {{ .Values.olm.replicaCount }}
selector:
matchLabels:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
app: catalog-operator
spec:
strategy:
type: RollingUpdate
type: Recreate
replicas: {{ .Values.catalog.replicaCount }}
selector:
matchLabels:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -581,11 +581,20 @@ func NewOperator(ctx context.Context, kubeconfigPath string, clock utilclock.Clo
sharedIndexInformers = append(sharedIndexInformers, buPodInformer.Informer())

// Wire ConfigMaps
configMapInformer := informers.NewSharedInformerFactoryWithOptions(op.opClient.KubernetesInterface(), resyncPeriod(), informers.WithTweakListOptions(func(options *metav1.ListOptions) {
options.LabelSelector = install.OLMManagedLabelKey
})).Core().V1().ConfigMaps()
configMapInformer := k8sInformerFactory.Core().V1().ConfigMaps()
op.lister.CoreV1().RegisterConfigMapLister(metav1.NamespaceAll, configMapInformer.Lister())
sharedIndexInformers = append(sharedIndexInformers, configMapInformer.Informer())
configmapsgvk := corev1.SchemeGroupVersion.WithResource("configmaps")
if err := labelObjects(configmapsgvk, configMapInformer.Informer(), labeller.ObjectLabeler[*corev1.ConfigMap, *corev1applyconfigurations.ConfigMapApplyConfiguration](
ctx, op.logger, labeller.Filter(configmapsgvk),
configMapInformer.Lister().List,
corev1applyconfigurations.ConfigMap,
func(namespace string, ctx context.Context, cfg *corev1applyconfigurations.ConfigMapApplyConfiguration, opts metav1.ApplyOptions) (*corev1.ConfigMap, error) {
return op.opClient.KubernetesInterface().CoreV1().ConfigMaps(namespace).Apply(ctx, cfg, opts)
},
)); err != nil {
return nil, err
}

// Wire Jobs
jobInformer := k8sInformerFactory.Batch().V1().Jobs()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,9 @@ func (c *catalogHealthReconciler) updateDeprecatedStatus(ctx context.Context, su
if c.sourceProvider == nil {
return false, nil
}

source, ok := c.sourceProvider.Sources(sub.Namespace)[cache.SourceKey{
source, ok := c.sourceProvider.Sources(sub.Spec.CatalogSourceNamespace)[cache.SourceKey{
Name: sub.Spec.CatalogSource,
Namespace: sub.Namespace,
Namespace: sub.Spec.CatalogSourceNamespace,
}]
if !ok {
return false, nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ func ServiceAccountFilter(isServiceAccountReferenced func(namespace, name string
}

var filters = map[schema.GroupVersionResource]func(metav1.Object) bool{
corev1.SchemeGroupVersion.WithResource("services"): HasOLMOwnerRef,
corev1.SchemeGroupVersion.WithResource("configmaps"): HasOLMOwnerRef,
corev1.SchemeGroupVersion.WithResource("services"): HasOLMOwnerRef,
corev1.SchemeGroupVersion.WithResource("pods"): func(object metav1.Object) bool {
_, ok := object.GetLabels()[reconciler.CatalogSourceLabelKey]
return ok
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,11 @@ func (c *ConfigMapRegistryReconciler) EnsureRegistryServer(logger *logrus.Entry,

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

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

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

if source.ConfigMapChanges(configMap) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,13 +299,17 @@ func TestConfigMapRegistryReconciler(t *testing.T) {
in: in{
cluster: cluster{},
catsrc: &v1alpha1.CatalogSource{
ObjectMeta: metav1.ObjectMeta{
Namespace: "test-ns",
},
Spec: v1alpha1.CatalogSourceSpec{
SourceType: v1alpha1.SourceTypeConfigmap,
ConfigMap: "test-cm",
},
},
},
out: out{
err: fmt.Errorf("unable to get configmap / from cache"),
err: fmt.Errorf(`unable to find configmap test-ns/test-cm: configmaps "test-cm" not found`),
},
},
{
Expand Down Expand Up @@ -463,7 +467,11 @@ func TestConfigMapRegistryReconciler(t *testing.T) {

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

require.Equal(t, tt.out.err, err)
if tt.out.err != nil {
require.EqualError(t, err, tt.out.err.Error())
} else {
require.NoError(t, err)
}
require.Equal(t, tt.out.status, tt.in.catsrc.Status.RegistryServiceStatus)

if tt.out.err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,21 @@ var _ = Describe("Subscription", func() {
It("creation if not installed", func() {

defer func() {
if env := os.Getenv("SKIP_CLEANUP"); env != "" {
fmt.Printf("Skipping cleanup of subscriptions in namespace %s\n", generatedNamespace.GetName())
return
}
require.NoError(GinkgoT(), crc.OperatorsV1alpha1().Subscriptions(generatedNamespace.GetName()).DeleteCollection(context.Background(), metav1.DeleteOptions{}, metav1.ListOptions{}))
}()

By("creating a catalog")
require.NoError(GinkgoT(), initCatalog(GinkgoT(), generatedNamespace.GetName(), c, crc))

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

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

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

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

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

Expand Down
4 changes: 3 additions & 1 deletion staging/operator-lifecycle-manager/test/e2e/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -1073,11 +1073,13 @@ func SetupGeneratedTestNamespaceWithOperatorGroup(name string, og operatorsv1.Op
return ctx.Ctx().E2EClient().Create(context.Background(), &ns)
}).Should(Succeed())

ctx.Ctx().Logf("created the %s testing namespace", ns.GetName())

Eventually(func() error {
return ctx.Ctx().E2EClient().Create(context.Background(), &og)
}).Should(Succeed())

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

return ns
}
Expand Down
7 changes: 7 additions & 0 deletions staging/operator-registry/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,12 @@ $(LOCALBIN):
## Tool Binaries
GORELEASER ?= $(LOCALBIN)/goreleaser
GINKGO ?= $(LOCALBIN)/ginkgo
PROTOC_VERSION ?= $(LOCALBIN)/protoc-gen-go-grpc

## Tool Versions
GORELEASER_VERSION ?= v1.8.3
GINKGO_VERSION ?= v2.1.3
PROTOC_VERSION ?= v1.3.0

.PHONY: goreleaser
goreleaser: $(GORELEASER) ## Download goreleaser locally if necessary.
Expand All @@ -162,3 +164,8 @@ $(GORELEASER): $(LOCALBIN)
ginkgo: $(GINKGO) ## Download ginkgo locally if necessary.
$(GINKGO): $(LOCALBIN)
GOBIN=$(LOCALBIN) go install $(GO_INSTALL_OPTS) github.com/onsi/ginkgo/v2/ginkgo@$(GINKGO_VERSION)

.PHONY: protoc-gen-go-grpc
protoc-gen-go-grpc: $(protoc-gen-go-grpc) ## Download protoc-gen-go-grpc locally if necessary.
$(protoc-gen-go-grpc): $(LOCALBIN)
GOBIN=$(LOCALBIN) go install $(GO_INSTALL_OPTS) google.golang.org/grpc/cmd/protoc-gen-go-grpc@$(PROTOC_VERSION)
46 changes: 45 additions & 1 deletion staging/operator-registry/alpha/declcfg/write.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,26 @@ func (writer *MermaidWriter) WriteChannels(cfg DeclarativeConfig, out io.Writer)

minEdgePackage := writer.getMinEdgePackage(&cfg)

depByPackage := sets.Set[string]{}
depByChannel := sets.Set[string]{}
depByBundle := sets.Set[string]{}

for _, d := range cfg.Deprecations {
for _, e := range d.Entries {
switch e.Reference.Schema {
case SchemaPackage:
depByPackage.Insert(d.Package)
case SchemaChannel:
depByChannel.Insert(e.Reference.Name)
case SchemaBundle:
depByBundle.Insert(e.Reference.Name)
}
}
}

var deprecatedPackage string
deprecatedChannels := []string{}

for _, c := range cfg.Channels {
filteredChannel := writer.filterChannel(&c, versionMap, minVersion, minEdgePackage)
if filteredChannel != nil {
Expand All @@ -119,10 +139,23 @@ func (writer *MermaidWriter) WriteChannels(cfg DeclarativeConfig, out io.Writer)
pkgBuilder.WriteString(fmt.Sprintf(" %%%% channel %q\n", filteredChannel.Name))
pkgBuilder.WriteString(fmt.Sprintf(" subgraph %s[%q]\n", channelID, filteredChannel.Name))

if depByPackage.Has(filteredChannel.Package) {
deprecatedPackage = filteredChannel.Package
}

if depByChannel.Has(filteredChannel.Name) {
deprecatedChannels = append(deprecatedChannels, channelID)
}

for _, ce := range filteredChannel.Entries {
if versionMap[ce.Name].GE(minVersion) {
bundleDeprecation := ""
if depByBundle.Has(ce.Name) {
bundleDeprecation = ":::deprecated"
}

entryId := fmt.Sprintf("%s-%s", channelID, ce.Name)
pkgBuilder.WriteString(fmt.Sprintf(" %s[%q]\n", entryId, ce.Name))
pkgBuilder.WriteString(fmt.Sprintf(" %s[%q]%s\n", entryId, ce.Name, bundleDeprecation))

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

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

if deprecatedPackage != "" {
out.Write([]byte(fmt.Sprintf("style %s fill:#989695\n", deprecatedPackage)))
}

if len(deprecatedChannels) > 0 {
for _, deprecatedChannel := range deprecatedChannels {
out.Write([]byte(fmt.Sprintf("style %s fill:#DCD0FF\n", deprecatedChannel)))
}
}

return nil
}

Expand Down
Loading