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

Syncing latest changes from upstream main for ramen #157

Merged
merged 46 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
f8e7127
Makefile: delete whitespace at the end of lines
raghavendra-talur Aug 4, 2023
9090ad8
makefile: move the installation of golangci-lint to a script
raghavendra-talur Aug 4, 2023
ca17832
golangci-lint: specify the current list of enabled linters
raghavendra-talur Nov 8, 2023
6677058
Create a single helper for the various versions of addAnnotation
ELENAGER Nov 8, 2023
f3fd6ce
Remove cephcsi image override
nirs Nov 6, 2023
ffc5fe4
Don't override csiaddons sidecar image
nirs Nov 6, 2023
d253452
Pass in the current primary to createVolSyncDestManifestWork during c…
ShyamsundarR Nov 10, 2023
7725f0b
Move all tests images to quay.io
nirs Oct 29, 2023
8f63fa6
Pull velero images from quay.io
nirs Oct 29, 2023
719fd43
Update Velero version in documentation
ELENAGER Nov 13, 2023
de07977
init DRPolicy metrics before secrets propagation
rakeshgm Nov 2, 2023
f1488c1
golangci-lint: explicitly list the revive rules
raghavendra-talur Nov 21, 2023
5e75156
golangci-lint: disable even the default linters
raghavendra-talur Nov 21, 2023
97f04de
golangci-lint: update golangci-lint version to 1.55.2
raghavendra-talur Nov 21, 2023
96b2cbe
golangci-lint: disable the failing linters
raghavendra-talur Nov 21, 2023
379daa1
Add label to volsync secret for inclusion in hub recovery backup
BenamarMk Nov 21, 2023
2271f38
golangci-lint: enable dot-imports rule of revive
raghavendra-talur Nov 21, 2023
5cdc7eb
Add missing pvc namespace to the vrg rdspec
nirs Nov 29, 2023
e709cd0
Deploy recipe CRD in all DR environments
nirs Nov 14, 2023
8bec3d8
Make containsMismatchVolSyncPVCs() more clear
nirs Nov 30, 2023
d35f8bd
Consider also protected PVC namespace
nirs Nov 30, 2023
d9b5ffa
ManifestWork Regeneration Bug and ACM Eviction Consequences
BenamarMk Dec 4, 2023
9dd1c15
Fix and reformat 2 comments
BenamarMk Dec 4, 2023
ca7af2d
Exclude VolSync secret Policy from hub backup
BenamarMk Dec 5, 2023
f2c5575
Enable automatic managed clusters approval
nirs Nov 23, 2023
d0de64f
Deploy managed clusters s3 secrets using ramen
nirs Nov 22, 2023
5637d0f
Update clusteradm install instructions
nirs Nov 11, 2023
15cc764
During Failover pull VRG from s3 only from failover cluster
ELENAGER Nov 29, 2023
7641e8f
pre-commit.sh: refactor to make it easier to read
raghavendra-talur Dec 6, 2023
b1695d3
golangci-lint: remove funlen limits for the test functions
raghavendra-talur Nov 7, 2023
dad29f9
Ignore only bin at the root of the project
nirs Oct 23, 2023
eff62fb
Add ramen logger service
nirs Oct 30, 2023
3edf49f
Add cirros test image
nirs Oct 30, 2023
e2eafef
Dump ramen log in kubevirt self test
nirs Oct 26, 2023
8e2994c
Add release number to cirros container
nirs Oct 31, 2023
d7ecb62
Show uptime in START log
nirs Oct 31, 2023
f93efe0
Start ramen logger first
nirs Oct 31, 2023
a5570c5
Disable most kernel log messages during boot
nirs Oct 31, 2023
c95a5f0
Automatically generate secret for the test VM
nirs Nov 3, 2023
25e89c0
Workaround minikube bug
nirs Nov 15, 2023
89a61cb
Use vm driver for selftest and drenv tests
nirs Nov 11, 2023
a9031f0
Simplify minio development environment
nirs Nov 12, 2023
0160735
Fix spelling in envs/*.yaml
nirs Nov 12, 2023
35d1e6f
Remove docker requirement for drenv test
nirs Nov 12, 2023
4bd62cf
Use existing cluster for drenv tests
nirs Nov 11, 2023
fe846a6
Use drenv-sefltest to validate the installation
nirs Nov 12, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ env:
IMAGE_REGISTRY: "quay.io"
IMAGE_TAG: "ci"
DOCKERCMD: "podman"
DRIVER: "container"
defaults:
run:
shell: bash
Expand Down Expand Up @@ -79,7 +80,7 @@ jobs:
- name: GolangCI Lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.49.0
version: v1.55.2

unit-test:
name: Unit tests
Expand Down Expand Up @@ -116,7 +117,6 @@ jobs:
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube
minikube version
mkdir "$HOME/.minikube/profiles"

- name: Install kubectl
run: |
Expand Down Expand Up @@ -145,6 +145,10 @@ jobs:
run: make black
working-directory: test

- name: Start test cluster
run: make cluster
working-directory: test

- name: Run tests
run: make test
working-directory: test
Expand All @@ -153,6 +157,10 @@ jobs:
run: make coverage
working-directory: test

- name: Clean up
run: make clean
working-directory: test

ramenctl-test:
name: ramenctl tests
runs-on: ubuntu-22.04
Expand Down
9 changes: 7 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
*.dll
*.so
*.dylib
bin
testbin/*
/bin
/testbin/*

# Test binary, build with `go test -c`
*.test
Expand Down Expand Up @@ -37,9 +37,14 @@ venv
# Test enviromemnt generated files
test/.coverage
test/.coverage.*
test/addons/kubevirt/vm/id_rsa.pub

# Python generated files
*.egg-info/
__pycache__/
test/build
ramenctl/build

# Generated disk images
*.qcow2
*.iso
186 changes: 157 additions & 29 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,34 +33,162 @@ linters-settings:
wsl:
allow-trailing-comment: true
enforce-err-cuddling: true
revive:
ignore-generated-header: false
severity: error
rules:
- name: blank-imports
- name: context-as-argument
- name: context-keys-type
- name: dot-imports
- name: error-return
- name: error-strings
- name: error-naming
- name: exported
- name: if-return
- name: increment-decrement
- name: var-naming
- name: var-declaration
- name: package-comments
- name: range
- name: receiver-naming
- name: time-naming
- name: unexported-return
- name: indent-error-flow
- name: errorf
- name: empty-block
- name: superfluous-else
- name: unreachable-code
- name: redefines-builtin-id
- name: atomic
- name: constant-logical-expr
- name: unnecessary-stmt
- name: get-return
- name: modifies-parameter
- name: modifies-value-receiver
- name: range-val-in-closure
- name: waitgroup-by-value
- name: call-to-gc
- name: duplicated-imports
- name: unhandled-error
# - name: flag-parameter
# - name: unused-receiver
# - name: unused-parameter
# - name: confusing-naming
# - name: import-shadowing
# - name: confusing-results
# - name: bool-literal-in-expr

issues:
exclude-rules:
# Allow dot imports for ginkgo and gomega
- source: ginkgo|gomega
linters:
- revive
text: "should not use dot imports"
- source: "^func Test"
linters:
- funlen


linters:
enable-all: true
disable:
- exhaustivestruct
- gochecknoglobals
- gochecknoinits
- godot
- godox
- paralleltest
- goerr113 # TODO: Need to introduce error definition and bring this back
- goheader # TODO: Introduce back post fixing linter errors
- gci
- interfacer # interfacer linter is archived and deprecated (https://github.com/mvdan/interfacer)
# TODO: fix folloing linter errors.
- exhaustruct
- tagliatelle
- gomoddirectives
- goimports
- wrapcheck
- varnamelen
- staticcheck
- nosnakecase
- ireturn
- nilnil
- containedctx
- nonamedreturns
- forcetypeassert
- promlinter
- contextcheck
- errname
disable-all: true
enable:
- asasalint
- asciicheck
- bidichk
- bodyclose
- cyclop
- deadcode
- decorder
# - depguard
- dogsled
- dupl
- durationcheck
- errcheck
- errchkjson
# - errorlint
- execinquery
- exhaustive
- exportloopref
- forbidigo
- funlen
- gocognit
# - goconst
- gocritic
- gocyclo
- gofmt
- gofumpt
- golint
- gomnd
- gomodguard
- goprintffuncname
- gosec
- gosimple
- govet
- grouper
- ifshort
- importas
- ineffassign
- interfacebloat
- lll
- logrlint
- maintidx
- makezero
- maligned
- misspell
# - nakedret
- nestif
- nilerr
- nlreturn
- noctx
# - nolintlint
- nosprintfhostport
- prealloc
- predeclared
- reassign
- revive
- rowserrcheck
- scopelint
- sqlclosecheck
- structcheck
- stylecheck
- tenv
- testpackage
- thelper
- tparallel
- typecheck
- unconvert
- unparam
- unused
- usestdlibvars
- varcheck
# - wastedassign
- whitespace
- wsl
# - exhaustivestruct
# - gochecknoglobals
# - gochecknoinits
# - godot
# - godox
# - paralleltest
# - goerr113 # TODO: Need to introduce error definition and bring this back
# - goheader # TODO: Introduce back post fixing linter errors
# - gci
# - interfacer # interfacer linter is archived and deprecated (https://github.com/mvdan/interfacer)
# - exhaustruct
# - tagliatelle
# - gomoddirectives
# - goimports
# - wrapcheck
# - varnamelen
# - staticcheck
# - nosnakecase
# - ireturn
# - nilnil
# - containedctx
# - nonamedreturns
# - forcetypeassert
# - promlinter
# - contextcheck
# - errname
16 changes: 4 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -124,17 +124,9 @@ manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and Cust
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."

GOLANGCI_URL := https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh
GOLANGCI_VERSION := 1.49.0
GOLANGCI_INSTALLED_VER := $(shell testbin/golangci-lint version --format=short 2>&1)
.PHONY: golangci-bin
golangci-bin: ## Download and install goloanci-lint locally if necessary.
ifeq (,$(GOLANGCI_INSTALLED_VER))
$(info Installing golangci-lint (version: $(GOLANGCI_VERSION)) into testbin)
curl -sSfL $(GOLANGCI_URL) | sh -s -- -b testbin v$(GOLANGCI_VERSION)
else ifneq ($(GOLANGCI_VERSION),$(GOLANGCI_INSTALLED_VER))
$(error Incorrect version ($(GOLANGCI_INSTALLED_VER)) for golangci-lint found, expecting $(GOLANGCI_VERSION))
endif
golangci-bin:
hack/install-golangci-lint.sh

.PHONY: lint
lint: golangci-bin ## Run configured golangci-lint and pre-commit.sh linters against the code.
Expand Down Expand Up @@ -415,15 +407,15 @@ catalog-push: ## Push a catalog image.
.PHONY: docker-buildx
docker-buildx: # Build and push docker image for the manager for cross-platform support
ifeq ($(DOCKERCMD),docker)
# copy existing Dockerfile and insert --platform=${BUILDPLATFORM} and
# copy existing Dockerfile and insert --platform=${BUILDPLATFORM} and
# replace GOARCH value to ${TARGETARCH} into Dockerfile.cross, and preserve the original Dockerfile
$(eval PLATFORMS="linux/arm64,linux/amd64,linux/s390x,linux/ppc64le")
$(SED_CMD) \
-e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' \
-e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' \
Dockerfile > Dockerfile.cross
$(SED_CMD) -e 's/GOARCH=amd64/GOARCH=$${TARGETARCH}/' -i Dockerfile.cross
- $(DOCKERCMD) buildx create --name $(IMAGE_NAME)-builder --bootstrap --use
- $(DOCKERCMD) buildx create --name $(IMAGE_NAME)-builder --bootstrap --use
- $(DOCKERCMD) buildx build --push --platform="${PLATFORMS}" --tag ${IMG} -f Dockerfile.cross .
- $(DOCKERCMD) buildx rm $(IMAGE_NAME)-builder
rm Dockerfile.cross
Expand Down
52 changes: 22 additions & 30 deletions controllers/drplacementcontrol.go
Original file line number Diff line number Diff line change
Expand Up @@ -535,20 +535,23 @@ func (d *DRPCInstance) checkMetroFailoverPrerequisites(curHomeCluster string) (b
func (d *DRPCInstance) checkRegionalFailoverPrerequisites() bool {
d.setProgression(rmn.ProgressionWaitForStorageMaintenanceActivation)

if required, activationsRequired := requiresRegionalFailoverPrerequisites(
d.ctx,
d.reconciler.APIReader,
rmnutil.DRPolicyS3Profiles(d.drPolicy, d.drClusters).List(),
d.instance.GetName(), d.instance.GetNamespace(),
d.vrgs, d.instance.Spec.FailoverCluster,
d.reconciler.ObjStoreGetter, d.log); required {
for _, drCluster := range d.drClusters {
if drCluster.Name != d.instance.Spec.FailoverCluster {
continue
}
for _, drCluster := range d.drClusters {
if drCluster.Name != d.instance.Spec.FailoverCluster {
continue
}

// we want to work with failover cluster only, because the previous primary cluster might be unreachable
if required, activationsRequired := requiresRegionalFailoverPrerequisites(
d.ctx,
d.reconciler.APIReader,
[]string{drCluster.Spec.S3ProfileName},
d.instance.GetName(), d.instance.GetNamespace(),
d.vrgs, d.instance.Spec.FailoverCluster,
d.reconciler.ObjStoreGetter, d.log); required {
return checkFailoverMaintenanceActivations(drCluster, activationsRequired, d.log)
}

break
}

return true
Expand Down Expand Up @@ -1204,7 +1207,7 @@ func (d *DRPCInstance) switchToCluster(targetCluster, targetClusterNamespace str
vrgState = vrg.Status.State
}

d.log.Info(fmt.Sprintf("PVs/PVCs have been Restored? %v and VRG Primary %v", restored, vrgState))
d.log.Info(fmt.Sprintf("PVs/PVCs have been Restored? '%v' and VRG Primary='%v'", restored, vrgState))

if !restored || vrg.Status.State != rmn.PrimaryState {
d.setProgression(rmn.ProgressionWaitingForResourceRestore)
Expand Down Expand Up @@ -1388,9 +1391,11 @@ func (d *DRPCInstance) updateUserPlacementRule(homeCluster, reason string) error
d.log.Info(fmt.Sprintf("Updating user Placement %s homeCluster %s",
d.userPlacement.GetName(), homeCluster))

err := d.addAnnotation(LastAppDeploymentCluster, homeCluster)
if err != nil {
return err
added := rmnutil.AddAnnotation(d.instance, LastAppDeploymentCluster, homeCluster)
if added {
if err := d.reconciler.Update(d.ctx, d.instance); err != nil {
return err
}
}

newPD := &clrapiv1beta1.ClusterDecision{
Expand All @@ -1401,19 +1406,6 @@ func (d *DRPCInstance) updateUserPlacementRule(homeCluster, reason string) error
return d.reconciler.updateUserPlacementStatusDecision(d.ctx, d.userPlacement, newPD)
}

func (d *DRPCInstance) addAnnotation(key, value string) error {
annotations := d.instance.GetAnnotations()

if annotations == nil {
annotations = map[string]string{}
}

annotations[key] = value
d.instance.SetAnnotations(annotations)

return d.reconciler.Update(d.ctx, d.instance)
}

func (d *DRPCInstance) clearUserPlacementRuleStatus() error {
d.log.Info("Clearing user Placement", "name", d.userPlacement.GetName())

Expand Down Expand Up @@ -1748,7 +1740,7 @@ func (d *DRPCInstance) cleanupForVolSync(clusterToSkip string) error {

// Recreate the VRG ManifestWork for the secondary. This typically happens during Hub Recovery.
if errors.IsNotFound(err) {
err := d.createVolSyncDestManifestWork(clusterName)
err := d.createVolSyncDestManifestWork(clusterToSkip)
if err != nil {
return err
}
Expand Down Expand Up @@ -1998,7 +1990,7 @@ func (d *DRPCInstance) ensureVRGDeleted(clusterName string) bool {
}

func (d *DRPCInstance) updateVRGState(clusterName string, state rmn.ReplicationState) (bool, error) {
d.log.Info(fmt.Sprintf("Updating VRG ReplicationState to secondary for cluster %s", clusterName))
d.log.Info(fmt.Sprintf("Updating VRG ReplicationState to %s for cluster %s", state, clusterName))

vrg, err := d.getVRGFromManifestWork(clusterName)
if err != nil {
Expand Down
Loading