Skip to content

Commit 09a8f23

Browse files
committed
add a dynamic caching layer for clusterextension managed content
Signed-off-by: everettraven <[email protected]>
1 parent 2eca31d commit 09a8f23

File tree

13 files changed

+868
-68
lines changed

13 files changed

+868
-68
lines changed

.github/workflows/add-to-project.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
name: Add issue to project
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: actions/[email protected].1
14+
- uses: actions/[email protected].2
1515
with:
1616
project-url: https://github.com/orgs/operator-framework/projects/8
1717
github-token: ${{ secrets.ADD_TO_PROJECT_PAT }}

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ test: manifests generate fmt vet test-unit test-e2e #HELP Run all tests.
118118

119119
.PHONY: e2e
120120
e2e: #EXHELP Run the e2e tests.
121-
go test -v ./test/e2e/...
121+
go test -count=1 -v ./test/e2e/...
122122

123123
E2E_REGISTRY_NAME := docker-registry
124124
E2E_REGISTRY_NAMESPACE := operator-controller-e2e
@@ -129,7 +129,7 @@ export CATALOG_IMG := $(REGISTRY_ROOT)/test-catalog:e2e
129129
.PHONY: test-ext-dev-e2e
130130
test-ext-dev-e2e: $(OPERATOR_SDK) $(KUSTOMIZE) $(KIND) #HELP Run extension create, upgrade and delete tests.
131131
test/extension-developer-e2e/setup.sh $(OPERATOR_SDK) $(CONTAINER_RUNTIME) $(KUSTOMIZE) $(KIND) $(KIND_CLUSTER_NAME) $(E2E_REGISTRY_NAMESPACE)
132-
go test -v ./test/extension-developer-e2e/...
132+
go test -count=1 -v ./test/extension-developer-e2e/...
133133

134134
.PHONY: test-unit
135135
ENVTEST_VERSION := $(shell go list -m k8s.io/client-go | cut -d" " -f2 | sed 's/^v0\.\([[:digit:]]\{1,\}\)\.[[:digit:]]\{1,\}$$/1.\1.x/')

api/v1alpha1/clusterextension_types.go

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,30 @@ type ClusterExtensionSpec struct {
7979
// the bundle may contain resources that are cluster-scoped or that are
8080
// installed in a different namespace. This namespace is expected to exist.
8181
InstallNamespace string `json:"installNamespace"`
82+
83+
//+kubebuilder:Optional
84+
// Preflight defines the configuration of preflight checks.
85+
Preflight *PreflightConfig `json:"preflight,omitempty"`
86+
}
87+
88+
// PreflightConfig holds the configuration for the preflight checks.
89+
type PreflightConfig struct {
90+
//+kubebuilder:Required
91+
// CRDUpgradeSafety holds necessary configuration for the CRD Upgrade Safety preflight checks.
92+
CRDUpgradeSafety *CRDUpgradeSafetyPreflightConfig `json:"crdUpgradeSafety,omitempty"`
93+
}
94+
95+
// CRDUpgradeSafetyPreflightConfig is the configuration for CRD upgrade safety preflight check.
96+
type CRDUpgradeSafetyPreflightConfig struct {
97+
//+kubebuilder:Required
98+
// Disabled represents the state of the CRD upgrade safety preflight check being disabled/enabled.
99+
Disabled bool `json:"disabled,omitempty"`
82100
}
83101

84102
const (
85103
// TODO(user): add more Types, here and into init()
86-
TypeInstalled = "Installed"
87-
TypeResolved = "Resolved"
88-
TypeHasValidBundle = "HasValidBundle"
104+
TypeInstalled = "Installed"
105+
TypeResolved = "Resolved"
89106

90107
// TypeDeprecated is a rollup condition that is present when
91108
// any of the deprecated conditions are present.
@@ -103,10 +120,9 @@ const (
103120
ReasonInstallationSucceeded = "InstallationSucceeded"
104121
ReasonResolutionFailed = "ResolutionFailed"
105122

106-
ReasonSuccess = "Success"
107-
ReasonDeprecated = "Deprecated"
108-
ReasonUpgradeFailed = "UpgradeFailed"
109-
ReasonHasValidBundleUnknown = "HasValidBundleUnknown"
123+
ReasonSuccess = "Success"
124+
ReasonDeprecated = "Deprecated"
125+
ReasonUpgradeFailed = "UpgradeFailed"
110126

111127
ReasonUnpackPending = "UnpackPending"
112128
ReasonUnpackSuccess = "UnpackSuccess"
@@ -121,7 +137,6 @@ func init() {
121137
conditionsets.ConditionTypes = append(conditionsets.ConditionTypes,
122138
TypeInstalled,
123139
TypeResolved,
124-
TypeHasValidBundle,
125140
TypeDeprecated,
126141
TypePackageDeprecated,
127142
TypeChannelDeprecated,
@@ -139,7 +154,6 @@ func init() {
139154
ReasonBundleLoadFailed,
140155
ReasonErrorGettingClient,
141156
ReasonInstallationStatusUnknown,
142-
ReasonHasValidBundleUnknown,
143157
ReasonUnpackPending,
144158
ReasonUnpackSuccess,
145159
ReasonUnpackFailed,

api/v1alpha1/zz_generated.deepcopy.go

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

cmd/manager/main.go

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

2727
"github.com/spf13/pflag"
2828
"go.uber.org/zap/zapcore"
29+
apiextensionsv1client "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1"
2930
k8slabels "k8s.io/apimachinery/pkg/labels"
3031
"k8s.io/apimachinery/pkg/selection"
3132
_ "k8s.io/client-go/plugin/pkg/client/auth"
@@ -40,6 +41,7 @@ import (
4041
catalogd "github.com/operator-framework/catalogd/api/core/v1alpha1"
4142
helmclient "github.com/operator-framework/helm-operator-plugins/pkg/client"
4243
registryv1handler "github.com/operator-framework/rukpak/pkg/handler"
44+
crdupgradesafety "github.com/operator-framework/rukpak/pkg/preflights/crdupgradesafety"
4345
"github.com/operator-framework/rukpak/pkg/provisioner/registry"
4446
"github.com/operator-framework/rukpak/pkg/source"
4547
"github.com/operator-framework/rukpak/pkg/storage"
@@ -215,6 +217,16 @@ func main() {
215217
os.Exit(1)
216218
}
217219

220+
aeClient, err := apiextensionsv1client.NewForConfig(mgr.GetConfig())
221+
if err != nil {
222+
setupLog.Error(err, "unable to create apiextensions client")
223+
os.Exit(1)
224+
}
225+
226+
preflights := []controllers.Preflight{
227+
crdupgradesafety.NewPreflight(aeClient.CustomResourceDefinitions()),
228+
}
229+
218230
if err = (&controllers.ClusterExtensionReconciler{
219231
Client: cl,
220232
BundleProvider: catalogClient,
@@ -225,6 +237,7 @@ func main() {
225237
Handler: registryv1handler.HandlerFunc(registry.HandleBundleDeployment),
226238
Finalizers: clusterExtensionFinalizers,
227239
CaCertDir: caCertDir,
240+
Preflights: preflights,
228241
}).SetupWithManager(mgr); err != nil {
229242
setupLog.Error(err, "unable to create controller", "controller", "ClusterExtension")
230243
os.Exit(1)

config/base/crd/bases/olm.operatorframework.io_clusterextensions.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,19 @@ spec:
5959
maxLength: 48
6060
pattern: ^[a-z0-9]+(-[a-z0-9]+)*$
6161
type: string
62+
preflight:
63+
description: Preflight defines the configuration of preflight checks.
64+
properties:
65+
crdUpgradeSafety:
66+
description: CRDUpgradeSafety holds necessary configuration for
67+
the CRD Upgrade Safety preflight checks.
68+
properties:
69+
disabled:
70+
description: Disabled represents the state of the CRD upgrade
71+
safety preflight check being disabled/enabled.
72+
type: boolean
73+
type: object
74+
type: object
6275
upgradeConstraintPolicy:
6376
default: Enforce
6477
description: Defines the policy for how to handle upgrade constraints

go.mod

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ require (
1010
github.com/go-logr/logr v1.4.2
1111
github.com/google/go-cmp v0.6.0
1212
github.com/operator-framework/api v0.26.0
13-
github.com/operator-framework/catalogd v0.14.0
13+
github.com/operator-framework/catalogd v0.15.0
1414
github.com/operator-framework/helm-operator-plugins v0.2.2-0.20240520180534-f463c36fedf9
1515
github.com/operator-framework/operator-registry v1.43.1
1616
github.com/operator-framework/rukpak v0.24.0
@@ -20,15 +20,17 @@ require (
2020
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842
2121
gopkg.in/yaml.v2 v2.4.0
2222
helm.sh/helm/v3 v3.15.2
23-
k8s.io/api v0.30.1
24-
k8s.io/apimachinery v0.30.1
25-
k8s.io/client-go v0.30.1
26-
k8s.io/component-base v0.30.1
23+
k8s.io/api v0.30.2
24+
k8s.io/apiextensions-apiserver v0.30.2
25+
k8s.io/apimachinery v0.30.2
26+
k8s.io/client-go v0.30.2
27+
k8s.io/component-base v0.30.2
2728
k8s.io/utils v0.0.0-20240502163921-fe8a2dddb1d0
2829
sigs.k8s.io/controller-runtime v0.18.4
2930
)
3031

3132
require (
33+
carvel.dev/kapp v0.62.1-0.20240508153820-7d8a03ed7ccf // indirect
3234
cloud.google.com/go/compute/metadata v0.3.0 // indirect
3335
dario.cat/mergo v1.0.0 // indirect
3436
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 // indirect
@@ -86,6 +88,9 @@ require (
8688
github.com/containers/libtrust v0.0.0-20230121012942-c1716e8a8d01 // indirect
8789
github.com/containers/ocicrypt v1.1.10 // indirect
8890
github.com/containers/storage v1.54.0 // indirect
91+
github.com/cppforlife/cobrautil v0.0.0-20221130162803-acdfead391ef // indirect
92+
github.com/cppforlife/color v1.9.1-0.20200716202919-6706ac40b835 // indirect
93+
github.com/cppforlife/go-cli-ui v0.0.0-20220425131040-94f26b16bc14 // indirect
8994
github.com/cyphar/filepath-securejoin v0.2.5 // indirect
9095
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
9196
github.com/dimchansky/utfbom v1.1.1 // indirect
@@ -138,6 +143,7 @@ require (
138143
github.com/h2non/go-is-svg v0.0.0-20160927212452-35e8c4b0612c // indirect
139144
github.com/hashicorp/errwrap v1.1.0 // indirect
140145
github.com/hashicorp/go-multierror v1.1.1 // indirect
146+
github.com/hashicorp/go-version v1.6.0 // indirect
141147
github.com/huandu/xstrings v1.4.0 // indirect
142148
github.com/imdario/mergo v0.3.16 // indirect
143149
github.com/inconshreveable/mousetrap v1.1.0 // indirect
@@ -147,6 +153,8 @@ require (
147153
github.com/joelanford/ignore v0.1.0 // indirect
148154
github.com/josharian/intern v1.0.0 // indirect
149155
github.com/json-iterator/go v1.1.12 // indirect
156+
github.com/k14s/starlark-go v0.0.0-20200720175618-3a5c849cc368 // indirect
157+
github.com/k14s/ytt v0.36.0 // indirect
150158
github.com/kevinburke/ssh_config v1.2.0 // indirect
151159
github.com/klauspost/compress v1.17.8 // indirect
152160
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect
@@ -177,6 +185,7 @@ require (
177185
github.com/opencontainers/go-digest v1.0.0 // indirect
178186
github.com/opencontainers/image-spec v1.1.0 // indirect
179187
github.com/opencontainers/runtime-spec v1.2.0 // indirect
188+
github.com/openshift/crd-schema-checker v0.0.0-20240404194209-35a9033b1d11 // indirect
180189
github.com/operator-framework/operator-lib v0.14.0 // indirect
181190
github.com/otiai10/copy v1.14.0 // indirect
182191
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
@@ -200,6 +209,9 @@ require (
200209
github.com/stretchr/objx v0.5.2 // indirect
201210
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 // indirect
202211
github.com/vbatts/tar-split v0.11.5 // indirect
212+
github.com/vito/go-interact v1.0.1 // indirect
213+
github.com/vmware-tanzu/carvel-kapp-controller v0.50.2 // indirect
214+
github.com/vmware-tanzu/carvel-vendir v0.36.0 // indirect
203215
github.com/xanzy/ssh-agent v0.3.3 // indirect
204216
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
205217
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
@@ -235,8 +247,7 @@ require (
235247
gopkg.in/inf.v0 v0.9.1 // indirect
236248
gopkg.in/warnings.v0 v0.1.2 // indirect
237249
gopkg.in/yaml.v3 v3.0.1 // indirect
238-
k8s.io/apiextensions-apiserver v0.30.1 // indirect
239-
k8s.io/apiserver v0.30.1 // indirect
250+
k8s.io/apiserver v0.30.2 // indirect
240251
k8s.io/cli-runtime v0.30.0 // indirect
241252
k8s.io/klog/v2 v2.120.1 // indirect
242253
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect

0 commit comments

Comments
 (0)