Skip to content

Commit f5fb02c

Browse files
Merge pull request #531 from stevekuznetsov/skuznets/update-olm
OCPBUGS-17157: sync
2 parents d98ec8b + f41c684 commit f5fb02c

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

+579
-92
lines changed

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ require (
1313
github.com/mikefarah/yq/v3 v3.0.0-20201202084205-8846255d1c37
1414
github.com/onsi/ginkgo/v2 v2.9.5
1515
github.com/openshift/api v3.9.0+incompatible
16-
github.com/operator-framework/api v0.17.7
16+
github.com/operator-framework/api v0.17.8-0.20230803152844-704ae942c4a9
1717
github.com/operator-framework/operator-lifecycle-manager v0.0.0-00010101000000-000000000000
1818
github.com/operator-framework/operator-registry v1.27.1
1919
github.com/sirupsen/logrus v1.9.2
@@ -68,7 +68,7 @@ require (
6868
github.com/distribution/distribution v2.7.1+incompatible // indirect
6969
github.com/docker/cli v23.0.1+incompatible // indirect
7070
github.com/docker/distribution v2.8.2+incompatible // indirect
71-
github.com/docker/docker v23.0.1+incompatible // indirect
71+
github.com/docker/docker v23.0.3+incompatible // indirect
7272
github.com/docker/docker-credential-helpers v0.7.0 // indirect
7373
github.com/docker/go-connections v0.4.0 // indirect
7474
github.com/docker/go-metrics v0.0.1 // indirect

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,8 @@ github.com/docker/cli v23.0.1+incompatible h1:LRyWITpGzl2C9e9uGxzisptnxAn1zfZKXy
185185
github.com/docker/cli v23.0.1+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
186186
github.com/docker/distribution v0.0.0-20191216044856-a8371794149d h1:jC8tT/S0OGx2cswpeUTn4gOIea8P08lD3VFQT0cOZ50=
187187
github.com/docker/distribution v0.0.0-20191216044856-a8371794149d/go.mod h1:0+TTO4EOBfRPhZXAeF1Vu+W3hHZ8eLp8PgKVZlcvtFY=
188-
github.com/docker/docker v23.0.1+incompatible h1:vjgvJZxprTTE1A37nm+CLNAdwu6xZekyoiVlUZEINcY=
189-
github.com/docker/docker v23.0.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
188+
github.com/docker/docker v23.0.3+incompatible h1:9GhVsShNWz1hO//9BNg/dpMnZW25KydO4wtVxWAIbho=
189+
github.com/docker/docker v23.0.3+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
190190
github.com/docker/docker-credential-helpers v0.7.0 h1:xtCHsjxogADNZcdv1pKUHXryefjlVRqWqIhk/uXJp0A=
191191
github.com/docker/docker-credential-helpers v0.7.0/go.mod h1:rETQfLdHNT3foU5kuNkFR1R1V12OJRRO5lzt2D1b5X0=
192192
github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ=

manifests/0000_50_olm_00-catalogsources.crd.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,13 @@ spec:
534534
topologyKey:
535535
description: This pod should be co-located (affinity) or not co-located (anti-affinity) with the pods matching the labelSelector in the specified namespaces, where co-located is defined as running on a node whose value of the label with key topologyKey matches that of any node on which any of the selected pods is running. Empty topologyKey is not allowed.
536536
type: string
537+
memoryTarget:
538+
description: "MemoryTarget configures the $GOMEMLIMIT value for the gRPC catalog Pod. This is a soft memory limit for the server, which the runtime will attempt to meet but makes no guarantees that it will do so. If this value is set, the Pod will have the following modifications made to the container running the server: - the $GOMEMLIMIT environment variable will be set to this value in bytes - the memory request will be set to this value - the memory limit will be set to 200% of this value \n This field should be set if it's desired to reduce the footprint of a catalog server as much as possible, or if a catalog being served is very large and needs more than the default allocation. If your index image has a file- system cache, determine a good approximation for this value by doubling the size of the package cache at /tmp/cache/cache/packages.json in the index image. \n This field is best-effort; if unset, no default will be used and no Pod memory limit or $GOMEMLIMIT value will be set."
539+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
540+
anyOf:
541+
- type: integer
542+
- type: string
543+
x-kubernetes-int-or-string: true
537544
nodeSelector:
538545
description: NodeSelector is a selector which must be true for the pod to fit on a node. Selector which must match a node's labels for the pod to be scheduled on that node.
539546
type: object

staging/api/.github/workflows/go.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ jobs:
3333
- uses: codecov/codecov-action@v3
3434
with:
3535
files: cover.out
36-
fail_ci_if_error: true
3736
functionalities: fixes
3837

3938
go-apidiff:

staging/api/crds/operators.coreos.com_catalogsources.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,13 @@ spec:
532532
topologyKey:
533533
description: This pod should be co-located (affinity) or not co-located (anti-affinity) with the pods matching the labelSelector in the specified namespaces, where co-located is defined as running on a node whose value of the label with key topologyKey matches that of any node on which any of the selected pods is running. Empty topologyKey is not allowed.
534534
type: string
535+
memoryTarget:
536+
description: "MemoryTarget configures the $GOMEMLIMIT value for the gRPC catalog Pod. This is a soft memory limit for the server, which the runtime will attempt to meet but makes no guarantees that it will do so. If this value is set, the Pod will have the following modifications made to the container running the server: - the $GOMEMLIMIT environment variable will be set to this value in bytes - the memory request will be set to this value - the memory limit will be set to 200% of this value \n This field should be set if it's desired to reduce the footprint of a catalog server as much as possible, or if a catalog being served is very large and needs more than the default allocation. If your index image has a file- system cache, determine a good approximation for this value by doubling the size of the package cache at /tmp/cache/cache/packages.json in the index image. \n This field is best-effort; if unset, no default will be used and no Pod memory limit or $GOMEMLIMIT value will be set."
537+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
538+
anyOf:
539+
- type: integer
540+
- type: string
541+
x-kubernetes-int-or-string: true
535542
nodeSelector:
536543
description: NodeSelector is a selector which must be true for the pod to fit on a node. Selector which must match a node's labels for the pod to be scheduled on that node.
537544
type: object

staging/api/crds/zz_defs.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

staging/api/pkg/operators/v1alpha1/catalogsource_types.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77

88
"github.com/sirupsen/logrus"
99
corev1 "k8s.io/api/core/v1"
10+
"k8s.io/apimachinery/pkg/api/resource"
1011
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1112
"k8s.io/apimachinery/pkg/types"
1213
)
@@ -145,6 +146,21 @@ type GrpcPodConfig struct {
145146
// +kubebuilder:validation:Enum=legacy;restricted
146147
// +kubebuilder:default:=legacy
147148
SecurityContextConfig SecurityConfig `json:"securityContextConfig,omitempty"`
149+
150+
// MemoryTarget configures the $GOMEMLIMIT value for the gRPC catalog Pod. This is a soft memory limit for the server,
151+
// which the runtime will attempt to meet but makes no guarantees that it will do so. If this value is set, the Pod
152+
// will have the following modifications made to the container running the server:
153+
// - the $GOMEMLIMIT environment variable will be set to this value in bytes
154+
// - the memory request will be set to this value
155+
// - the memory limit will be set to 200% of this value
156+
//
157+
// This field should be set if it's desired to reduce the footprint of a catalog server as much as possible, or if
158+
// a catalog being served is very large and needs more than the default allocation. If your index image has a file-
159+
// system cache, determine a good approximation for this value by doubling the size of the package cache at
160+
// /tmp/cache/cache/packages.json in the index image.
161+
//
162+
// This field is best-effort; if unset, no default will be used and no Pod memory limit or $GOMEMLIMIT value will be set.
163+
MemoryTarget *resource.Quantity `json:"memoryTarget,omitempty"`
148164
}
149165

150166
// UpdateStrategy holds all the different types of catalog source update strategies

staging/api/pkg/operators/v1alpha1/clusterserviceversion.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,19 @@ func (c *ClusterServiceVersion) IsObsolete() bool {
120120

121121
// IsCopied returns true if the CSV has been copied and false otherwise.
122122
func (c *ClusterServiceVersion) IsCopied() bool {
123-
operatorNamespace, ok := c.GetAnnotations()[OperatorGroupNamespaceAnnotationKey]
124-
if c.Status.Reason == CSVReasonCopied || ok && c.GetNamespace() != operatorNamespace {
125-
return true
123+
return c.Status.Reason == CSVReasonCopied || IsCopied(c)
124+
}
125+
126+
func IsCopied(o metav1.Object) bool {
127+
annotations := o.GetAnnotations()
128+
if annotations != nil {
129+
operatorNamespace, ok := annotations[OperatorGroupNamespaceAnnotationKey]
130+
if ok && o.GetNamespace() != operatorNamespace {
131+
return true
132+
}
126133
}
127134

128-
if labels := c.GetLabels(); labels != nil {
135+
if labels := o.GetLabels(); labels != nil {
129136
if _, ok := labels[CopiedLabelKey]; ok {
130137
return true
131138
}

staging/api/pkg/operators/v1alpha1/clusterserviceversion_test.go

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,3 +430,68 @@ func helperNewConditions(count int) []ClusterServiceVersionCondition {
430430

431431
return conditions
432432
}
433+
434+
func TestIsCopied(t *testing.T) {
435+
var testCases = []struct {
436+
name string
437+
input metav1.Object
438+
expected bool
439+
}{
440+
{
441+
name: "no labels or annotations",
442+
input: &metav1.ObjectMeta{},
443+
expected: false,
444+
},
445+
{
446+
name: "no labels, has annotations but missing operatorgroup namespace annotation",
447+
input: &metav1.ObjectMeta{
448+
Annotations: map[string]string{},
449+
},
450+
expected: false,
451+
},
452+
{
453+
name: "no labels, has operatorgroup namespace annotation matching self",
454+
input: &metav1.ObjectMeta{
455+
Namespace: "whatever",
456+
Annotations: map[string]string{
457+
"olm.operatorNamespace": "whatever",
458+
},
459+
},
460+
expected: false,
461+
},
462+
{
463+
name: "no labels, has operatorgroup namespace annotation not matching self",
464+
input: &metav1.ObjectMeta{
465+
Namespace: "whatever",
466+
Annotations: map[string]string{
467+
"olm.operatorNamespace": "other",
468+
},
469+
},
470+
expected: true,
471+
},
472+
{
473+
name: "no annotations, labels missing copied key",
474+
input: &metav1.ObjectMeta{
475+
Labels: map[string]string{},
476+
},
477+
expected: false,
478+
},
479+
{
480+
name: "no annotations, labels has copied key",
481+
input: &metav1.ObjectMeta{
482+
Labels: map[string]string{
483+
"olm.copiedFrom": "whatever",
484+
},
485+
},
486+
expected: true,
487+
},
488+
}
489+
490+
for _, testCase := range testCases {
491+
t.Run(testCase.name, func(t *testing.T) {
492+
if got, expected := IsCopied(testCase.input), testCase.expected; got != expected {
493+
t.Errorf("got %v, expected %v", got, expected)
494+
}
495+
})
496+
}
497+
}

staging/api/pkg/operators/v1alpha1/zz_generated.deepcopy.go

Lines changed: 5 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)