Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync downstream main with upstream main #81

Merged
merged 25 commits into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
f851aec
build: fix `make docker-generate-protobuf` target
nixpanic Jun 21, 2023
6a356c5
crds: add lastsyncduration and lastsyncbytes to volrep
yati1998 Jun 12, 2023
f3f2b62
proto: update rpc to include other volrep info
yati1998 Jun 12, 2023
dc8bb6d
vendor: updates the vendor directory
yati1998 Jun 12, 2023
ee9403c
replication: update reconcile logic
yati1998 Jun 12, 2023
1712b73
build: use Go 1.20 while building in container
nixpanic Jun 23, 2023
342d457
tools: move tools.go to its own directory tools/
Rakshith-R Jun 23, 2023
5da4b7f
ci: include `/tools` directory in dependabot config
nixpanic Jun 26, 2023
d58e6b4
vendor: Bump google.golang.org/grpc from 1.55.0 to 1.56.1
dependabot[bot] Jun 26, 2023
d4463a0
build: update k8s and controller runtime pkgs
subhamkrai Jun 26, 2023
36f9fd2
vendor: bump k8s.io/api from 0.27.2 to 0.27.3
dependabot[bot] Jun 26, 2023
da2bc42
vendor: Bump github.com/kubernetes-csi/csi-lib-utils
dependabot[bot] Jun 26, 2023
e44d317
vendor: Bump k8s.io/client-go from 0.26.3 to 0.27.3
dependabot[bot] Jun 26, 2023
d90368f
vendor: bump google.golang.org/protobuf from 1.30.0 to 1.31.0
dependabot[bot] Jun 26, 2023
fb32a2c
vendor: Bump sigs.k8s.io/controller-tools in /tools
dependabot[bot] Jun 26, 2023
3fad6ab
deploy: commit changes done by controller-tools update
Rakshith-R Jun 26, 2023
a41d5ab
vendor: bump google.golang.org/protobuf to 1.31.0 in /tools
dependabot[bot] Jun 26, 2023
5c8fcf2
rebase: commit changes done while upating tools/protobuf
Rakshith-R Jun 27, 2023
3fd87a2
Adding version details to sidecar
saranyareddy24 Jun 25, 2023
7e73c8b
build: use `make` to build executables in containers
nixpanic Jun 27, 2023
22b6288
build: include `-version` option for csi-addons executable
nixpanic Jun 27, 2023
fcc6e23
build: force rebuilding without CGo
nixpanic Jun 27, 2023
6c78a07
build: switch back to docker for golang:1.20
Rakshith-R Jun 28, 2023
b136c3a
cleanup: corrections in the ci doc
karthik-us Jun 27, 2023
bed9c6e
controller: fix reclaimspace based on ns annotation
Rakshith-R Jun 27, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
9 changes: 9 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ updates:
prefix: "vendor"
labels:
- vendor
- package-ecosystem: "gomod"
directory: "/tools"
schedule:
interval: "weekly"
rebase-strategy: "disabled"
commit-message:
prefix: "vendor"
labels:
- vendor
- package-ecosystem: "github-actions"
directory: "/"
schedule:
Expand Down
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# Build the manager binary
FROM golang:1.19 as builder
FROM golang:1.20 as builder

# Copy the contents of the repository
ADD . /workspace/go/src/github.com/csi-addons/kubernetes-csi-addons

ENV GOPATH=/workspace/go
ENV GOPATH=/workspace/go CGO_ENABLED=0
WORKDIR /workspace/go/src/github.com/csi-addons/kubernetes-csi-addons

# Build
RUN CGO_ENABLED=0 GOOS=linux go build -mod=vendor -a -o /workspace/manager cmd/manager/main.go
RUN make build

# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
FROM gcr.io/distroless/static:nonroot
WORKDIR /
COPY --from=builder /workspace/manager .
COPY --from=builder /workspace/go/src/github.com/csi-addons/kubernetes-csi-addons/bin/csi-addons-manager .
USER 65532:65532

ENTRYPOINT ["/manager"]
ENTRYPOINT ["/csi-addons-manager"]
33 changes: 23 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@ ifneq ($(TAG),latest)
BUNDLE_VERSION ?= --version=$(shell sed s/^v// <<< $(TAG))
endif

# To get the GIT commit id
GIT_COMMIT ?= $(shell git rev-list -1 HEAD)

# Fetch the git tag
GIT_TAG ?= $(shell git describe --tags HEAD 2>/dev/null || echo $(GIT_COMMIT))

GO_PROJECT=github.com/csi-addons/kubernetes-csi-addons

LDFLAGS ?=
LDFLAGS += -X $(GO_PROJECT)/internal/version.GitCommit=$(GIT_COMMIT)
LDFLAGS += -X $(GO_PROJECT)/internal/version.Version=$(GIT_TAG)

# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.23

Expand Down Expand Up @@ -158,9 +170,9 @@ bundle-validate: container-cmd operator-sdk

.PHONY: build
build: generate fmt vet ## Build manager binary.
go build -o bin/manager cmd/manager/main.go
go build -o bin/sidecar sidecar/main.go
go build -o bin/csi-addons ./cmd/csi-addons
go build -ldflags '$(LDFLAGS)' -a -o bin/csi-addons-manager cmd/manager/main.go
go build -ldflags '$(LDFLAGS)' -a -o bin/csi-addons-sidecar sidecar/main.go
go build -ldflags '$(LDFLAGS)' -a -o bin/csi-addons ./cmd/csi-addons

.PHONY: run
run: manifests generate fmt vet ## Run a controller from your host.
Expand Down Expand Up @@ -192,7 +204,7 @@ docker-push-bundle: container-cmd

.PHONY: docker-build-tools
docker-generate-protobuf: container-cmd ./build/Containerfile.tools
$(CONTAINER_CMD) build -f $^ -t ${TOOLS_IMG} .
$(CONTAINER_CMD) build -f ./build/Containerfile.tools -t ${TOOLS_IMG} .
$(CONTAINER_CMD) run --rm -ti --volume=${PWD}:/go/src/github.com/csi-addons/kubernetes-csi-addons:Z ${TOOLS_IMG} make generate-protobuf

##@ Deployment
Expand Down Expand Up @@ -221,38 +233,39 @@ undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/confi
CONTROLLER_GEN = $(shell pwd)/bin/controller-gen
.PHONY: controller-gen
controller-gen:
go build -o $(CONTROLLER_GEN) ./vendor/$(shell grep controller-gen tools.go | sed 's/.*_ "//;s/"//')
cd ./tools && go build -o $(CONTROLLER_GEN) ./vendor/$(shell grep controller-gen tools/tools.go | sed 's/.*_ "//;s/"//')

# kustomize gets installed from the vendor/ directory. The tools.go file is
# used to select the major version of kustomize.
KUSTOMIZE = $(shell pwd)/bin/kustomize
.PHONY: kustomize
kustomize:
go build -o $(KUSTOMIZE) ./vendor/$(shell grep kustomize tools.go | sed 's/.*_ "//;s/"//')
cd ./tools && go build -o $(KUSTOMIZE) ./vendor/$(shell grep kustomize tools/tools.go | sed 's/.*_ "//;s/"//')

# setup-envtest gets installed from the vendor/ directory.
ENVTEST = $(shell pwd)/bin/setup-envtest
.PHONY: envtest
envtest:
go build -o $(ENVTEST) ./vendor/$(shell grep setup-envtest tools.go | sed 's/.*_ "//;s/"//')
cd ./tools && go build -o $(ENVTEST) ./vendor/$(shell grep setup-envtest tools/tools.go | sed 's/.*_ "//;s/"//')

# operator-sdk gets installed from the vendor/ directory.
OPERATOR_SDK = $(shell pwd)/bin/operator-sdk
.PHONY: operator-sdk
operator-sdk:
go build -o $(OPERATOR_SDK) ./vendor/$(shell grep operator-sdk tools.go | sed 's/.*_ "//;s/"//')
# FIXME: Remove `go mod tidy && go mod vendor` once we find the reason why ci workflow fails.
cd ./tools && go mod tidy && go mod vendor && go build -o $(OPERATOR_SDK) ./vendor/$(shell grep operator-sdk tools/tools.go | sed 's/.*_ "//;s/"//')

# protoc-gen-go gets installed from the vendor/ directory.
PROTOC_GEN_GO = $(shell pwd)/bin/protoc-gen-go
.PHONY: protoc-gen-go
protoc-gen-go:
go build -o $(PROTOC_GEN_GO) ./vendor/$(shell grep '/protoc-gen-go"' tools.go | sed 's/.*_ "//;s/"//')
cd ./tools && go build -o $(PROTOC_GEN_GO) ./vendor/$(shell grep '/protoc-gen-go"' tools/tools.go | sed 's/.*_ "//;s/"//')

# protoc-gen-go-grpc gets installed from the vendor/ directory.
PROTOC_GEN_GO_GRPC = $(shell pwd)/bin/protoc-gen-go-grpc
.PHONY: protoc-gen-go-grpc
protoc-gen-go-grpc:
go build -o $(PROTOC_GEN_GO_GRPC) ./vendor/$(shell grep protoc-gen-go-grpc tools.go | sed 's/.*_ "//;s/"//')
cd ./tools && go build -o $(PROTOC_GEN_GO_GRPC) ./vendor/$(shell grep protoc-gen-go-grpc tools/tools.go | sed 's/.*_ "//;s/"//')

# go-get-tool will 'go get' any package $2 and install it to $1.
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
Expand Down
17 changes: 9 additions & 8 deletions apis/csiaddons/v1alpha1/csiaddonsnode_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,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 @@ -42,17 +43,17 @@ func (c *CSIAddonsNode) SetupWebhookWithManager(mgr ctrl.Manager) error {
var _ webhook.Validator = &CSIAddonsNode{}

// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
func (c *CSIAddonsNode) ValidateCreate() error {
return nil
func (c *CSIAddonsNode) ValidateCreate() (admission.Warnings, error) {
return nil, nil
}

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

oldCSIAddonsNode, ok := old.(*CSIAddonsNode)
if !ok {
return errors.New("error casting CSIAddonsNode object")
return nil, errors.New("error casting CSIAddonsNode object")
}

var allErrs field.ErrorList
Expand All @@ -66,15 +67,15 @@ func (c *CSIAddonsNode) ValidateUpdate(old runtime.Object) error {
}

if len(allErrs) != 0 {
return apierrors.NewInvalid(
return nil, apierrors.NewInvalid(
schema.GroupKind{Group: "csiaddons.openshift.io", Kind: "CSIAddonsNode"},
c.Name, allErrs)
}

return nil
return nil, nil
}

// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
func (r *CSIAddonsNode) ValidateDelete() error {
return nil
func (r *CSIAddonsNode) ValidateDelete() (admission.Warnings, error) {
return nil, nil
}
17 changes: 9 additions & 8 deletions apis/csiaddons/v1alpha1/networkfence_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,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 @@ -43,17 +44,17 @@ func (n *NetworkFence) SetupWebhookWithManager(mgr ctrl.Manager) error {
var _ webhook.Validator = &NetworkFence{}

// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
func (n *NetworkFence) ValidateCreate() error {
return nil
func (n *NetworkFence) ValidateCreate() (admission.Warnings, error) {
return nil, nil
}

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

oldNetworkFence, ok := old.(*NetworkFence)
if !ok {
return errors.New("error casting NetworkFence object")
return nil, errors.New("error casting NetworkFence object")
}

var allErrs field.ErrorList
Expand All @@ -74,15 +75,15 @@ func (n *NetworkFence) ValidateUpdate(old runtime.Object) error {
}

if len(allErrs) != 0 {
return apierrors.NewInvalid(
return nil, apierrors.NewInvalid(
schema.GroupKind{Group: "csiaddons.openshift.io", Kind: "NetworkFence"},
n.Name, allErrs)
}

return nil
return nil, nil
}

// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
func (n *NetworkFence) ValidateDelete() error {
return nil
func (n *NetworkFence) ValidateDelete() (admission.Warnings, error) {
return nil, nil
}
17 changes: 9 additions & 8 deletions apis/csiaddons/v1alpha1/reclaimspacecronjob_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,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 @@ -42,17 +43,17 @@ func (r *ReclaimSpaceCronJob) SetupWebhookWithManager(mgr ctrl.Manager) error {
var _ webhook.Validator = &ReclaimSpaceCronJob{}

// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
func (r *ReclaimSpaceCronJob) ValidateCreate() error {
return nil
func (r *ReclaimSpaceCronJob) ValidateCreate() (admission.Warnings, error) {
return nil, nil
}

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

oldReclaimSpaceCronJob, ok := old.(*ReclaimSpaceCronJob)
if !ok {
return errors.New("error casting ReclaimSpaceCronJob object")
return nil, errors.New("error casting ReclaimSpaceCronJob object")
}

var allErrs field.ErrorList
Expand All @@ -62,14 +63,14 @@ func (r *ReclaimSpaceCronJob) ValidateUpdate(old runtime.Object) error {
}

if len(allErrs) != 0 {
return apierrors.NewInvalid(
return nil, apierrors.NewInvalid(
schema.GroupKind{Group: "csiaddons.openshift.io", Kind: "ReclaimSpaceCronJob"},
r.Name, allErrs)
}
return nil
return nil, nil
}

// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
func (r *ReclaimSpaceCronJob) ValidateDelete() error {
return nil
func (r *ReclaimSpaceCronJob) ValidateDelete() (admission.Warnings, error) {
return nil, nil
}
17 changes: 9 additions & 8 deletions apis/csiaddons/v1alpha1/reclaimspacejob_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,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 @@ -42,17 +43,17 @@ func (r *ReclaimSpaceJob) SetupWebhookWithManager(mgr ctrl.Manager) error {
var _ webhook.Validator = &ReclaimSpaceJob{}

// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
func (r *ReclaimSpaceJob) ValidateCreate() error {
return nil
func (r *ReclaimSpaceJob) ValidateCreate() (admission.Warnings, error) {
return nil, nil
}

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

oldReclaimSpaceJob, ok := old.(*ReclaimSpaceJob)
if !ok {
return errors.New("error casting ReclaimSpaceJob object")
return nil, errors.New("error casting ReclaimSpaceJob object")
}

var allErrs field.ErrorList
Expand All @@ -62,15 +63,15 @@ func (r *ReclaimSpaceJob) ValidateUpdate(old runtime.Object) error {
}

if len(allErrs) != 0 {
return apierrors.NewInvalid(
return nil, apierrors.NewInvalid(
schema.GroupKind{Group: "csiaddons.openshift.io", Kind: "ReclaimSpaceJob"},
r.Name, allErrs)
}

return nil
return nil, nil
}

// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
func (r *ReclaimSpaceJob) ValidateDelete() error {
return nil
func (r *ReclaimSpaceJob) ValidateDelete() (admission.Warnings, error) {
return nil, nil
}
10 changes: 6 additions & 4 deletions apis/replication.storage/v1alpha1/volumereplication_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,12 @@ type VolumeReplicationStatus struct {
Conditions []metav1.Condition `json:"conditions,omitempty"`
// observedGeneration is the last generation change the operator has dealt with
// +optional
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
LastStartTime *metav1.Time `json:"lastStartTime,omitempty"`
LastCompletionTime *metav1.Time `json:"lastCompletionTime,omitempty"`
LastSyncTime *metav1.Time `json:"lastSyncTime,omitempty"`
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
LastStartTime *metav1.Time `json:"lastStartTime,omitempty"`
LastCompletionTime *metav1.Time `json:"lastCompletionTime,omitempty"`
LastSyncTime *metav1.Time `json:"lastSyncTime,omitempty"`
LastSyncBytes *int64 `json:"lastSyncBytes,omitempty"`
LastSyncDuration *metav1.Duration `json:"lastSyncDuration,omitempty"`
}

// +kubebuilder:object:root=true
Expand Down
17 changes: 9 additions & 8 deletions apis/replication.storage/v1alpha1/volumereplication_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,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 @@ -43,17 +44,17 @@ func (v *VolumeReplication) SetupWebhookWithManager(mgr ctrl.Manager) error {
var _ webhook.Validator = &VolumeReplication{}

// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
func (v *VolumeReplication) ValidateCreate() error {
return nil
func (v *VolumeReplication) ValidateCreate() (admission.Warnings, error) {
return nil, nil
}

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

oldReplication, ok := old.(*VolumeReplication)
if !ok {
return errors.New("error casting old VolumeReplication object")
return nil, errors.New("error casting old VolumeReplication object")
}

var allErrs field.ErrorList
Expand All @@ -69,15 +70,15 @@ func (v *VolumeReplication) ValidateUpdate(old runtime.Object) error {
}

if len(allErrs) != 0 {
return apierrors.NewInvalid(
return nil, apierrors.NewInvalid(
schema.GroupKind{Group: "replication.storage.openshift.io", Kind: "VolumeReplication"},
v.Name, allErrs)
}

return nil
return nil, nil
}

// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
func (v *VolumeReplication) ValidateDelete() error {
return nil
func (v *VolumeReplication) ValidateDelete() (admission.Warnings, error) {
return nil, nil
}
Loading