Skip to content

Commit ca05ff8

Browse files
Merge pull request #382 from openshift-bot/synchronize-upstream
OPRUN-3957: Synchronize From Upstream Repositories
2 parents 0b44e8c + 6715324 commit ca05ff8

File tree

90 files changed

+6148
-497
lines changed

Some content is hidden

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

90 files changed

+6148
-497
lines changed

Makefile

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,10 @@ export RELEASE_MANIFEST := operator-controller.yaml
8383
export RELEASE_INSTALL := install.sh
8484
export RELEASE_CATALOGS := default-catalogs.yaml
8585

86-
CATALOGS_MANIFEST := ./config/catalogs/clustercatalogs/default-catalogs.yaml
86+
# List of manifests that are checked in
87+
MANIFEST_HOME := ./manifests
88+
STANDARD_MANIFEST := ./manifests/standard.yaml
89+
CATALOGS_MANIFEST := ./manifests/default-catalogs.yaml
8790

8891
# Disable -j flag for make
8992
.NOTPARALLEL:
@@ -143,7 +146,7 @@ KUSTOMIZE_OPCON_RBAC_DIR := config/base/operator-controller/rbac
143146
CRD_WORKING_DIR := crd_work_dir
144147
# Due to https://github.com/kubernetes-sigs/controller-tools/issues/837 we can't specify individual files
145148
# So we have to generate them together and then move them into place
146-
manifests: $(CONTROLLER_GEN) #EXHELP Generate WebhookConfiguration, ClusterRole, and CustomResourceDefinition objects.
149+
manifests: $(CONTROLLER_GEN) $(KUSTOMIZE) #EXHELP Generate WebhookConfiguration, ClusterRole, and CustomResourceDefinition objects.
147150
mkdir $(CRD_WORKING_DIR)
148151
$(CONTROLLER_GEN) --load-build-tags=$(GO_BUILD_TAGS) crd paths="./api/v1/..." output:crd:artifacts:config=$(CRD_WORKING_DIR)
149152
mv $(CRD_WORKING_DIR)/olm.operatorframework.io_clusterextensions.yaml $(KUSTOMIZE_OPCON_CRDS_DIR)
@@ -154,6 +157,9 @@ manifests: $(CONTROLLER_GEN) #EXHELP Generate WebhookConfiguration, ClusterRole,
154157
# Generate the remaining catalogd manifests
155158
$(CONTROLLER_GEN) --load-build-tags=$(GO_BUILD_TAGS) rbac:roleName=manager-role paths="./internal/catalogd/..." output:rbac:artifacts:config=$(KUSTOMIZE_CATD_RBAC_DIR)
156159
$(CONTROLLER_GEN) --load-build-tags=$(GO_BUILD_TAGS) webhook paths="./internal/catalogd/..." output:webhook:artifacts:config=$(KUSTOMIZE_CATD_WEBHOOKS_DIR)
160+
# Generate manifests stored in source-control
161+
mkdir -p $(MANIFEST_HOME)
162+
$(KUSTOMIZE) build $(KUSTOMIZE_BUILD_DIR) > $(STANDARD_MANIFEST)
157163

158164
.PHONY: generate
159165
generate: $(CONTROLLER_GEN) #EXHELP Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
@@ -296,8 +302,8 @@ kind-load: $(KIND) #EXHELP Loads the currently constructed images into the KIND
296302
.PHONY: kind-deploy
297303
kind-deploy: export MANIFEST := $(RELEASE_MANIFEST)
298304
kind-deploy: export DEFAULT_CATALOG := $(RELEASE_CATALOGS)
299-
kind-deploy: manifests $(KUSTOMIZE)
300-
$(KUSTOMIZE) build $(KUSTOMIZE_BUILD_DIR) | sed "s/cert-git-version/cert-$(VERSION)/g" > $(MANIFEST)
305+
kind-deploy: manifests
306+
sed "s/cert-git-version/cert-$(VERSION)/g" $(STANDARD_MANIFEST) > $(MANIFEST)
301307
cp $(CATALOGS_MANIFEST) $(DEFAULT_CATALOG)
302308
envsubst '$$DEFAULT_CATALOG,$$CERT_MGR_VERSION,$$INSTALL_DEFAULT_CATALOGS,$$MANIFEST' < scripts/install.tpl.sh | bash -s
303309

@@ -390,8 +396,9 @@ release: $(GORELEASER) #EXHELP Runs goreleaser for the operator-controller. By d
390396
.PHONY: quickstart
391397
quickstart: export MANIFEST := "https://github.com/operator-framework/operator-controller/releases/download/$(VERSION)/$(notdir $(RELEASE_MANIFEST))"
392398
quickstart: export DEFAULT_CATALOG := "https://github.com/operator-framework/operator-controller/releases/download/$(VERSION)/$(notdir $(RELEASE_CATALOGS))"
393-
quickstart: $(KUSTOMIZE) manifests #EXHELP Generate the unified installation release manifests and scripts.
394-
$(KUSTOMIZE) build $(KUSTOMIZE_BUILD_DIR) | sed "s/cert-git-version/cert-$(VERSION)/g" | sed "s/:devel/:$(VERSION)/g" > $(RELEASE_MANIFEST)
399+
quickstart: manifests #EXHELP Generate the unified installation release manifests and scripts.
400+
# Update the stored standard manifests for distribution
401+
sed "s/:devel/:$(VERSION)/g" $(STANDARD_MANIFEST) | sed "s/cert-git-version/cert-$(VERSION)/g" > $(RELEASE_MANIFEST)
395402
cp $(CATALOGS_MANIFEST) $(RELEASE_CATALOGS)
396403
envsubst '$$DEFAULT_CATALOG,$$CERT_MGR_VERSION,$$INSTALL_DEFAULT_CATALOGS,$$MANIFEST' < scripts/install.tpl.sh > $(RELEASE_INSTALL)
397404

cmd/catalogd/main.go

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ import (
3030

3131
"github.com/containers/image/v5/types"
3232
"github.com/spf13/cobra"
33-
corev1 "k8s.io/api/core/v1"
34-
"k8s.io/apimachinery/pkg/fields"
35-
k8slabels "k8s.io/apimachinery/pkg/labels"
3633
"k8s.io/apimachinery/pkg/runtime"
3734
k8stypes "k8s.io/apimachinery/pkg/types"
3835
apimachineryrand "k8s.io/apimachinery/pkg/util/rand"
@@ -61,8 +58,11 @@ import (
6158
"github.com/operator-framework/operator-controller/internal/catalogd/serverutil"
6259
"github.com/operator-framework/operator-controller/internal/catalogd/storage"
6360
"github.com/operator-framework/operator-controller/internal/catalogd/webhook"
61+
sharedcontrollers "github.com/operator-framework/operator-controller/internal/shared/controllers"
6462
fsutil "github.com/operator-framework/operator-controller/internal/shared/util/fs"
6563
imageutil "github.com/operator-framework/operator-controller/internal/shared/util/image"
64+
"github.com/operator-framework/operator-controller/internal/shared/util/pullsecretcache"
65+
sautil "github.com/operator-framework/operator-controller/internal/shared/util/sa"
6666
"github.com/operator-framework/operator-controller/internal/shared/version"
6767
)
6868

@@ -246,17 +246,19 @@ func run(ctx context.Context) error {
246246
cacheOptions := crcache.Options{
247247
ByObject: map[client.Object]crcache.ByObject{},
248248
}
249-
if cfg.globalPullSecretKey != nil {
250-
cacheOptions.ByObject[&corev1.Secret{}] = crcache.ByObject{
251-
Namespaces: map[string]crcache.Config{
252-
cfg.globalPullSecretKey.Namespace: {
253-
LabelSelector: k8slabels.Everything(),
254-
FieldSelector: fields.SelectorFromSet(map[string]string{
255-
"metadata.name": cfg.globalPullSecretKey.Name,
256-
}),
257-
},
258-
},
259-
}
249+
250+
saKey, err := sautil.GetServiceAccount()
251+
if err != nil {
252+
setupLog.Error(err, "Failed to extract serviceaccount from JWT")
253+
return err
254+
}
255+
setupLog.Info("Successfully extracted serviceaccount from JWT", "serviceaccount",
256+
fmt.Sprintf("%s/%s", saKey.Namespace, saKey.Name))
257+
258+
err = pullsecretcache.SetupPullSecretCache(&cacheOptions, cfg.globalPullSecretKey, saKey)
259+
if err != nil {
260+
setupLog.Error(err, "Unable to setup pull-secret cache")
261+
return err
260262
}
261263

262264
// Create manager
@@ -312,7 +314,7 @@ func run(ctx context.Context) error {
312314
DockerCertPath: cfg.pullCasDir,
313315
OCICertPath: cfg.pullCasDir,
314316
}
315-
if _, err := os.Stat(authFilePath); err == nil && cfg.globalPullSecretKey != nil {
317+
if _, err := os.Stat(authFilePath); err == nil {
316318
logger.Info("using available authentication information for pulling image")
317319
srcContext.AuthFilePath = authFilePath
318320
} else if os.IsNotExist(err) {
@@ -370,17 +372,16 @@ func run(ctx context.Context) error {
370372
return err
371373
}
372374

373-
if cfg.globalPullSecretKey != nil {
374-
setupLog.Info("creating SecretSyncer controller for watching secret", "Secret", cfg.globalPullSecret)
375-
err := (&corecontrollers.PullSecretReconciler{
376-
Client: mgr.GetClient(),
377-
AuthFilePath: authFilePath,
378-
SecretKey: *cfg.globalPullSecretKey,
379-
}).SetupWithManager(mgr)
380-
if err != nil {
381-
setupLog.Error(err, "unable to create controller", "controller", "SecretSyncer")
382-
return err
383-
}
375+
setupLog.Info("creating SecretSyncer controller for watching secret", "Secret", cfg.globalPullSecret)
376+
err = (&sharedcontrollers.PullSecretReconciler{
377+
Client: mgr.GetClient(),
378+
AuthFilePath: authFilePath,
379+
SecretKey: cfg.globalPullSecretKey,
380+
ServiceAccountKey: saKey,
381+
}).SetupWithManager(mgr)
382+
if err != nil {
383+
setupLog.Error(err, "unable to create controller", "controller", "SecretSyncer")
384+
return err
384385
}
385386
//+kubebuilder:scaffold:builder
386387

cmd/operator-controller/main.go

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,8 @@ import (
3030

3131
"github.com/containers/image/v5/types"
3232
"github.com/spf13/cobra"
33-
corev1 "k8s.io/api/core/v1"
3433
rbacv1 "k8s.io/api/rbac/v1"
3534
apiextensionsv1client "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1"
36-
"k8s.io/apimachinery/pkg/fields"
3735
k8slabels "k8s.io/apimachinery/pkg/labels"
3836
k8stypes "k8s.io/apimachinery/pkg/types"
3937
apimachineryrand "k8s.io/apimachinery/pkg/util/rand"
@@ -71,9 +69,12 @@ import (
7169
"github.com/operator-framework/operator-controller/internal/operator-controller/rukpak/render/certproviders"
7270
"github.com/operator-framework/operator-controller/internal/operator-controller/rukpak/render/registryv1"
7371
"github.com/operator-framework/operator-controller/internal/operator-controller/scheme"
72+
sharedcontrollers "github.com/operator-framework/operator-controller/internal/shared/controllers"
7473
fsutil "github.com/operator-framework/operator-controller/internal/shared/util/fs"
7574
httputil "github.com/operator-framework/operator-controller/internal/shared/util/http"
7675
imageutil "github.com/operator-framework/operator-controller/internal/shared/util/image"
76+
"github.com/operator-framework/operator-controller/internal/shared/util/pullsecretcache"
77+
sautil "github.com/operator-framework/operator-controller/internal/shared/util/sa"
7778
"github.com/operator-framework/operator-controller/internal/shared/version"
7879
)
7980

@@ -217,17 +218,19 @@ func run() error {
217218
},
218219
DefaultLabelSelector: k8slabels.Nothing(),
219220
}
220-
if globalPullSecretKey != nil {
221-
cacheOptions.ByObject[&corev1.Secret{}] = crcache.ByObject{
222-
Namespaces: map[string]crcache.Config{
223-
globalPullSecretKey.Namespace: {
224-
LabelSelector: k8slabels.Everything(),
225-
FieldSelector: fields.SelectorFromSet(map[string]string{
226-
"metadata.name": globalPullSecretKey.Name,
227-
}),
228-
},
229-
},
230-
}
221+
222+
saKey, err := sautil.GetServiceAccount()
223+
if err != nil {
224+
setupLog.Error(err, "Failed to extract serviceaccount from JWT")
225+
return err
226+
}
227+
setupLog.Info("Successfully extracted serviceaccount from JWT", "serviceaccount",
228+
fmt.Sprintf("%s/%s", saKey.Namespace, saKey.Name))
229+
230+
err = pullsecretcache.SetupPullSecretCache(&cacheOptions, globalPullSecretKey, saKey)
231+
if err != nil {
232+
setupLog.Error(err, "Unable to setup pull-secret cache")
233+
return err
231234
}
232235

233236
metricsServerOptions := server.Options{}
@@ -360,7 +363,7 @@ func run() error {
360363
OCICertPath: cfg.pullCasDir,
361364
}
362365
logger := log.FromContext(ctx)
363-
if _, err := os.Stat(authFilePath); err == nil && globalPullSecretKey != nil {
366+
if _, err := os.Stat(authFilePath); err == nil {
364367
logger.Info("using available authentication information for pulling image")
365368
srcContext.AuthFilePath = authFilePath
366369
} else if os.IsNotExist(err) {
@@ -482,17 +485,16 @@ func run() error {
482485
return err
483486
}
484487

485-
if globalPullSecretKey != nil {
486-
setupLog.Info("creating SecretSyncer controller for watching secret", "Secret", cfg.globalPullSecret)
487-
err := (&controllers.PullSecretReconciler{
488-
Client: mgr.GetClient(),
489-
AuthFilePath: authFilePath,
490-
SecretKey: *globalPullSecretKey,
491-
}).SetupWithManager(mgr)
492-
if err != nil {
493-
setupLog.Error(err, "unable to create controller", "controller", "SecretSyncer")
494-
return err
495-
}
488+
setupLog.Info("creating SecretSyncer controller for watching secret", "Secret", cfg.globalPullSecret)
489+
err = (&sharedcontrollers.PullSecretReconciler{
490+
Client: mgr.GetClient(),
491+
AuthFilePath: authFilePath,
492+
SecretKey: globalPullSecretKey,
493+
ServiceAccountKey: saKey,
494+
}).SetupWithManager(mgr)
495+
if err != nil {
496+
setupLog.Error(err, "unable to create controller", "controller", "SecretSyncer")
497+
return err
496498
}
497499

498500
//+kubebuilder:scaffold:builder

commitchecker.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
expectedMergeBase: 0c9f0b529d50666f0bd28cb6e34fecf090076235
1+
expectedMergeBase: efc6657e23a9f03ed370e73562c89b72d13ec605
22
upstreamBranch: main
33
upstreamOrg: operator-framework
44
upstreamRepo: operator-controller

config/base/catalogd/rbac/role.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,19 @@ rules:
3030
- get
3131
- patch
3232
- update
33+
---
34+
apiVersion: rbac.authorization.k8s.io/v1
35+
kind: Role
36+
metadata:
37+
name: manager-role
38+
namespace: system
39+
rules:
40+
- apiGroups:
41+
- ""
42+
resources:
43+
- secrets
44+
- serviceaccounts
45+
verbs:
46+
- get
47+
- list
48+
- watch

config/base/catalogd/rbac/role_binding.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,20 @@ subjects:
1313
- kind: ServiceAccount
1414
name: controller-manager
1515
namespace: system
16+
---
17+
apiVersion: rbac.authorization.k8s.io/v1
18+
kind: RoleBinding
19+
metadata:
20+
labels:
21+
app.kubernetes.io/part-of: olm
22+
app.kubernetes.io/name: catalogd
23+
name: manager-rolebinding
24+
namespace: system
25+
roleRef:
26+
apiGroup: rbac.authorization.k8s.io
27+
kind: Role
28+
name: manager-role
29+
subjects:
30+
- kind: ServiceAccount
31+
name: controller-manager
32+
namespace: system

config/base/operator-controller/rbac/role.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,11 @@ rules:
7777
- patch
7878
- update
7979
- watch
80+
- apiGroups:
81+
- ""
82+
resources:
83+
- serviceaccounts
84+
verbs:
85+
- get
86+
- list
87+
- watch
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: catalogd-controller-manager
5+
namespace: olmv1-system
6+
spec:
7+
template:
8+
spec:
9+
containers:
10+
- name: manager
11+
env:
12+
- name: GOCOVERDIR
13+
value: /e2e-coverage
14+
volumeMounts:
15+
- name: e2e-coverage-volume
16+
mountPath: /e2e-coverage
17+
volumes:
18+
- name: e2e-coverage-volume
19+
persistentVolumeClaim:
20+
claimName: e2e-coverage

config/components/coverage/kustomization.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ resources:
55
- manager_e2e_coverage_pvc.yaml
66
- manager_e2e_coverage_copy_pod.yaml
77
patches:
8-
- path: manager_e2e_coverage_patch.yaml
8+
- path: operator_controller_manager_e2e_coverage_patch.yaml
9+
- path: catalogd_manager_e2e_coverage_patch.yaml

0 commit comments

Comments
 (0)