Skip to content

Commit a947685

Browse files
Merge pull request #1496 from awgreene/operatorgroup
Bug 1830031: Update OLM to use UID for OG Labels
2 parents 15f5ba3 + 5e8ca4e commit a947685

File tree

186 files changed

+35763
-301
lines changed

Some content is hidden

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

186 files changed

+35763
-301
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: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3336,8 +3336,11 @@ var _ = Describe("CSV", func() {
33363336
actualWebhook, err := c.KubernetesInterface().AdmissionregistrationV1().ValidatingWebhookConfigurations().Get(context.TODO(), webhook.Name, metav1.GetOptions{})
33373337
require.NoError(GinkgoT(), err)
33383338

3339+
ogLabel, err := getOGLabelKey(og)
3340+
require.NoError(GinkgoT(), err)
3341+
33393342
expected := &metav1.LabelSelector{
3340-
MatchLabels: map[string]string{"olm.operatorgroup/" + namespace.Name + "." + og.GetName(): ""},
3343+
MatchLabels: map[string]string{ogLabel: ""},
33413344
MatchExpressions: []metav1.LabelSelectorRequirement(nil),
33423345
}
33433346

test/e2e/operator_groups_e2e_test.go

Lines changed: 14 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,8 @@ 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, err := getOGLabelKey(operatorGroup)
2100+
require.NoError(GinkgoT(), err)
21002101

21012102
// Create list options
21022103
listOptions := metav1.ListOptions{
@@ -2186,11 +2187,12 @@ var _ = Describe("Operator Group", func() {
21862187
TargetNamespaces: testNamespaces,
21872188
},
21882189
}
2189-
_, err := crc.OperatorsV1().OperatorGroups(testNamespaceA).Create(context.TODO(), operatorGroup, metav1.CreateOptions{})
2190+
operatorGroup, err := crc.OperatorsV1().OperatorGroups(testNamespaceA).Create(context.TODO(), operatorGroup, metav1.CreateOptions{})
21902191
require.NoError(GinkgoT(), err)
21912192

21922193
// Create the OperatorGroup Label
2193-
ogLabel := fmt.Sprintf("olm.operatorgroup/%s.%s", testNamespaceA, operatorGroup.GetName())
2194+
ogLabel, err := getOGLabelKey(operatorGroup)
2195+
require.NoError(GinkgoT(), err)
21942196

21952197
// Create list options
21962198
listOptions := metav1.ListOptions{
@@ -2325,3 +2327,11 @@ func containsNamespace(namespaces []corev1.Namespace, namespaceName string) bool
23252327
}
23262328
return false
23272329
}
2330+
2331+
func getOGLabelKey(og *v1.OperatorGroup) (string, error) {
2332+
ogUID := string(og.GetUID())
2333+
if ogUID == "" {
2334+
return "", fmt.Errorf("OperatorGroup UID is empty string")
2335+
}
2336+
return fmt.Sprintf("olm.operatorgroup.uid/%s", og.GetUID()), nil
2337+
}

upstream.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ COPY go.sum go.sum
1717
COPY cmd cmd
1818
COPY util util
1919
COPY test test
20-
RUN make build
20+
RUN CGO_ENABLED=0 make build
2121
RUN make build-util
2222

2323
FROM alpine:latest

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)