Skip to content

Commit 4a80046

Browse files
committed
Revert "Bug 2255411: Backport of upstream PRs 1171, 1173, 1174"
1 parent 42fe9d7 commit 4a80046

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2062
-1643
lines changed

.github/workflows/ci.yaml

+1-6
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ env:
2323
IMAGE_NAME: ${{ vars.IMAGE_NAME || 'ramen' }}
2424
OPERATOR_SUGGESTED_NAMESPACE: ${{ vars.OPERATOR_SUGGESTED_NAMESPACE || 'ramen-system' }}
2525
# Constants
26-
GO_VERSION: "1.21"
26+
GO_VERSION: "1.19"
2727
IMAGE_REGISTRY: "quay.io"
2828
IMAGE_TAG: "ci"
2929
DOCKERCMD: "podman"
@@ -39,11 +39,6 @@ jobs:
3939
- name: Checkout source
4040
uses: actions/checkout@v3
4141

42-
- name: Setup go
43-
uses: actions/setup-go@v4
44-
with:
45-
go-version: ${{ env.GO_VERSION }}
46-
4742
- name: Install prereqs
4843
run: |
4944
echo 'APT::Acquire::Retries "5";' | sudo tee /etc/apt/apt.conf.d/80-retries

Dockerfile

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,25 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
# Build the manager binary
5-
FROM docker.io/library/golang:1.21 as builder
5+
FROM golang:1.19.1 as builder
66

77
WORKDIR /workspace
88
# Copy the Go Modules manifests
99
COPY go.mod go.mod
1010
COPY go.sum go.sum
11-
COPY api/ api/
1211
# cache deps before building and copying source so that we don't need to re-download as much
1312
# and so that source changes don't invalidate our downloaded layer
1413
RUN go mod download
1514

1615
# Copy the go source
1716
COPY main.go main.go
17+
COPY api/ api/
1818
COPY controllers/ controllers/
1919

2020
# Build
21-
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o manager main.go
21+
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager main.go
2222

23-
FROM registry.access.redhat.com/ubi8/ubi-minimal
23+
FROM registry.access.redhat.com/ubi8/ubi
2424
WORKDIR /
2525
COPY --from=builder /workspace/manager .
2626

Makefile

+47-7
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ IMAGE_NAME ?= ramen
3838
IMAGE_TAG ?= latest
3939
PLATFORM ?= k8s
4040
IMAGE_TAG_BASE = $(IMAGE_REGISTRY)/$(IMAGE_REPOSITORY)/$(IMAGE_NAME)
41-
RBAC_PROXY_IMG ?= "gcr.io/kubebuilder/kube-rbac-proxy:v0.13.1"
41+
RBAC_PROXY_IMG ?= "gcr.io/kubebuilder/kube-rbac-proxy:v0.13.0"
4242
OPERATOR_SUGGESTED_NAMESPACE ?= ramen-system
4343
AUTO_CONFIGURE_DR_CLUSTER ?= true
4444
KUBE_OBJECT_PROTECTION_DISABLED ?= false
@@ -126,7 +126,7 @@ generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and
126126

127127
.PHONY: golangci-bin
128128
golangci-bin:
129-
@hack/install-golangci-lint.sh
129+
hack/install-golangci-lint.sh
130130

131131
.PHONY: lint
132132
lint: golangci-bin ## Run configured golangci-lint and pre-commit.sh linters against the code.
@@ -255,20 +255,48 @@ undeploy-dr-cluster: kustomize ## Undeploy dr-cluster controller from the K8s cl
255255
##@ Tools
256256

257257
CONTROLLER_GEN = $(shell pwd)/bin/controller-gen
258+
controller_gen_version=v0.9.2
258259
controller-gen: ## Download controller-gen locally if necessary.
259-
@hack/install-controller-gen.sh
260+
@test '$(shell $(CONTROLLER_GEN) --version)' = 'Version: $(controller_gen_version)' ||\
261+
$(call go-get-tool,sigs.k8s.io/controller-tools/cmd/controller-gen@$(controller_gen_version))
260262

261-
.PHONY: kustomize
262263
KUSTOMIZE = $(shell pwd)/bin/kustomize
263264
kustomize: ## Download kustomize locally if necessary.
264-
@hack/install-kustomize.sh
265+
@test -f $(KUSTOMIZE) ||\
266+
$(call go-get-tool,sigs.k8s.io/kustomize/kustomize/[email protected])
267+
268+
# go-get-tool will 'go get' any package $1 and install it to bin/.
269+
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
270+
define go-get-tool
271+
{ \
272+
set -e ;\
273+
TMP_DIR=$$(mktemp -d) ;\
274+
cd $$TMP_DIR ;\
275+
go mod init tmp ;\
276+
echo "Downloading $(1)" ;\
277+
GOBIN=$(PROJECT_DIR)/bin go install $(1) ;\
278+
rm -rf $$TMP_DIR ;\
279+
}
280+
endef
265281

266282
##@ Bundle
267283

268284
.PHONY: operator-sdk
269285
OSDK = ./bin/operator-sdk
270286
operator-sdk: ## Download operator-sdk locally if necessary.
271-
@hack/install-operator-sdk.sh
287+
ifeq (,$(wildcard $(OSDK)))
288+
ifeq (,$(shell which operator-sdk 2>/dev/null))
289+
@{ \
290+
set -e ;\
291+
mkdir -p $(dir $(OSDK)) ;\
292+
OS=$(shell go env GOOS) && ARCH=$(shell go env GOARCH) && \
293+
curl -sSLo $(OSDK) https://github.com/operator-framework/operator-sdk/releases/download/v1.24.0/operator-sdk_$${OS}_$${ARCH} ;\
294+
chmod +x $(OSDK) ;\
295+
}
296+
else
297+
OSDK = $(shell which operator-sdk)
298+
endif
299+
endif
272300

273301
.PHONY: bundle
274302
bundle: bundle-hub bundle-dr-cluster ## Generate all bundle manifests and metadata, then validate generated files.
@@ -327,7 +355,19 @@ bundle-dr-cluster-push: ## Push the dr-cluster bundle image.
327355
.PHONY: opm
328356
OPM = ./bin/opm
329357
opm: ## Download opm locally if necessary.
330-
@./hack/install-opm.sh
358+
ifeq (,$(wildcard $(OPM)))
359+
ifeq (,$(shell which opm 2>/dev/null))
360+
@{ \
361+
set -e ;\
362+
mkdir -p $(dir $(OPM)) ;\
363+
OS=$(shell go env GOOS) && ARCH=$(shell go env GOARCH) && \
364+
curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.23.2/$${OS}-$${ARCH}-opm ;\
365+
chmod +x $(OPM) ;\
366+
}
367+
else
368+
OPM = $(shell which opm)
369+
endif
370+
endif
331371

332372
# A comma-separated list of bundle images (e.g. make catalog-build BUNDLE_IMGS=example.com/operator-bundle:v0.1.0,example.com/operator-bundle:v0.2.0).
333373
# These images MUST exist in a registry and be pull-able.

api/v1alpha1/drcluster_webhook.go

+11-12
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
ctrl "sigs.k8s.io/controller-runtime"
1111
logf "sigs.k8s.io/controller-runtime/pkg/log"
1212
"sigs.k8s.io/controller-runtime/pkg/webhook"
13-
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
1413
)
1514

1615
// log is for logging in this package.
@@ -28,50 +27,50 @@ func (r *DRCluster) SetupWebhookWithManager(mgr ctrl.Manager) error {
2827
var _ webhook.Validator = &DRCluster{}
2928

3029
// ValidateCreate checks
31-
func (r *DRCluster) ValidateCreate() (admission.Warnings, error) {
30+
func (r *DRCluster) ValidateCreate() error {
3231
drclusterlog.Info("validate create", "name", r.Name)
3332

3433
return r.ValidateDRCluster()
3534
}
3635

3736
// ValidateUpdate checks
38-
func (r *DRCluster) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
37+
func (r *DRCluster) ValidateUpdate(old runtime.Object) error {
3938
drclusterlog.Info("validate update", "name", r.Name)
4039

4140
oldDRCluster, ok := old.(*DRCluster)
4241
if !ok {
43-
return nil, fmt.Errorf("error casting old DRCluster")
42+
return fmt.Errorf("error casting old DRCluster")
4443
}
4544

4645
// check for immutability for Region and S3ProfileName
4746
if r.Spec.Region != oldDRCluster.Spec.Region {
48-
return nil, fmt.Errorf("Region cannot be changed")
47+
return fmt.Errorf("Region cannot be changed")
4948
}
5049

5150
if r.Spec.S3ProfileName != oldDRCluster.Spec.S3ProfileName {
52-
return nil, fmt.Errorf("S3ProfileName cannot be changed")
51+
return fmt.Errorf("S3ProfileName cannot be changed")
5352
}
5453

5554
return r.ValidateDRCluster()
5655
}
5756

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

62-
return nil, nil
61+
return nil
6362
}
6463

65-
func (r *DRCluster) ValidateDRCluster() (admission.Warnings, error) {
64+
func (r *DRCluster) ValidateDRCluster() error {
6665
if r.Spec.Region == "" {
67-
return nil, fmt.Errorf("Region cannot be empty")
66+
return fmt.Errorf("Region cannot be empty")
6867
}
6968

7069
if r.Spec.S3ProfileName == "" {
71-
return nil, fmt.Errorf("S3ProfileName cannot be empty")
70+
return fmt.Errorf("S3ProfileName cannot be empty")
7271
}
7372

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

76-
return nil, nil
75+
return nil
7776
}

api/v1alpha1/drplacementcontrol_webhook.go

+10-11
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
ctrl "sigs.k8s.io/controller-runtime"
1212
logf "sigs.k8s.io/controller-runtime/pkg/log"
1313
"sigs.k8s.io/controller-runtime/pkg/webhook"
14-
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
1514
)
1615

1716
// log is for logging in this package.
@@ -29,19 +28,19 @@ func (r *DRPlacementControl) SetupWebhookWithManager(mgr ctrl.Manager) error {
2928
var _ webhook.Validator = &DRPlacementControl{}
3029

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

35-
return nil, nil
34+
return nil
3635
}
3736

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

4241
oldDRPC, ok := old.(*DRPlacementControl)
4342
if !ok {
44-
return nil, fmt.Errorf("error casting old DRPC")
43+
return fmt.Errorf("error casting old DRPC")
4544
}
4645

4746
// checks for immutability
@@ -50,31 +49,31 @@ func (r *DRPlacementControl) ValidateUpdate(old runtime.Object) (admission.Warni
5049
"old", oldDRPC.Spec.PlacementRef,
5150
"new", r.Spec.PlacementRef)
5251

53-
return nil, fmt.Errorf("PlacementRef cannot be changed")
52+
return fmt.Errorf("PlacementRef cannot be changed")
5453
}
5554

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

61-
return nil, fmt.Errorf("DRPolicyRef cannot be changed")
60+
return fmt.Errorf("DRPolicyRef cannot be changed")
6261
}
6362

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

69-
return nil, fmt.Errorf("PVCSelector cannot be changed")
68+
return fmt.Errorf("PVCSelector cannot be changed")
7069
}
7170

72-
return nil, nil
71+
return nil
7372
}
7473

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

79-
return nil, nil
78+
return nil
8079
}

api/v1alpha1/drpolicy_webhook.go

+11-12
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
ctrl "sigs.k8s.io/controller-runtime"
1212
logf "sigs.k8s.io/controller-runtime/pkg/log"
1313
"sigs.k8s.io/controller-runtime/pkg/webhook"
14-
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
1514
)
1615

1716
// log is for logging in this package.
@@ -29,45 +28,45 @@ func (r *DRPolicy) SetupWebhookWithManager(mgr ctrl.Manager) error {
2928
var _ webhook.Validator = &DRPolicy{}
3029

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

35-
return nil, nil
34+
return nil
3635
}
3736

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

4241
oldDRPolicy, ok := old.(*DRPolicy)
4342

4443
if !ok {
45-
return nil, fmt.Errorf("error casting old DRPolicy")
44+
return fmt.Errorf("error casting old DRPolicy")
4645
}
4746

4847
// checks for immutability
4948
if r.Spec.SchedulingInterval != oldDRPolicy.Spec.SchedulingInterval {
50-
return nil, fmt.Errorf("SchedulingInterval cannot be changed")
49+
return fmt.Errorf("SchedulingInterval cannot be changed")
5150
}
5251

5352
if !reflect.DeepEqual(r.Spec.ReplicationClassSelector, oldDRPolicy.Spec.ReplicationClassSelector) {
54-
return nil, fmt.Errorf("ReplicationClassSelector cannot be changed")
53+
return fmt.Errorf("ReplicationClassSelector cannot be changed")
5554
}
5655

5756
if !reflect.DeepEqual(r.Spec.VolumeSnapshotClassSelector, oldDRPolicy.Spec.VolumeSnapshotClassSelector) {
58-
return nil, fmt.Errorf("VolumeSnapshotClassSelector cannot be changed")
57+
return fmt.Errorf("VolumeSnapshotClassSelector cannot be changed")
5958
}
6059

6160
if !reflect.DeepEqual(r.Spec.DRClusters, oldDRPolicy.Spec.DRClusters) {
62-
return nil, fmt.Errorf("DRClusters cannot be changed")
61+
return fmt.Errorf("DRClusters cannot be changed")
6362
}
6463

65-
return nil, nil
64+
return nil
6665
}
6766

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

72-
return nil, nil
71+
return nil
7372
}

api/v1alpha1/volumereplicationgroup_types.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ type ProtectedPVC struct {
258258

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

263263
// Conditions for this protected pvc
264264
//+optional

api/v1alpha1/zz_generated.deepcopy.go

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)