Skip to content

Commit

Permalink
Merge pull request #371 from jakobmoellerdev/OCPVE-587
Browse files Browse the repository at this point in the history
OCPVE-587: chore: update to k8s 1.27.x APIs and bump to go1.20
  • Loading branch information
jeff-roche authored Jul 27, 2023
2 parents 255d754 + 3ca4bf6 commit a962b90
Show file tree
Hide file tree
Showing 830 changed files with 68,093 additions and 30,127 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM golang:1.18 as builder
FROM golang:1.20 as builder

WORKDIR /workspace
# Copy the Go Modules manifests
Expand Down
51 changes: 26 additions & 25 deletions api/v1alpha1/lvmcluster_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/webhook"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
)

// log is for logging in this package.
Expand All @@ -45,69 +46,69 @@ func (l *LVMCluster) SetupWebhookWithManager(mgr ctrl.Manager) error {
}

// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
func (l *LVMCluster) ValidateCreate() error {
func (l *LVMCluster) ValidateCreate() (admission.Warnings, error) {
lvmclusterlog.Info("validate create", "name", l.Name)

err := l.verifySingleDefaultDeviceClass()
if err != nil {
return err
return admission.Warnings{}, err
}

err = l.verifyPathsAreNotEmpty()
if err != nil {
return err
return admission.Warnings{}, err
}

err = l.verifyAbsolutePath()
if err != nil {
return err
return admission.Warnings{}, err
}

err = l.verifyNoDeviceOverlap()
if err != nil {
return err
return admission.Warnings{}, err
}

err = l.verifyFstype()
if err != nil {
return err
return admission.Warnings{}, err
}

return nil
return admission.Warnings{}, nil
}

// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
func (l *LVMCluster) ValidateUpdate(old runtime.Object) error {
func (l *LVMCluster) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
lvmclusterlog.Info("validate update", "name", l.Name)

err := l.verifySingleDefaultDeviceClass()
if err != nil {
return err
return admission.Warnings{}, err
}

err = l.verifyPathsAreNotEmpty()
if err != nil {
return err
return admission.Warnings{}, err
}

err = l.verifyAbsolutePath()
if err != nil {
return err
return admission.Warnings{}, err
}

err = l.verifyNoDeviceOverlap()
if err != nil {
return err
return admission.Warnings{}, err
}

err = l.verifyFstype()
if err != nil {
return err
return admission.Warnings{}, err
}

oldLVMCluster, ok := old.(*LVMCluster)
if !ok {
return fmt.Errorf("Failed to parse LVMCluster.")
return admission.Warnings{}, fmt.Errorf("Failed to parse LVMCluster.")
}

for _, deviceClass := range l.Spec.Storage.DeviceClasses {
Expand All @@ -119,16 +120,16 @@ func (l *LVMCluster) ValidateUpdate(old runtime.Object) error {

if (newThinPoolConfig != nil && oldThinPoolConfig == nil && err != ErrDeviceClassNotFound) ||
(newThinPoolConfig == nil && oldThinPoolConfig != nil) {
return fmt.Errorf("ThinPoolConfig can not be changed")
return admission.Warnings{}, fmt.Errorf("ThinPoolConfig can not be changed")
}

if newThinPoolConfig != nil && oldThinPoolConfig != nil {
if newThinPoolConfig.Name != oldThinPoolConfig.Name {
return fmt.Errorf("ThinPoolConfig.Name can not be changed")
return admission.Warnings{}, fmt.Errorf("ThinPoolConfig.Name can not be changed")
} else if newThinPoolConfig.SizePercent != oldThinPoolConfig.SizePercent {
return fmt.Errorf("ThinPoolConfig.SizePercent can not be changed")
return admission.Warnings{}, fmt.Errorf("ThinPoolConfig.SizePercent can not be changed")
} else if newThinPoolConfig.OverprovisionRatio != oldThinPoolConfig.OverprovisionRatio {
return fmt.Errorf("ThinPoolConfig.OverprovisionRatio can not be changed")
return admission.Warnings{}, fmt.Errorf("ThinPoolConfig.OverprovisionRatio can not be changed")
}
}

Expand All @@ -146,28 +147,28 @@ func (l *LVMCluster) ValidateUpdate(old runtime.Object) error {

// Make sure a device path list was not added
if len(oldDevices) == 0 && len(newDevices) > 0 {
return fmt.Errorf("invalid: device paths can not be added after a device class has been initialized")
return admission.Warnings{}, fmt.Errorf("invalid: device paths can not be added after a device class has been initialized")
}

// Make sure an optionalPaths list was not added
if len(oldOptionalDevices) == 0 && len(newOptionalDevices) > 0 {
return fmt.Errorf("invalid: optional device paths can not be added after a device class has been initialized")
return admission.Warnings{}, fmt.Errorf("invalid: optional device paths can not be added after a device class has been initialized")
}

// Validate all the old paths still exist
err := validateDevicePathsStillExist(oldDevices, newDevices)
if err != nil {
return fmt.Errorf("invalid: required device paths were deleted from the LVMCluster: %v", err)
return admission.Warnings{}, fmt.Errorf("invalid: required device paths were deleted from the LVMCluster: %v", err)
}

// Validate all the old optional paths still exist
err = validateDevicePathsStillExist(oldOptionalDevices, newOptionalDevices)
if err != nil {
return fmt.Errorf("invalid: optional device paths were deleted from the LVMCluster: %v", err)
return admission.Warnings{}, fmt.Errorf("invalid: optional device paths were deleted from the LVMCluster: %v", err)
}
}

return nil
return admission.Warnings{}, nil
}

func validateDevicePathsStillExist(old, new []string) error {
Expand All @@ -190,10 +191,10 @@ func validateDevicePathsStillExist(old, new []string) error {
}

// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
func (l *LVMCluster) ValidateDelete() error {
func (l *LVMCluster) ValidateDelete() (admission.Warnings, error) {
lvmclusterlog.Info("validate delete", "name", l.Name)

return nil
return []string{}, nil
}

func (l *LVMCluster) verifySingleDefaultDeviceClass() error {
Expand Down
9 changes: 4 additions & 5 deletions controllers/lvmcluster_controller_watches.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"sigs.k8s.io/controller-runtime/pkg/source"
)

// SetupWithManager sets up the controller with the Manager.
Expand All @@ -38,23 +37,23 @@ func (r *LVMClusterReconciler) SetupWithManager(mgr ctrl.Manager) error {
Owns(&lvmv1alpha1.LVMVolumeGroup{}).
Owns(&lvmv1alpha1.LVMVolumeGroupNodeStatus{}).
Watches(
&source.Kind{Type: &lvmv1alpha1.LVMVolumeGroupNodeStatus{}},
&lvmv1alpha1.LVMVolumeGroupNodeStatus{},
handler.EnqueueRequestsFromMapFunc(r.getLVMClusterObjsForReconcile),
).
Watches(
&source.Kind{Type: &storagev1.StorageClass{}},
&storagev1.StorageClass{},
handler.EnqueueRequestsFromMapFunc(r.getLVMClusterObjsForReconcile),
).
Complete(r)
}

func (r *LVMClusterReconciler) getLVMClusterObjsForReconcile(obj client.Object) []reconcile.Request {
func (r *LVMClusterReconciler) getLVMClusterObjsForReconcile(ctx context.Context, obj client.Object) []reconcile.Request {
foundLVMClusterList := &lvmv1alpha1.LVMClusterList{}
listOps := &client.ListOptions{
Namespace: obj.GetNamespace(),
}

err := r.Client.List(context.TODO(), foundLVMClusterList, listOps)
err := r.Client.List(ctx, foundLVMClusterList, listOps)
if err != nil {
r.Log.Error(err, "getLVMClusterObjsForReconcile: Failed to get LVMCluster objs")
return []reconcile.Request{}
Expand Down
2 changes: 1 addition & 1 deletion controllers/persistent-volume-claim/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestPersistentVolumeClaimReconciler_Reconcile(t *testing.T) {
objs: []client.Object{
&v1.PersistentVolumeClaim{
ObjectMeta: metav1.ObjectMeta{Namespace: defaultNamespace, Name: "test-deletionTimestamp",
DeletionTimestamp: &metav1.Time{Time: time.Now()}},
DeletionTimestamp: &metav1.Time{Time: time.Now()}, Finalizers: []string{"random-finalizer"}},
},
},
},
Expand Down
81 changes: 40 additions & 41 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
module github.com/openshift/lvm-operator

go 1.18
go 1.20

require (
github.com/aws/aws-sdk-go v1.44.10
github.com/go-logr/logr v1.2.4
github.com/google/go-cmp v0.5.9
github.com/kubernetes-csi/external-snapshotter/client/v4 v4.2.0
github.com/onsi/ginkgo/v2 v2.9.4
github.com/onsi/gomega v1.27.6
github.com/openshift/api v0.0.0-20211028023115-7224b732cc14
github.com/openshift/client-go v0.0.0-20210831095141-e19a065e79f7
github.com/onsi/ginkgo/v2 v2.9.5
github.com/onsi/gomega v1.27.7
github.com/openshift/api v0.0.0-20230613151523-ba04973d3ed1
github.com/openshift/client-go v0.0.0-20230503144108-75015d2347cb
github.com/openshift/custom-resource-status v1.1.2
github.com/operator-framework/api v0.17.1
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.14.0
github.com/stretchr/testify v1.8.0
github.com/prometheus/client_golang v1.16.0
github.com/stretchr/testify v1.8.4
github.com/topolvm/topolvm v0.15.4-0.20221116041433-d58476400ff1
gotest.tools/v3 v3.0.3
k8s.io/api v0.26.1
k8s.io/apimachinery v0.26.1
k8s.io/client-go v0.26.1
k8s.io/component-helpers v0.23.4
k8s.io/utils v0.0.0-20221128185143-99ec85e7a448
sigs.k8s.io/controller-runtime v0.14.6
k8s.io/api v0.27.4
k8s.io/apimachinery v0.27.4
k8s.io/client-go v0.27.4
k8s.io/component-helpers v0.27.4
k8s.io/utils v0.0.0-20230313181309-38a27ef9d749
sigs.k8s.io/controller-runtime v0.15.0
sigs.k8s.io/yaml v1.3.0
)

require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cybozu-go/log v1.6.0 // indirect
github.com/cybozu-go/netutil v1.2.0 // indirect
github.com/cybozu-go/well v1.10.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
github.com/emicklei/go-restful/v3 v3.10.2 // indirect
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-logr/zapr v1.2.3 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.20.0 // indirect
github.com/go-openapi/swag v0.21.1 // indirect
github.com/go-logr/zapr v1.2.4 // indirect
github.com/go-openapi/jsonpointer v0.20.0 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
Expand All @@ -53,55 +53,54 @@ require (
github.com/google/uuid v1.3.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/huandu/xstrings v1.3.1 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/magiconair/properties v1.8.5 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/mitchellh/mapstructure v1.4.3 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pelletier/go-toml v1.9.4 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
github.com/prometheus/client_model v0.4.0 // indirect
github.com/prometheus/common v0.44.0 // indirect
github.com/prometheus/procfs v0.11.1 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/spf13/afero v1.6.0 // indirect
github.com/spf13/cast v1.4.1 // indirect
github.com/spf13/cobra v1.6.0 // indirect
github.com/spf13/cobra v1.6.1 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.10.1 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/net v0.9.0 // indirect
golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5 // indirect
golang.org/x/sys v0.7.0 // indirect
golang.org/x/term v0.7.0 // indirect
golang.org/x/text v0.9.0 // indirect
golang.org/x/net v0.12.0 // indirect
golang.org/x/oauth2 v0.10.0 // indirect
golang.org/x/sys v0.10.0 // indirect
golang.org/x/term v0.10.0 // indirect
golang.org/x/text v0.11.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.8.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
golang.org/x/tools v0.9.1 // indirect
gomodules.xyz/jsonpatch/v2 v2.3.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20220502173005-c8bf987b8c21 // indirect
google.golang.org/grpc v1.49.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
google.golang.org/grpc v1.51.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.66.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.26.1 // indirect
k8s.io/component-base v0.26.1 // indirect
k8s.io/klog/v2 v2.80.1 // indirect
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 // indirect
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
k8s.io/apiextensions-apiserver v0.27.2 // indirect
k8s.io/component-base v0.27.2 // indirect
k8s.io/klog/v2 v2.90.1 // indirect
k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
)
Loading

0 comments on commit a962b90

Please sign in to comment.