Skip to content

Commit

Permalink
fix: CI check for Velero version (#94)
Browse files Browse the repository at this point in the history
Signed-off-by: Mateus Oliveira <[email protected]>
  • Loading branch information
mateusoliveira43 authored Oct 2, 2024
1 parent 516ad2e commit 5f69c2f
Show file tree
Hide file tree
Showing 8 changed files with 383 additions and 274 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,12 @@ jobs:
echo "::error::run 'make update-non-admin-manifests' in OADP repository to update Non Admin Controller (NAC) manifests"
exit 1
fi
- name: Check Velero manifests
working-directory: ./oadp-non-admin
run: |
OADP_OPERATOR_PATH=../ make update-velero-manifests
if test -n "$(git status --short)"; then
echo "::error::run 'make update-velero-manifests' in Non Admin Controller (NAC) repository to update Velero manifests"
exit 1
fi
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -275,3 +275,17 @@ check-images: ## Check if images are the same in Makefile and config/manager/kus
@if [ "$(MANAGER_IMAGE)" == "" ];then echo "No manager image found" && exit 1;fi
@if [ "$(MANAGER_TAG)" == "" ];then echo "No manager tag found" && exit 1;fi
@grep -Iq "IMG ?= $(MANAGER_IMAGE):$(MANAGER_TAG)" ./Makefile || (echo "Images differ" && exit 1)

.PHONY: update-velero-manifests
update-velero-manifests: ## Update Velero manifests used by NAC, from OADP_OPERATOR_PATH
ifeq ($(OADP_OPERATOR_PATH),)
$(error You must set OADP_OPERATOR_PATH to run this command)
endif
@{ \
NAC_VELERO_VERSION=$(shell grep -I 'github.com/openshift/velero' $(shell pwd)/go.mod | awk -F' ' '{print $$5}') ;\
OADP_VELERO_VERSION=$(shell grep -I 'github.com/openshift/velero' $(OADP_OPERATOR_PATH)/go.mod | awk -F' ' '{print $$5}') ;\
sed -i "s%$$NAC_VELERO_VERSION%$$OADP_VELERO_VERSION%" $(shell pwd)/go.mod ;\
for file_name in $(shell ls $(shell pwd)/hack/extra-crds);do \
cp $(OADP_OPERATOR_PATH)/config/crd/bases/$$file_name $(shell pwd)/hack/extra-crds/$$file_name && \
sed -i "1s%^%# Code generated by make update-velero-manifests. DO NOT EDIT.\n%" $(shell pwd)/hack/extra-crds/$$file_name;done ;\
}
28 changes: 27 additions & 1 deletion config/crd/bases/nac.oadp.openshift.io_nonadminbackups.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ spec:
itemOperationTimeout:
description: |-
ItemOperationTimeout specifies the time used to wait for asynchronous BackupItemAction operations
The default value is 1 hour.
The default value is 4 hour.
type: string
labelSelector:
description: |-
Expand Down Expand Up @@ -498,6 +498,16 @@ spec:
TTL is a time.Duration-parseable string describing how long
the Backup should be retained for.
type: string
uploaderConfig:
description: UploaderConfig specifies the configuration for the
uploader.
nullable: true
properties:
parallelFilesUpload:
description: ParallelFilesUpload is the number of files parallel
uploads to perform when using the uploader.
type: integer
type: object
volumeSnapshotLocations:
description: VolumeSnapshotLocations is a list containing names
of VolumeSnapshotLocations associated with this backup.
Expand Down Expand Up @@ -664,6 +674,22 @@ spec:
description: FormatVersion is the backup format version, including
major, minor, and patch version.
type: string
hookStatus:
description: HookStatus contains information about the status
of the hooks.
nullable: true
properties:
hooksAttempted:
description: |-
HooksAttempted is the total number of attempted hooks
Specifically, HooksAttempted represents the number of hooks that failed to execute
and the number of hooks that executed successfully.
type: integer
hooksFailed:
description: HooksFailed is the total number of hooks which
ended with an error
type: integer
type: object
phase:
description: Phase is the current state of the Backup.
enum:
Expand Down
13 changes: 13 additions & 0 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ If your changes involve code, please check [code quality and standardization sec

If your changes involve Kubernetes objects (`config/` folder), please follow [Kubernetes objects changes section](#kubernetes-objects-changes).

If your changes involve Velero version or its objects, please follow [Velero objects changes section](#velero-objects-changes).

If you are upgrading project's kubebuilder version, please follow [upgrade kubebuilder version section](#upgrade-kubebuilder-version).

> **NOTE:** Run `make help` for more information on all potential `make` targets
Expand Down Expand Up @@ -122,6 +124,17 @@ If NAC Kubernetes objects are changed, like CRDs, RBACs, etc, follow this workfl

[More information](architecture.md#oadp-integration).

## Velero objects changes

If Velero version or its objects needs changes, follow this workflow:
- create branch in this repository and run `make update-non-admin-manifests` command, pointing to related created OADP operator repository branch. Example:
```sh
OADP_OPERATOR_PATH=./home/user/oadp-operator make update-velero-manifests
```
- create pull requests in NAC

[More information](architecture.md#oadp-integration).

## Upgrade kubebuilder version

To upgrade kubebuilder version, create kubebuilder structure using the current kubebuilder version and the upgrade version, using the same commands presented in [kubebuilder architecture documentation](architecture.md#kubebuilder), in two different folders. Then generate a `diff` file from the two folders and apply changes to project code.
10 changes: 10 additions & 0 deletions docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ NAC objects are included in OADP operator through `make update-non-admin-manifes
The continuous integration (CI) pipeline of the project verifies if OADP operator repository branches have up to date NAC objects included.

Velero version and its objects (for tests) are updated in NAC through `make update-velero-manifests` command, which is run in this repository.

> **NOTE:** Manual steps required in this repository prior to implementation of `make update-velero-manifests` command:
> - replace statement with `github.com/openshift/velero` must be already set in `go.mod` file
> - add empty file with expected name in `hack/extra-crds` folder
> **NOTE:** `make update-velero-manifests` command does not work for deletion, i.e., if a file that was previously managed by the command is deleted (or renamed), it needs to be manually deleted.
The continuous integration (CI) pipeline of the project verifies if this repository branches have up to date Velero version and Velero objects.

## Kubebuilder

The project was generated using kubebuilder version `v3.14.0`, running the following commands
Expand Down
50 changes: 25 additions & 25 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
module github.com/migtools/oadp-non-admin

go 1.22
go 1.22.0

toolchain go1.22.6

require (
github.com/go-logr/logr v1.4.1
github.com/onsi/ginkgo/v2 v2.14.0
github.com/onsi/gomega v1.30.0
github.com/stretchr/testify v1.8.4
github.com/onsi/ginkgo/v2 v2.19.0
github.com/onsi/gomega v1.33.1
github.com/stretchr/testify v1.9.0
github.com/vmware-tanzu/velero v1.12.0
k8s.io/api v0.29.0
k8s.io/apimachinery v0.29.0
k8s.io/client-go v0.29.0
sigs.k8s.io/controller-runtime v0.17.0
sigs.k8s.io/controller-runtime v0.17.2
)

require (
Expand All @@ -26,43 +28,41 @@ require (
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // 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/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.18.0 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.45.0 // indirect
github.com/prometheus/client_golang v1.19.0 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.52.3 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.26.0 // indirect
golang.org/x/exp v0.0.0-20221028150844-83b7d23a625f // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/oauth2 v0.12.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/term v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.16.1 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/oauth2 v0.19.0 // indirect
golang.org/x/sys v0.21.0 // indirect
golang.org/x/term v0.21.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.31.0 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand All @@ -76,4 +76,4 @@ require (
sigs.k8s.io/yaml v1.4.0 // indirect
)

replace github.com/vmware-tanzu/velero => github.com/openshift/velero v0.10.2-0.20231024175012-d8101a298016
replace github.com/vmware-tanzu/velero => github.com/openshift/velero v0.10.2-0.20240822161636-3fac5687bd46
Loading

0 comments on commit 5f69c2f

Please sign in to comment.