Skip to content
This repository has been archived by the owner on Aug 12, 2024. It is now read-only.

Commit

Permalink
add crd upgrade safety preflight check
Browse files Browse the repository at this point in the history
Signed-off-by: everettraven <[email protected]>
  • Loading branch information
everettraven committed May 13, 2024
1 parent bb7cd98 commit 21cd9e6
Show file tree
Hide file tree
Showing 6 changed files with 457 additions and 13 deletions.
1 change: 1 addition & 0 deletions api/v1alpha2/bundledeployment_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const (
ReasonReconcileFailed = "ReconcileFailed"
ReasonUnhealthy = "Unhealthy"
ReasonUpgradeFailed = "UpgradeFailed"
ReasonPreflightFailed = "PreflightFailed"
)

// BundleDeploymentSpec defines the desired state of BundleDeployment
Expand Down
14 changes: 14 additions & 0 deletions cmd/core/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/gorilla/handlers"
"github.com/spf13/pflag"
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
apiextensionsv1client "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/selection"
Expand All @@ -51,6 +52,7 @@ import (
"github.com/operator-framework/rukpak/internal/provisioner/registry"
"github.com/operator-framework/rukpak/internal/version"
"github.com/operator-framework/rukpak/pkg/features"
"github.com/operator-framework/rukpak/pkg/preflights/crdupgradesafety"
"github.com/operator-framework/rukpak/pkg/source"
"github.com/operator-framework/rukpak/pkg/storage"
"github.com/operator-framework/rukpak/pkg/util"
Expand Down Expand Up @@ -231,11 +233,23 @@ func main() {
setupLog.Error(err, "unable to create action client getter")
os.Exit(1)
}

aeClient, err := apiextensionsv1client.NewForConfig(cfg)
if err != nil {
setupLog.Error(err, "unable to create apiextensions client")
os.Exit(1)
}

preflights := []bundledeployment.Preflight{
crdupgradesafety.NewPreflight(aeClient.CustomResourceDefinitions()),
}

commonBDProvisionerOptions := []bundledeployment.Option{
bundledeployment.WithActionClientGetter(acg),
bundledeployment.WithFinalizers(bundleFinalizers),
bundledeployment.WithStorage(bundleStorage),
bundledeployment.WithUnpacker(unpacker),
bundledeployment.WithPreflights(preflights...),
}

if err := bundledeployment.SetupWithManager(mgr, systemNamespace, append(
Expand Down
17 changes: 14 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module github.com/operator-framework/rukpak

go 1.21
go 1.22

toolchain go1.21.0
toolchain go1.22.0

require (
github.com/containerd/containerd v1.7.15
Expand All @@ -22,6 +22,7 @@ require (
github.com/spf13/cobra v1.8.0
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.9.0
github.com/vmware-tanzu/carvel-kapp v0.61.0
golang.org/x/crypto v0.22.0
golang.org/x/sync v0.7.0
helm.sh/helm/v3 v3.14.4
Expand Down Expand Up @@ -98,6 +99,9 @@ require (
github.com/containers/libtrust v0.0.0-20230121012942-c1716e8a8d01 // indirect
github.com/containers/ocicrypt v1.1.9 // indirect
github.com/containers/storage v1.53.0 // indirect
github.com/cppforlife/cobrautil v0.0.0-20221130162803-acdfead391ef // indirect
github.com/cppforlife/color v1.9.1-0.20200716202919-6706ac40b835 // indirect
github.com/cppforlife/go-cli-ui v0.0.0-20220425131040-94f26b16bc14 // indirect
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dimchansky/utfbom v1.1.1 // indirect
Expand Down Expand Up @@ -148,6 +152,7 @@ require (
github.com/h2non/go-is-svg v0.0.0-20160927212452-35e8c4b0612c // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
github.com/huandu/xstrings v1.4.0 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
Expand All @@ -156,6 +161,8 @@ require (
github.com/jmoiron/sqlx v1.3.5 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/k14s/starlark-go v0.0.0-20200720175618-3a5c849cc368 // indirect
github.com/k14s/ytt v0.36.0 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/klauspost/compress v1.17.7 // indirect
github.com/klauspost/pgzip v1.2.6 // indirect
Expand All @@ -165,7 +172,7 @@ require (
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
Expand All @@ -185,6 +192,7 @@ require (
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0 // indirect
github.com/opencontainers/runtime-spec v1.2.0 // indirect
github.com/openshift/crd-schema-checker v0.0.0-20240404194209-35a9033b1d11 // indirect
github.com/operator-framework/operator-lib v0.12.0 // indirect
github.com/otiai10/copy v1.14.0 // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
Expand All @@ -207,6 +215,9 @@ require (
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 // indirect
github.com/ulikunitz/xz v0.5.11 // indirect
github.com/vbatts/tar-split v0.11.5 // indirect
github.com/vito/go-interact v1.0.1 // indirect
github.com/vmware-tanzu/carvel-kapp-controller v0.50.2 // indirect
github.com/vmware-tanzu/carvel-vendir v0.36.0 // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
Expand Down
Loading

0 comments on commit 21cd9e6

Please sign in to comment.