Skip to content

Commit

Permalink
Merge pull request #170 from red-hat-storage/sync_us--main
Browse files Browse the repository at this point in the history
Syncing latest changes from upstream main for ramen
  • Loading branch information
ShyamsundarR authored Jan 13, 2024
2 parents 1cde0d5 + bd1de0c commit 8aaed55
Show file tree
Hide file tree
Showing 33 changed files with 1,455 additions and 1,620 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ env:
IMAGE_NAME: ${{ vars.IMAGE_NAME || 'ramen' }}
OPERATOR_SUGGESTED_NAMESPACE: ${{ vars.OPERATOR_SUGGESTED_NAMESPACE || 'ramen-system' }}
# Constants
GO_VERSION: "1.19"
GO_VERSION: "1.21"
IMAGE_REGISTRY: "quay.io"
IMAGE_TAG: "ci"
DOCKERCMD: "podman"
Expand All @@ -39,6 +39,11 @@ jobs:
- name: Checkout source
uses: actions/checkout@v3

- name: Setup go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}

- name: Install prereqs
run: |
echo 'APT::Acquire::Retries "5";' | sudo tee /etc/apt/apt.conf.d/80-retries
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# SPDX-License-Identifier: Apache-2.0

# Build the manager binary
FROM docker.io/library/golang:1.19.1 as builder
FROM docker.io/library/golang:1.21 as builder

WORKDIR /workspace
# Copy the Go Modules manifests
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ IMAGE_NAME ?= ramen
IMAGE_TAG ?= latest
PLATFORM ?= k8s
IMAGE_TAG_BASE = $(IMAGE_REGISTRY)/$(IMAGE_REPOSITORY)/$(IMAGE_NAME)
RBAC_PROXY_IMG ?= "gcr.io/kubebuilder/kube-rbac-proxy:v0.13.0"
RBAC_PROXY_IMG ?= "gcr.io/kubebuilder/kube-rbac-proxy:v0.13.1"
OPERATOR_SUGGESTED_NAMESPACE ?= ramen-system
AUTO_CONFIGURE_DR_CLUSTER ?= true
KUBE_OBJECT_PROTECTION_DISABLED ?= false
Expand Down Expand Up @@ -258,7 +258,7 @@ undeploy-dr-cluster: kustomize ## Undeploy dr-cluster controller from the K8s cl
##@ Tools

CONTROLLER_GEN = $(shell pwd)/bin/controller-gen
controller_gen_version=v0.9.2
controller_gen_version=v0.14.0
controller-gen: ## Download controller-gen locally if necessary.
@test '$(shell $(CONTROLLER_GEN) --version)' = 'Version: $(controller_gen_version)' ||\
$(call go-get-tool,sigs.k8s.io/controller-tools/cmd/controller-gen@$(controller_gen_version))
Expand Down
23 changes: 12 additions & 11 deletions api/v1alpha1/drcluster_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,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 @@ -27,50 +28,50 @@ func (r *DRCluster) SetupWebhookWithManager(mgr ctrl.Manager) error {
var _ webhook.Validator = &DRCluster{}

// ValidateCreate checks
func (r *DRCluster) ValidateCreate() error {
func (r *DRCluster) ValidateCreate() (admission.Warnings, error) {
drclusterlog.Info("validate create", "name", r.Name)

return r.ValidateDRCluster()
}

// ValidateUpdate checks
func (r *DRCluster) ValidateUpdate(old runtime.Object) error {
func (r *DRCluster) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
drclusterlog.Info("validate update", "name", r.Name)

oldDRCluster, ok := old.(*DRCluster)
if !ok {
return fmt.Errorf("error casting old DRCluster")
return nil, fmt.Errorf("error casting old DRCluster")
}

// check for immutability for Region and S3ProfileName
if r.Spec.Region != oldDRCluster.Spec.Region {
return fmt.Errorf("Region cannot be changed")
return nil, fmt.Errorf("Region cannot be changed")
}

if r.Spec.S3ProfileName != oldDRCluster.Spec.S3ProfileName {
return fmt.Errorf("S3ProfileName cannot be changed")
return nil, fmt.Errorf("S3ProfileName cannot be changed")
}

return r.ValidateDRCluster()
}

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

return nil
return nil, nil
}

func (r *DRCluster) ValidateDRCluster() error {
func (r *DRCluster) ValidateDRCluster() (admission.Warnings, error) {
if r.Spec.Region == "" {
return fmt.Errorf("Region cannot be empty")
return nil, fmt.Errorf("Region cannot be empty")
}

if r.Spec.S3ProfileName == "" {
return fmt.Errorf("S3ProfileName cannot be empty")
return nil, fmt.Errorf("S3ProfileName cannot be empty")
}

// TODO: We can add other validations like validation of CIDRs format

return nil
return nil, nil
}
21 changes: 11 additions & 10 deletions api/v1alpha1/drplacementcontrol_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,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 @@ -28,19 +29,19 @@ func (r *DRPlacementControl) SetupWebhookWithManager(mgr ctrl.Manager) error {
var _ webhook.Validator = &DRPlacementControl{}

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

return nil
return nil, nil
}

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

oldDRPC, ok := old.(*DRPlacementControl)
if !ok {
return fmt.Errorf("error casting old DRPC")
return nil, fmt.Errorf("error casting old DRPC")
}

// checks for immutability
Expand All @@ -49,31 +50,31 @@ func (r *DRPlacementControl) ValidateUpdate(old runtime.Object) error {
"old", oldDRPC.Spec.PlacementRef,
"new", r.Spec.PlacementRef)

return fmt.Errorf("PlacementRef cannot be changed")
return nil, fmt.Errorf("PlacementRef cannot be changed")
}

if !reflect.DeepEqual(r.Spec.DRPolicyRef, oldDRPC.Spec.DRPolicyRef) {
drplacementcontrollog.Info("detected DRPolicyRef updates, which is disallowed", "name", r.Name,
"old", oldDRPC.Spec.DRPolicyRef,
"new", r.Spec.DRPolicyRef)

return fmt.Errorf("DRPolicyRef cannot be changed")
return nil, fmt.Errorf("DRPolicyRef cannot be changed")
}

if !reflect.DeepEqual(r.Spec.PVCSelector, oldDRPC.Spec.PVCSelector) {
drplacementcontrollog.Info("detected PVCSelector updates, which is disallowed", "name", r.Name,
"old", oldDRPC.Spec.PVCSelector,
"new", r.Spec.PVCSelector)

return fmt.Errorf("PVCSelector cannot be changed")
return nil, fmt.Errorf("PVCSelector cannot be changed")
}

return nil
return nil, nil
}

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

return nil
return nil, nil
}
23 changes: 12 additions & 11 deletions api/v1alpha1/drpolicy_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,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 @@ -28,45 +29,45 @@ func (r *DRPolicy) SetupWebhookWithManager(mgr ctrl.Manager) error {
var _ webhook.Validator = &DRPolicy{}

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

return nil
return nil, nil
}

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

oldDRPolicy, ok := old.(*DRPolicy)

if !ok {
return fmt.Errorf("error casting old DRPolicy")
return nil, fmt.Errorf("error casting old DRPolicy")
}

// checks for immutability
if r.Spec.SchedulingInterval != oldDRPolicy.Spec.SchedulingInterval {
return fmt.Errorf("SchedulingInterval cannot be changed")
return nil, fmt.Errorf("SchedulingInterval cannot be changed")
}

if !reflect.DeepEqual(r.Spec.ReplicationClassSelector, oldDRPolicy.Spec.ReplicationClassSelector) {
return fmt.Errorf("ReplicationClassSelector cannot be changed")
return nil, fmt.Errorf("ReplicationClassSelector cannot be changed")
}

if !reflect.DeepEqual(r.Spec.VolumeSnapshotClassSelector, oldDRPolicy.Spec.VolumeSnapshotClassSelector) {
return fmt.Errorf("VolumeSnapshotClassSelector cannot be changed")
return nil, fmt.Errorf("VolumeSnapshotClassSelector cannot be changed")
}

if !reflect.DeepEqual(r.Spec.DRClusters, oldDRPolicy.Spec.DRClusters) {
return fmt.Errorf("DRClusters cannot be changed")
return nil, fmt.Errorf("DRClusters cannot be changed")
}

return nil
return nil, nil
}

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

return nil
return nil, nil
}
2 changes: 1 addition & 1 deletion api/v1alpha1/volumereplicationgroup_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ type ProtectedPVC struct {

// Resources set in the claim to be replicated
//+optional
Resources corev1.ResourceRequirements `json:"resources,omitempty"`
Resources corev1.VolumeResourceRequirements `json:"resources,omitempty"`

// Conditions for this protected pvc
//+optional
Expand Down
4 changes: 2 additions & 2 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8aaed55

Please sign in to comment.