Skip to content

Commit c21af9d

Browse files
committed
Small changes
Signed-off-by: Brett Tofel <[email protected]>
1 parent dacf1f0 commit c21af9d

File tree

6 files changed

+230
-141
lines changed

6 files changed

+230
-141
lines changed

.github/workflows/e2e-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- name: Build controller image
2626
run: make e2e-build
2727
- name: Save image
28-
run: docker save quay.io/operator-framework/olm:dev -o olm-image.tar
28+
run: docker save quay.io/operator-framework/olm:local -o olm-image.tar
2929
- name: Upload Docker image as artifact
3030
uses: actions/upload-artifact@v4
3131
with:

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export CONFIGMAP_SERVER_IMAGE ?= quay.io/operator-framework/configmap-operator-r
6363

6464
PKG := github.com/operator-framework/operator-lifecycle-manager
6565
IMAGE_REPO ?= quay.io/operator-framework/olm
66-
IMAGE_TAG ?= dev
66+
IMAGE_TAG ?= "dev"
6767

6868
# Go build settings #
6969

@@ -228,7 +228,7 @@ kind-create: kind-clean #HELP Create a new kind cluster $KIND_CLUSTER_NAME (defa
228228
$(KIND) export kubeconfig --name $(KIND_CLUSTER_NAME)
229229

230230
.PHONY: deploy
231-
OLM_IMAGE := $(IMAGE_REPO):$(IMAGE_TAG)
231+
OLM_IMAGE := quay.io/operator-framework/olm:local
232232
deploy: $(KIND) $(HELM) #HELP Deploy OLM to kind cluster $KIND_CLUSTER_NAME (default: kind-olmv0) using $OLM_IMAGE (default: quay.io/operator-framework/olm:local)
233233
$(KIND) load docker-image $(OLM_IMAGE) --name $(KIND_CLUSTER_NAME); \
234234
$(HELM) upgrade --install olm deploy/chart \

pkg/controller/operators/olm/operator.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ import (
88
"sync"
99
"time"
1010

11-
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/operators/labeller"
12-
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/operators/olm/plugins"
1311
"github.com/sirupsen/logrus"
1412
appsv1 "k8s.io/api/apps/v1"
1513
corev1 "k8s.io/api/core/v1"
@@ -42,11 +40,14 @@ import (
4240

4341
operatorsv1 "github.com/operator-framework/api/pkg/operators/v1"
4442
"github.com/operator-framework/api/pkg/operators/v1alpha1"
43+
4544
"github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned"
4645
"github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/informers/externalversions"
4746
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/certs"
4847
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/install"
48+
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/operators/labeller"
4949
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/operators/olm/overrides"
50+
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/operators/olm/plugins"
5051
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/registry/resolver"
5152
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/clients"
5253
csvutility "github.com/operator-framework/operator-lifecycle-manager/pkg/lib/csv"

pkg/controller/operators/olm/operator_test.go

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020

2121
"github.com/google/go-cmp/cmp"
2222
configfake "github.com/openshift/client-go/config/clientset/versioned/fake"
23-
hashutil "github.com/operator-framework/operator-lifecycle-manager/pkg/lib/kubernetes/pkg/util/hash"
2423
"github.com/sirupsen/logrus"
2524
"github.com/stretchr/testify/assert"
2625
"github.com/stretchr/testify/require"
@@ -44,6 +43,7 @@ import (
4443
metadatafake "k8s.io/client-go/metadata/fake"
4544
"k8s.io/client-go/pkg/version"
4645
"k8s.io/client-go/rest"
46+
clienttesting "k8s.io/client-go/testing"
4747
"k8s.io/client-go/tools/cache"
4848
"k8s.io/client-go/tools/record"
4949
apiregistrationv1 "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1"
@@ -54,7 +54,6 @@ import (
5454
operatorsv1 "github.com/operator-framework/api/pkg/operators/v1"
5555
"github.com/operator-framework/api/pkg/operators/v1alpha1"
5656
opregistry "github.com/operator-framework/operator-registry/pkg/registry"
57-
clienttesting "k8s.io/client-go/testing"
5857

5958
"github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned"
6059
"github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/fake"
@@ -64,6 +63,7 @@ import (
6463
resolvercache "github.com/operator-framework/operator-lifecycle-manager/pkg/controller/registry/resolver/cache"
6564
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/clientfake"
6665
csvutility "github.com/operator-framework/operator-lifecycle-manager/pkg/lib/csv"
66+
hashutil "github.com/operator-framework/operator-lifecycle-manager/pkg/lib/kubernetes/pkg/util/hash"
6767
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/labeler"
6868
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/operatorclient"
6969
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/operatorlister"
@@ -5050,7 +5050,12 @@ func TestSyncOperatorGroups(t *testing.T) {
50505050
},
50515051
targetNamespace: {
50525052
withLabels(
5053-
withAnnotations(targetCSV.DeepCopy(), map[string]string{operatorsv1.OperatorGroupAnnotationKey: "operator-group-1", operatorsv1.OperatorGroupNamespaceAnnotationKey: operatorNamespace}),
5053+
withAnnotations(targetCSV.DeepCopy(), map[string]string{
5054+
operatorsv1.OperatorGroupAnnotationKey: "operator-group-1",
5055+
operatorsv1.OperatorGroupNamespaceAnnotationKey: operatorNamespace,
5056+
"olm.operatorframework.io/nonStatusCopyHash": "9ZxHAHQTkxzAQd7Qkk4Qjz3VAkA8lXwuX9mDX6",
5057+
"olm.operatorframework.io/statusCopyHash": "bedtcmN999WBSJ1RHvM7JfN2NJITrUjJ0g0MoH",
5058+
}),
50545059
labels.Merge(targetCSV.GetLabels(), map[string]string{v1alpha1.CopiedLabelKey: operatorNamespace}),
50555060
),
50565061
&rbacv1.Role{
@@ -5155,7 +5160,12 @@ func TestSyncOperatorGroups(t *testing.T) {
51555160
},
51565161
targetNamespace: {
51575162
withLabels(
5158-
withAnnotations(targetCSV.DeepCopy(), map[string]string{operatorsv1.OperatorGroupAnnotationKey: "operator-group-1", operatorsv1.OperatorGroupNamespaceAnnotationKey: operatorNamespace}),
5163+
withAnnotations(targetCSV.DeepCopy(), map[string]string{
5164+
operatorsv1.OperatorGroupAnnotationKey: "operator-group-1",
5165+
operatorsv1.OperatorGroupNamespaceAnnotationKey: operatorNamespace,
5166+
"olm.operatorframework.io/nonStatusCopyHash": "9ZxHAHQTkxzAQd7Qkk4Qjz3VAkA8lXwuX9mDX6",
5167+
"olm.operatorframework.io/statusCopyHash": "bedtcmN999WBSJ1RHvM7JfN2NJITrUjJ0g0MoH",
5168+
}),
51595169
labels.Merge(targetCSV.GetLabels(), map[string]string{v1alpha1.CopiedLabelKey: operatorNamespace}),
51605170
),
51615171
&rbacv1.Role{
@@ -5312,7 +5322,12 @@ func TestSyncOperatorGroups(t *testing.T) {
53125322
},
53135323
targetNamespace: {
53145324
withLabels(
5315-
withAnnotations(targetCSV.DeepCopy(), map[string]string{operatorsv1.OperatorGroupAnnotationKey: "operator-group-1", operatorsv1.OperatorGroupNamespaceAnnotationKey: operatorNamespace}),
5325+
withAnnotations(targetCSV.DeepCopy(), map[string]string{
5326+
operatorsv1.OperatorGroupAnnotationKey: "operator-group-1",
5327+
operatorsv1.OperatorGroupNamespaceAnnotationKey: operatorNamespace,
5328+
"olm.operatorframework.io/nonStatusCopyHash": "9ZxHAHQTkxzAQd7Qkk4Qjz3VAkA8lXwuX9mDX6",
5329+
"olm.operatorframework.io/statusCopyHash": "bedtcmN999WBSJ1RHvM7JfN2NJITrUjJ0g0MoH",
5330+
}),
53165331
labels.Merge(targetCSV.GetLabels(), map[string]string{v1alpha1.CopiedLabelKey: operatorNamespace}),
53175332
),
53185333
},

pkg/controller/operators/olm/operatorgroup.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -840,9 +840,10 @@ func (a *Operator) copyToNamespace(prototype *v1alpha1.ClusterServiceVersion, ns
840840
existingStatus := existing.Annotations[statusCopyHashAnnotation]
841841

842842
var updated *v1alpha1.ClusterServiceVersion
843+
// Always set the in-memory prototype's nonstatus annotation:
844+
prototype.Annotations[nonStatusCopyHashAnnotation] = nonstatus
843845
if existingNonStatus != nonstatus {
844846
// include updates to the non-status hash annotation if there is a mismatch
845-
prototype.Annotations[nonStatusCopyHashAnnotation] = nonstatus
846847
if updated, err = a.client.OperatorsV1alpha1().ClusterServiceVersions(nsTo).Update(context.TODO(), prototype, metav1.UpdateOptions{}); err != nil {
847848
return nil, fmt.Errorf("failed to update: %w", err)
848849
}
@@ -863,6 +864,10 @@ func (a *Operator) copyToNamespace(prototype *v1alpha1.ClusterServiceVersion, ns
863864
if updated, err = a.client.OperatorsV1alpha1().ClusterServiceVersions(nsTo).Update(context.TODO(), prototype, metav1.UpdateOptions{}); err != nil {
864865
return nil, fmt.Errorf("failed to update: %w", err)
865866
}
867+
} else {
868+
// Even if they're the same, ensure the returned prototype is annotated.
869+
prototype.Annotations[statusCopyHashAnnotation] = status
870+
updated = prototype
866871
}
867872
return &v1alpha1.ClusterServiceVersion{
868873
ObjectMeta: metav1.ObjectMeta{

0 commit comments

Comments
 (0)