Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
0796ecf
:seedling: Bump github.com/google/go-containerregistry (#1059)
dependabot[bot] Jul 18, 2024
5106e15
Move all e2e scripts into one location (#1046)
m1kola Jul 18, 2024
9b39e32
Bump go to 1.22.5 (#1064)
m1kola Jul 18, 2024
ea7d9a0
:seedling: Bump carvel.dev/kapp (#1063)
dependabot[bot] Jul 18, 2024
b184d0c
:seedling: Bump github.com/containerd/containerd from 1.7.19 to 1.7.2…
dependabot[bot] Jul 18, 2024
aff11ee
:seedling: Bump github.com/operator-framework/operator-registry (#1066)
dependabot[bot] Jul 18, 2024
3f06480
Bump k8s dependencies (#1069)
m1kola Jul 18, 2024
cae1cf1
BundleSource cleanup (#1061)
dtfranz Jul 18, 2024
775613f
Add dependabot K8s dependencies group (#1070)
m1kola Jul 18, 2024
95b9f0d
:sparkles: Wire up Service Account (#1038)
theishshah Jul 18, 2024
245436c
add cluster-admin permissions to o-c SA temporarily (#1073)
everettraven Jul 19, 2024
a0fca0d
bump catalogd to v0.19.0 (#1075)
grokspawn Jul 20, 2024
58c5776
✨ Cleaner Condition Types & Reasons (#1007)
bentito Jul 22, 2024
e3e6b03
:seedling: Add support for CA/certificate rotation (#1062)
tmshort Jul 22, 2024
b73ea5c
:sparkles: wire up ServiceAccount based caching layer (#1074)
everettraven Jul 22, 2024
117e10a
:seedling: Bump github.com/operator-framework/helm-operator-plugins (…
dependabot[bot] Jul 25, 2024
ea9ebca
:seedling: Bump mkdocs-material from 9.5.29 to 9.5.30 (#1076)
dependabot[bot] Jul 25, 2024
c5ac084
:seedling: Bump regex from 2024.5.15 to 2024.7.24 (#1080)
dependabot[bot] Jul 25, 2024
06b2455
:seedling: Bump github.com/operator-framework/catalogd (#1078)
dependabot[bot] Jul 25, 2024
ed87a01
Install default-catalogs from Catalogd release (#1079)
trgeiger Jul 26, 2024
ff0ce68
:seedling: Bump github.com/onsi/ginkgo/v2 from 2.19.0 to 2.19.1 (#1082)
dependabot[bot] Jul 29, 2024
c3a63b2
:seedling: Bump github.com/docker/docker (#1086)
dependabot[bot] Jul 30, 2024
e8e6089
:seedling: Bump pymdown-extensions from 10.8.1 to 10.9 (#1085)
dependabot[bot] Jul 30, 2024
2459d58
:seedling: Bump github.com/onsi/gomega from 1.34.0 to 1.34.1 (#1087)
dependabot[bot] Jul 30, 2024
2554b83
Bundle + CRD Upgrade Safety Tests (#1084)
dtfranz Jul 30, 2024
989a3df
Bug: remove old conditional in ClusterExtension (#1089)
trgeiger Jul 31, 2024
2284472
Merge branch 'main' into synchronize
Aug 2, 2024
3928ed0
UPSTREAM: <carry>: Add OpenShift specific files
dtfranz Oct 26, 2023
ebee561
UPSTREAM: <carry>: Drop commitchecker
awgreene Nov 3, 2023
6f9fe2d
UPSTREAM: <carry>: Updating ose-olm-operator-controller-container ima…
Dec 16, 2023
bbd6a7f
UPSTREAM: <carry>: update owners
Mar 27, 2024
37cd896
UPSTREAM: <carry>: Add pointer to tooling README
bentito Apr 1, 2024
b399f1b
UPSTREAM: <carry>: Disable Validating Admission Policy APIs downstream
Apr 26, 2024
7de1ca0
UPSTREAM: <carry>: Updating ose-olm-operator-controller-container ima…
Mar 27, 2024
457ba8a
UPSTREAM: <carry>: Enable Validating Admission Policy APIs downstream
Apr 30, 2024
4746830
UPSTREAM: <carry>: manifests: set required-scc for openshift workloads
liouk May 2, 2024
df26eb9
UPSTREAM: <carry>: Updating ose-olm-operator-controller-container ima…
May 25, 2024
1e7a713
UPSTREAM: <carry>: add everettraven to approvers+reviewers
everettraven Jun 24, 2024
32bbcdf
UPSTREAM: <carry>: add openshift kustomize overlay
everettraven Jul 9, 2024
62c781c
UPSTREAM: <drop>: go mod vendor
Aug 2, 2024
0933941
UPSTREAM: <drop>: remove upstream GitHub configuration
Aug 2, 2024
4ca3974
UPSTREAM: <drop>: configure the commit-checker
Aug 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ export CERT_MGR_VERSION := v1.9.0
export CATALOGD_VERSION := $(shell go list -mod=mod -m -f "{{.Version}}" github.com/operator-framework/catalogd)
export WAIT_TIMEOUT := 60s

# Install default ClusterCatalogs
export INSTALL_DEFAULT_CATALOGS := true

# By default setup-envtest will write to $XDG_DATA_HOME, or $HOME/.local/share if that is not defined.
# If $HOME is not set, we need to specify a binary directory to prevent an error in setup-envtest.
# Useful for some CI/CD environments that set neither $XDG_DATA_HOME nor $HOME.
Expand Down Expand Up @@ -148,11 +151,11 @@ test-unit: $(SETUP_ENVTEST) #HELP Run the unit tests
eval $$($(SETUP_ENVTEST) use -p env $(ENVTEST_VERSION) $(SETUP_ENVTEST_BIN_DIR_OVERRIDE)) && CGO_ENABLED=1 go test -count=1 -race -short $(UNIT_TEST_DIRS) -cover -coverprofile ${ROOT_DIR}/coverage/unit.out -test.gocoverdir=$(ROOT_DIR)/coverage/unit

image-registry: ## Setup in-cluster image registry
./test/tools/image-registry.sh $(E2E_REGISTRY_NAMESPACE) $(E2E_REGISTRY_NAME)
./hack/test/image-registry.sh $(E2E_REGISTRY_NAMESPACE) $(E2E_REGISTRY_NAME)

build-push-e2e-catalog: ## Build the testdata catalog used for e2e tests and push it to the image registry
./test/tools/build-push-e2e-catalog.sh $(E2E_REGISTRY_NAMESPACE) $(LOCAL_REGISTRY_HOST)/$(E2E_TEST_CATALOG_V1)
./test/tools/build-push-e2e-catalog.sh $(E2E_REGISTRY_NAMESPACE) $(LOCAL_REGISTRY_HOST)/$(E2E_TEST_CATALOG_V2)
./hack/test/build-push-e2e-catalog.sh $(E2E_REGISTRY_NAMESPACE) $(LOCAL_REGISTRY_HOST)/$(E2E_TEST_CATALOG_V1)
./hack/test/build-push-e2e-catalog.sh $(E2E_REGISTRY_NAMESPACE) $(LOCAL_REGISTRY_HOST)/$(E2E_TEST_CATALOG_V2)

# When running the e2e suite, you can set the ARTIFACT_PATH variable to the absolute path
# of the directory for the operator-controller e2e tests to store the artifacts, which
Expand All @@ -168,6 +171,7 @@ test-e2e: run image-registry build-push-e2e-catalog registry-load-bundles e2e e2
.PHONY: extension-developer-e2e
extension-developer-e2e: KUSTOMIZE_BUILD_DIR := config/overlays/cert-manager
extension-developer-e2e: KIND_CLUSTER_NAME := operator-controller-ext-dev-e2e #EXHELP Run extension-developer e2e on local kind cluster
extension-developer-e2e: export INSTALL_DEFAULT_CATALOGS := false #EXHELP Run extension-developer e2e on local kind cluster
extension-developer-e2e: run image-registry test-ext-dev-e2e kind-clean

.PHONY: run-latest-release
Expand All @@ -176,7 +180,7 @@ run-latest-release:

.PHONY: pre-upgrade-setup
pre-upgrade-setup:
./hack/pre-upgrade-setup.sh $(CATALOG_IMG) $(TEST_CLUSTER_CATALOG_NAME) $(TEST_CLUSTER_EXTENSION_NAME)
./hack/test/pre-upgrade-setup.sh $(CATALOG_IMG) $(TEST_CLUSTER_CATALOG_NAME) $(TEST_CLUSTER_EXTENSION_NAME)

.PHONY: post-upgrade-checks
post-upgrade-checks:
Expand All @@ -190,7 +194,7 @@ test-upgrade-e2e: kind-cluster run-latest-release image-registry build-push-e2e-

.PHONY: e2e-coverage
e2e-coverage:
COVERAGE_OUTPUT=./coverage/e2e.out ./hack/e2e-coverage.sh
COVERAGE_OUTPUT=./coverage/e2e.out ./hack/test/e2e-coverage.sh

.PHONY: kind-load
kind-load: $(KIND) #EXHELP Loads the currently constructed image onto the cluster.
Expand All @@ -200,7 +204,7 @@ kind-load: $(KIND) #EXHELP Loads the currently constructed image onto the cluste
kind-deploy: export MANIFEST="./operator-controller.yaml"
kind-deploy: manifests $(KUSTOMIZE) #EXHELP Install controller and dependencies onto the kind cluster.
$(KUSTOMIZE) build $(KUSTOMIZE_BUILD_DIR) > operator-controller.yaml
envsubst '$$CATALOGD_VERSION,$$CERT_MGR_VERSION,$$MANIFEST' < scripts/install.tpl.sh | bash -s
envsubst '$$CATALOGD_VERSION,$$CERT_MGR_VERSION,$$INSTALL_DEFAULT_CATALOGS,$$MANIFEST' < scripts/install.tpl.sh | bash -s

.PHONY: kind-cluster
kind-cluster: $(KIND) #EXHELP Standup a kind cluster.
Expand Down Expand Up @@ -284,7 +288,7 @@ release: $(GORELEASER) #EXHELP Runs goreleaser for the operator-controller. By d
quickstart: export MANIFEST := https://github.com/operator-framework/operator-controller/releases/download/$(VERSION)/operator-controller.yaml
quickstart: $(KUSTOMIZE) manifests #EXHELP Generate the installation release manifests and scripts.
$(KUSTOMIZE) build $(KUSTOMIZE_BUILD_DIR) | sed "s/:devel/:$(VERSION)/g" > operator-controller.yaml
envsubst '$$CATALOGD_VERSION,$$CERT_MGR_VERSION,$$MANIFEST' < scripts/install.tpl.sh > install.sh
envsubst '$$CATALOGD_VERSION,$$CERT_MGR_VERSION,$$INSTALL_DEFAULT_CATALOGS,$$MANIFEST' < scripts/install.tpl.sh > install.sh

##@ Docs

Expand Down
17 changes: 6 additions & 11 deletions api/v1alpha1/clusterextension_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,21 +128,17 @@ const (
ReasonErrorGettingClient = "ErrorGettingClient"
ReasonBundleLoadFailed = "BundleLoadFailed"

ReasonInstallationFailed = "InstallationFailed"
ReasonInstallationStatusUnknown = "InstallationStatusUnknown"
ReasonInstallationSucceeded = "InstallationSucceeded"
ReasonResolutionFailed = "ResolutionFailed"
ReasonInstallationFailed = "InstallationFailed"
ReasonResolutionFailed = "ResolutionFailed"

ReasonSuccess = "Success"
ReasonDeprecated = "Deprecated"
ReasonUpgradeFailed = "UpgradeFailed"

ReasonUnpackPending = "UnpackPending"
ReasonUnpackSuccess = "UnpackSuccess"
ReasonUnpackFailed = "UnpackFailed"

ReasonErrorGettingReleaseState = "ErrorGettingReleaseState"
ReasonCreateDynamicWatchFailed = "CreateDynamicWatchFailed"
)

func init() {
Expand All @@ -158,20 +154,16 @@ func init() {
)
// TODO(user): add Reasons from above
conditionsets.ConditionReasons = append(conditionsets.ConditionReasons,
ReasonInstallationSucceeded,
ReasonResolutionFailed,
ReasonInstallationFailed,
ReasonSuccess,
ReasonDeprecated,
ReasonUpgradeFailed,
ReasonBundleLoadFailed,
ReasonErrorGettingClient,
ReasonInstallationStatusUnknown,
ReasonUnpackPending,
ReasonUnpackSuccess,
ReasonUnpackFailed,
ReasonErrorGettingReleaseState,
ReasonCreateDynamicWatchFailed,
)
}

Expand All @@ -180,8 +172,11 @@ type BundleMetadata struct {
Version string `json:"version"`
}

// ClusterExtensionStatus defines the observed state of ClusterExtension
// ClusterExtensionStatus defines the observed state of ClusterExtension.
type ClusterExtensionStatus struct {
// InstalledBundle should only be modified when a new bundle is successfully installed. This ensures that if there
// is a previously successfully installed a bundle, and an upgrade fails, it is still communicated that there is
// still a bundle that is currently installed and owned by the ClusterExtension.
// +optional
InstalledBundle *BundleMetadata `json:"installedBundle,omitempty"`
// +optional
Expand Down
52 changes: 41 additions & 11 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,20 @@ import (
"context"
"flag"
"fmt"
"net/http"
"os"
"path/filepath"
"time"

"github.com/spf13/pflag"
"go.uber.org/zap/zapcore"
apiextensionsv1client "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1"
k8slabels "k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/selection"
"k8s.io/apimachinery/pkg/types"
corev1client "k8s.io/client-go/kubernetes/typed/core/v1"
_ "k8s.io/client-go/plugin/pkg/client/auth"
"k8s.io/client-go/rest"
ctrl "sigs.k8s.io/controller-runtime"
crcache "sigs.k8s.io/controller-runtime/pkg/cache"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand All @@ -42,8 +47,10 @@ import (

ocv1alpha1 "github.com/operator-framework/operator-controller/api/v1alpha1"
"github.com/operator-framework/operator-controller/internal/action"
"github.com/operator-framework/operator-controller/internal/authentication"
"github.com/operator-framework/operator-controller/internal/catalogmetadata/cache"
catalogclient "github.com/operator-framework/operator-controller/internal/catalogmetadata/client"
"github.com/operator-framework/operator-controller/internal/contentmanager"
"github.com/operator-framework/operator-controller/internal/controllers"
"github.com/operator-framework/operator-controller/internal/httputil"
"github.com/operator-framework/operator-controller/internal/labels"
Expand Down Expand Up @@ -158,9 +165,36 @@ func main() {
ext := obj.(*ocv1alpha1.ClusterExtension)
return ext.Spec.InstallNamespace, nil
})
coreClient, err := corev1client.NewForConfig(mgr.GetConfig())
if err != nil {
setupLog.Error(err, "unable to create core client")
os.Exit(1)
}
tokenGetter := authentication.NewTokenGetter(coreClient, authentication.WithExpirationDuration(1*time.Hour))

restConfigMapper := func(ctx context.Context, o client.Object, c *rest.Config) (*rest.Config, error) {
cExt, ok := o.(*ocv1alpha1.ClusterExtension)
if !ok {
return c, nil
}
namespacedName := types.NamespacedName{
Name: cExt.Spec.ServiceAccount.Name,
Namespace: cExt.Spec.InstallNamespace,
}
tempConfig := rest.AnonymousClientConfig(c)
tempConfig.WrapTransport = func(rt http.RoundTripper) http.RoundTripper {
return &authentication.TokenInjectingRoundTripper{
Tripper: rt,
TokenGetter: tokenGetter,
Key: namespacedName,
}
}
return tempConfig, nil
}
cfgGetter, err := helmclient.NewActionConfigGetter(mgr.GetConfig(), mgr.GetRESTMapper(),
helmclient.StorageNamespaceMapper(installNamespaceMapper),
helmclient.ClientNamespaceMapper(installNamespaceMapper),
helmclient.RestConfigMapper(restConfigMapper),
)
if err != nil {
setupLog.Error(err, "unable to config for creating helm client")
Expand All @@ -170,22 +204,21 @@ func main() {
acg, err := action.NewWrappedActionClientGetter(cfgGetter,
helmclient.WithFailureRollbacks(false),
)

if err != nil {
setupLog.Error(err, "unable to create helm client")
os.Exit(1)
}

certPool, err := httputil.NewCertPool(caCertDir)
certPoolWatcher, err := httputil.NewCertPoolWatcher(caCertDir, ctrl.Log.WithName("cert-pool"))
if err != nil {
setupLog.Error(err, "unable to create CA certificate pool")
os.Exit(1)
}
unpacker := &source.ImageRegistry{
BaseCachePath: filepath.Join(cachePath, "unpack"),
// TODO: This needs to be derived per extension via ext.Spec.InstallNamespace
AuthNamespace: systemNamespace,
CaCertPool: certPool,
AuthNamespace: systemNamespace,
CertPoolWatcher: certPoolWatcher,
}

clusterExtensionFinalizers := crfinalizer.NewFinalizers()
Expand All @@ -210,18 +243,15 @@ func main() {
}

cl := mgr.GetClient()
httpClient, err := httputil.BuildHTTPClient(certPool)
if err != nil {
setupLog.Error(err, "unable to create catalogd http client")
os.Exit(1)
}

catalogsCachePath := filepath.Join(cachePath, "catalogs")
if err := os.MkdirAll(catalogsCachePath, 0700); err != nil {
setupLog.Error(err, "unable to create catalogs cache directory")
os.Exit(1)
}
catalogClient := catalogclient.New(cache.NewFilesystemCache(catalogsCachePath, httpClient))
catalogClient := catalogclient.New(cache.NewFilesystemCache(catalogsCachePath, func() (*http.Client, error) {
return httputil.BuildHTTPClient(certPoolWatcher)
}))

resolver := &resolve.CatalogResolver{
WalkCatalogsFunc: resolve.CatalogWalker(
Expand All @@ -243,8 +273,8 @@ func main() {
Unpacker: unpacker,
InstalledBundleGetter: &controllers.DefaultInstalledBundleGetter{ActionClientGetter: acg},
Finalizers: clusterExtensionFinalizers,
CaCertPool: certPool,
Preflights: preflights,
Watcher: contentmanager.New(restConfigMapper, mgr.GetConfig(), mgr.GetRESTMapper()),
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "ClusterExtension")
os.Exit(1)
Expand Down
2 changes: 1 addition & 1 deletion commitchecker.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
expectedMergeBase: 6cd022e8e4d3825175c05a9ceecb748291a1a8f1
expectedMergeBase: 989a3df266062b3add4b4f330aa0f61659de0994
upstreamBranch: main
upstreamOrg: operator-framework
upstreamRepo: operator-controller
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ spec:
- serviceAccount
type: object
status:
description: ClusterExtensionStatus defines the observed state of ClusterExtension
description: ClusterExtensionStatus defines the observed state of ClusterExtension.
properties:
conditions:
items:
Expand Down Expand Up @@ -188,6 +188,10 @@ spec:
- type
x-kubernetes-list-type: map
installedBundle:
description: |-
InstalledBundle should only be modified when a new bundle is successfully installed. This ensures that if there
is a previously successfully installed a bundle, and an upgrade fails, it is still communicated that there is
still a bundle that is currently installed and owned by the ClusterExtension.
properties:
name:
type: string
Expand Down
14 changes: 11 additions & 3 deletions config/base/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ metadata:
name: manager-role
rules:
- apiGroups:
- '*'
- apiextensions.k8s.io
resources:
- '*'
- customresourcedefinitions
verbs:
- '*'
- get
- apiGroups:
- catalogd.operatorframework.io
resources:
Expand All @@ -36,13 +36,21 @@ rules:
- patch
- update
- watch
- apiGroups:
- ""
resources:
- serviceaccounts/token
verbs:
- create
- apiGroups:
- olm.operatorframework.io
resources:
- clusterextensions
verbs:
- get
- list
- patch
- update
- watch
- apiGroups:
- olm.operatorframework.io
Expand Down
2 changes: 1 addition & 1 deletion config/components/tls/patches/manager_deployment_cert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
value: {"name":"olmv1-certificate", "secret":{"secretName":"olmv1-cert", "optional": false, "items": [{"key": "ca.crt", "path": "olm-ca.crt"}]}}
- op: add
path: /spec/template/spec/containers/0/volumeMounts/-
value: {"name":"olmv1-certificate", "readOnly": true, "mountPath":"/var/certs/olm-ca.crt", "subPath":"olm-ca.crt"}
value: {"name":"olmv1-certificate", "readOnly": true, "mountPath":"/var/certs/"}
- op: add
path: /spec/template/spec/containers/0/args/-
value: "--ca-certs-dir=/var/certs"
2 changes: 1 addition & 1 deletion config/samples/olm_v1alpha1_clusterextension.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ spec:
packageName: argocd-operator
version: 0.6.0
serviceAccount:
name: argocd-installer
name: default
Loading