Skip to content

Commit d0ca938

Browse files
committed
Update OLM to use UID for OG Labels
Problem: OLM is using an older version of the operator-framework/api repository with which OLM applies a label with a blank value whose key is equal to "olm.operatorgroup/.". Kubernetes limits the lengths of label values and keys to 63 characters. This limit can easily be overcome when the OperatorGroup has a long name or when it is deployed in a namespace with a long name. Solution: Update OLM to use import the latest version of the operator-framework/api repository that uses "olm.operatorgroup.uid/" as the key for OperatorGroup labels. The length of this label will always be 58 characters as UIDs are 36 characters long.
1 parent 15f5ba3 commit d0ca938

File tree

185 files changed

+35749
-300
lines changed

Some content is hidden

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

185 files changed

+35749
-300
lines changed

go.mod

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ require (
2222
github.com/onsi/gomega v1.9.0
2323
github.com/openshift/api v0.0.0-20200331152225-585af27e34fd
2424
github.com/openshift/client-go v0.0.0-20200326155132-2a6cd50aedd0
25-
github.com/operator-framework/api v0.3.1
26-
github.com/operator-framework/operator-registry v1.11.0
25+
github.com/operator-framework/api v0.3.2
26+
github.com/operator-framework/operator-registry v1.12.1
2727
github.com/otiai10/copy v1.0.2
2828
github.com/pkg/errors v0.9.1
2929
github.com/prometheus/client_golang v1.2.1
@@ -36,19 +36,18 @@ require (
3636
google.golang.org/grpc v1.27.0
3737
gopkg.in/yaml.v2 v2.2.8
3838
helm.sh/helm/v3 v3.1.2
39-
k8s.io/api v0.18.0
40-
k8s.io/apiextensions-apiserver v0.18.0
41-
k8s.io/apimachinery v0.18.0
42-
k8s.io/apiserver v0.18.0
43-
k8s.io/client-go v0.18.0
44-
k8s.io/code-generator v0.18.0
45-
k8s.io/component-base v0.18.0
39+
k8s.io/api v0.18.2
40+
k8s.io/apiextensions-apiserver v0.18.2
41+
k8s.io/apimachinery v0.18.2
42+
k8s.io/apiserver v0.18.2
43+
k8s.io/client-go v0.18.2
44+
k8s.io/code-generator v0.18.2
45+
k8s.io/component-base v0.18.2
4646
k8s.io/klog v1.0.0
4747
k8s.io/kube-aggregator v0.18.0
4848
k8s.io/kube-openapi v0.0.0-20200121204235-bf4fb3bd569c
49-
rsc.io/letsencrypt v0.0.3 // indirect
50-
sigs.k8s.io/controller-runtime v0.5.2
51-
sigs.k8s.io/controller-tools v0.2.8
49+
sigs.k8s.io/controller-runtime v0.6.0
50+
sigs.k8s.io/controller-tools v0.3.0
5251
sigs.k8s.io/kind v0.7.0
5352
)
5453

@@ -58,7 +57,6 @@ replace (
5857
github.com/openshift/api => github.com/openshift/api v0.0.0-20200331152225-585af27e34fd // release-4.5
5958
github.com/openshift/client-go => github.com/openshift/client-go v0.0.0-20200326155132-2a6cd50aedd0 // release-4.5
6059

61-
github.com/operator-framework/api => github.com/operator-framework/api v0.3.1
6260
github.com/prometheus/client_golang => github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829
6361
google.golang.org/grpc => google.golang.org/grpc v1.26.0 // https://github.com/etcd-io/etcd/issues/11563
6462

go.sum

Lines changed: 49 additions & 20 deletions
Large diffs are not rendered by default.

pkg/controller/install/webhook.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ func (i *StrategyDeploymentInstaller) createOrUpdateWebhook(caPEM []byte, desc v
5656
if err != nil || len(operatorGroups) != 1 {
5757
return fmt.Errorf("Error retrieving OperatorGroup info")
5858
}
59-
ogNamespacelabelSelector := operatorGroups[0].NamespaceLabelSelector()
59+
ogNamespacelabelSelector, err := operatorGroups[0].NamespaceLabelSelector()
60+
if err != nil {
61+
return err
62+
}
6063

6164
switch desc.Type {
6265
case v1alpha1.ValidatingAdmissionWebhook:

pkg/controller/operators/olm/operator.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,10 @@ func (a *Operator) syncNamespace(obj interface{}) error {
776776
if namespace.Labels == nil {
777777
namespace.Labels = make(map[string]string, 1)
778778
}
779-
ogLabelKey, ogLabelValue := group.OGLabelKeyAndValue()
779+
ogLabelKey, ogLabelValue, err := group.OGLabelKeyAndValue()
780+
if err != nil {
781+
return err
782+
}
780783
namespace.Labels[ogLabelKey] = ogLabelValue
781784
}
782785
}

test/e2e/csv_e2e_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3337,7 +3337,7 @@ var _ = Describe("CSV", func() {
33373337
require.NoError(GinkgoT(), err)
33383338

33393339
expected := &metav1.LabelSelector{
3340-
MatchLabels: map[string]string{"olm.operatorgroup/" + namespace.Name + "." + og.GetName(): ""},
3340+
MatchLabels: map[string]string{fmt.Sprintf("olm.operatorgroup.uid/%s", og.GetUID()): ""},
33413341
MatchExpressions: []metav1.LabelSelectorRequirement(nil),
33423342
}
33433343

test/e2e/operator_groups_e2e_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2086,7 +2086,7 @@ var _ = Describe("Operator Group", func() {
20862086
TargetNamespaces: []string{},
20872087
},
20882088
}
2089-
_, err := crc.OperatorsV1().OperatorGroups(testNamespaceA).Create(context.TODO(), operatorGroup, metav1.CreateOptions{})
2089+
operatorGroup, err := crc.OperatorsV1().OperatorGroups(testNamespaceA).Create(context.TODO(), operatorGroup, metav1.CreateOptions{})
20902090
require.NoError(GinkgoT(), err)
20912091

20922092
// Cleanup OperatorGroup
@@ -2096,7 +2096,7 @@ var _ = Describe("Operator Group", func() {
20962096
}()
20972097

20982098
// Create the OperatorGroup Label
2099-
ogLabel := fmt.Sprintf("olm.operatorgroup/%s.%s", testNamespaceA, operatorGroup.GetName())
2099+
ogLabel := fmt.Sprintf("olm.operatorgroup.uid/%s", operatorGroup.GetUID())
21002100

21012101
// Create list options
21022102
listOptions := metav1.ListOptions{
@@ -2186,11 +2186,11 @@ var _ = Describe("Operator Group", func() {
21862186
TargetNamespaces: testNamespaces,
21872187
},
21882188
}
2189-
_, err := crc.OperatorsV1().OperatorGroups(testNamespaceA).Create(context.TODO(), operatorGroup, metav1.CreateOptions{})
2189+
operatorGroup, err := crc.OperatorsV1().OperatorGroups(testNamespaceA).Create(context.TODO(), operatorGroup, metav1.CreateOptions{})
21902190
require.NoError(GinkgoT(), err)
21912191

21922192
// Create the OperatorGroup Label
2193-
ogLabel := fmt.Sprintf("olm.operatorgroup/%s.%s", testNamespaceA, operatorGroup.GetName())
2193+
ogLabel := fmt.Sprintf("olm.operatorgroup.uid/%s", operatorGroup.GetUID())
21942194

21952195
// Create list options
21962196
listOptions := metav1.ListOptions{

vendor/github.com/containerd/containerd/archive/strconv.go

Lines changed: 68 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)