Skip to content

Commit

Permalink
Merge branch 'main' into K8SPSMDB-1109
Browse files Browse the repository at this point in the history
  • Loading branch information
egegunes committed Nov 7, 2024
2 parents c6c9547 + 54f358a commit 5da01b3
Show file tree
Hide file tree
Showing 37 changed files with 773 additions and 203 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ jobs:
with:
go-version: '^1.22'
- uses: actions/checkout@v4.1.1
- name: go test
run: go test -v ./...
- name: run tests
run: make test
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ VERSION ?= $(shell git rev-parse --abbrev-ref HEAD | $(SED) -e 's^/^-^g; s^[.]^-
IMAGE ?= $(IMAGE_TAG_BASE):$(VERSION)
DEPLOYDIR = ./deploy

ENVTEST_K8S_VERSION = 1.31

all: build

help: ## Display this help.
Expand Down Expand Up @@ -63,6 +65,9 @@ deploy: ## Deploy operator
undeploy: ## Undeploy operator
kubectl delete -f $(DEPLOYDIR)/operator.yaml

test: envtest ## Run tests.
DISABLE_TELEMETRY=true KUBEBUILDER_ASSETS="$(shell $(ENVTEST) --arch=amd64 use $(ENVTEST_K8S_VERSION) -p path)" go test ./... -coverprofile cover.out

# go-get-tool will 'go get' any package $2 and install it to $1.
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
define go-get-tool
Expand All @@ -85,6 +90,10 @@ KUSTOMIZE = $(shell pwd)/bin/kustomize
kustomize: ## Download kustomize locally if necessary.
$(call go-get-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/v4@v4.5.3)

ENVTEST = $(shell pwd)/bin/setup-envtest
envtest: ## Download envtest-setup locally if necessary.
$(call go-get-tool,$(ENVTEST),sigs.k8s.io/controller-runtime/tools/setup-envtest@latest)

# Prepare release
CERT_MANAGER_VER := $(shell grep -Eo "cert-manager v.*" go.mod|grep -Eo "[0-9]+\.[0-9]+\.[0-9]+")
release: manifests
Expand Down
4 changes: 4 additions & 0 deletions config/crd/bases/psmdb.percona.com_perconaservermongodbs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6409,6 +6409,8 @@ spec:
type: object
host:
type: string
priority:
type: integer
tags:
additionalProperties:
type: string
Expand Down Expand Up @@ -14167,6 +14169,8 @@ spec:
type: object
host:
type: string
priority:
type: integer
tags:
additionalProperties:
type: string
Expand Down
4 changes: 4 additions & 0 deletions deploy/bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7105,6 +7105,8 @@ spec:
type: object
host:
type: string
priority:
type: integer
tags:
additionalProperties:
type: string
Expand Down Expand Up @@ -14863,6 +14865,8 @@ spec:
type: object
host:
type: string
priority:
type: integer
tags:
additionalProperties:
type: string
Expand Down
1 change: 1 addition & 0 deletions deploy/cr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ spec:
# replsetOverrides:
# my-cluster-name-rs0-0:
# host: my-cluster-name-rs0-0.example.net:27017
# priority: 3
# tags:
# key: value-0
# my-cluster-name-rs0-1:
Expand Down
4 changes: 4 additions & 0 deletions deploy/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7105,6 +7105,8 @@ spec:
type: object
host:
type: string
priority:
type: integer
tags:
additionalProperties:
type: string
Expand Down Expand Up @@ -14863,6 +14865,8 @@ spec:
type: object
host:
type: string
priority:
type: integer
tags:
additionalProperties:
type: string
Expand Down
4 changes: 4 additions & 0 deletions deploy/cw-bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7105,6 +7105,8 @@ spec:
type: object
host:
type: string
priority:
type: integer
tags:
additionalProperties:
type: string
Expand Down Expand Up @@ -14863,6 +14865,8 @@ spec:
type: object
host:
type: string
priority:
type: integer
tags:
additionalProperties:
type: string
Expand Down
9 changes: 9 additions & 0 deletions e2e-tests/release_images → e2e-tests/release_versions
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,12 @@ IMAGE_MONGOD50=percona/percona-server-mongodb:5.0.29-25
IMAGE_BACKUP=percona/percona-backup-mongodb:2.6.0
IMAGE_PMM_CLIENT=percona/pmm-client:2.43.2
IMAGE_PMM_SERVER=percona/pmm-server:2.43.2
GKE_MIN=1.28
GKE_MAX=1.30
EKS_MIN=1.28
EKS_MAX=1.31
AKS_MIN=1.28
AKS_MAX=1.31
OPENSHIFT_MIN=4.13.52
OPENSHIFT_MAX=4.17.3
MINIKUBE_REL=1.31.0
2 changes: 2 additions & 0 deletions e2e-tests/replset-overrides/compare/priorities.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[ 1, 3, 0 ]
bye
88 changes: 88 additions & 0 deletions e2e-tests/replset-overrides/conf/some-name-override-priority.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
apiVersion: psmdb.percona.com/v1
kind: PerconaServerMongoDB
metadata:
finalizers:
- percona.com/delete-psmdb-pvc
name: some-name
spec:
crVersion: 1.17.0
image: perconalab/percona-server-mongodb-operator:main-mongod7.0
imagePullPolicy: Always
backup:
enabled: true
image: perconalab/percona-server-mongodb-operator:main-backup
storages:
minio:
type: s3
s3:
credentialsSecret: minio-secret
region: us-east-1
bucket: operator-testing
endpointUrl: http://minio-service:9000/
insecureSkipTLSVerify: false
replsets:
- name: rs0
size: 3
expose:
enabled: false
exposeType: ClusterIP
replsetOverrides:
some-name-rs0-0:
priority: 1
some-name-rs0-1:
priority: 3
some-name-rs0-2:
priority: 0
resources:
limits:
cpu: 300m
memory: 0.5G
requests:
cpu: 300m
memory: 0.5G
volumeSpec:
persistentVolumeClaim:
resources:
requests:
storage: 3Gi
secrets:
users: some-users
sharding:
configsvrReplSet:
affinity:
antiAffinityTopologyKey: none
expose:
enabled: false
exposeType: ClusterIP
podDisruptionBudget:
maxUnavailable: 1
resources:
limits:
cpu: 300m
memory: 0.5G
requests:
cpu: 300m
memory: 0.5G
size: 3
volumeSpec:
persistentVolumeClaim:
resources:
requests:
storage: 3Gi
enabled: false
mongos:
affinity:
antiAffinityTopologyKey: none
expose:
exposeType: ClusterIP
podDisruptionBudget:
maxUnavailable: 1
resources:
limits:
cpu: 300m
memory: 0.5G
requests:
cpu: 300m
memory: 0.5G
size: 3
updateStrategy: SmartUpdate
65 changes: 49 additions & 16 deletions e2e-tests/replset-overrides/run
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,17 @@ run_recovery_check() {
wait_cluster_consistency "${cluster}"
}

test_override_after_deploy() {
delete_cluster() {
local cluster=$1

echo "deleting cluster: ${cluster}"
kubectl_bin delete psmdb ${cluster}
wait_for_delete psmdb/${cluster}
wait_for_delete pod/${cluster}-rs0-0
kubectl delete secrets --all
}

test_override_host_after_deploy() {
kubectl_bin apply \
-f ${conf_dir}/secrets_with_tls.yml \
-f ${conf_dir}/minio-secret.yml
Expand Down Expand Up @@ -58,14 +68,10 @@ test_override_after_deploy() {

run_recovery_check "${cluster}" "backup-minio-logical" "external-rs0-0.${namespace}"

echo "deleting cluster"
kubectl_bin delete psmdb ${cluster}
wait_for_delete psmdb/${cluster}
wait_for_delete pod/${cluster}-rs0-0
kubectl delete secrets --all
delete_cluster ${cluster}
}

test_deploy_with_overrides() {
test_deploy_with_host_overrides() {
kubectl_bin apply \
-f ${conf_dir}/secrets_with_tls.yml \
-f ${conf_dir}/minio-secret.yml
Expand All @@ -88,11 +94,34 @@ test_deploy_with_overrides() {
wait_backup "backup-minio-physical"
run_recovery_check "${cluster}" "backup-minio-physical" "external-rs0-0.${namespace}"

echo "deleting cluster"
kubectl_bin delete psmdb ${cluster}
wait_for_delete psmdb/${cluster}
wait_for_delete pod/${cluster}-rs0-0
kubectl_bin delete secret --all
delete_cluster ${cluster}
}

test_override_priority() {
kubectl_bin apply \
-f ${conf_dir}/secrets_with_tls.yml \
-f ${conf_dir}/minio-secret.yml

echo "creating PSMDB cluster: ${cluster}"
apply_cluster ${test_dir}/conf/${cluster}-override-priority.yml
wait_for_running ${cluster}-rs0 3

echo "writing some data"
run_mongo \
'use myApp\n db.test.insert({ x: 100500 })' \
"databaseAdmin:databaseAdmin123456@${cluster}-rs0.${namespace}"
compare_mongo_cmd "find" "databaseAdmin:databaseAdmin123456@${cluster}-rs0.${namespace}"

echo "checking member priorities"
run_mongo \
"rs.conf().members.map(m => m.priority)" \
"databaseAdmin:databaseAdmin123456@${cluster}-rs0.${namespace}" \
| egrep -v 'I NETWORK|W NETWORK|F NETWORK|Error saving history file|Percona Server for MongoDB|connecting to:|Unable to reach primary for set|Implicit session:|versions do not match|Error saving history file:' \
> ${tmp_dir}/priorities.json
diff -u ${test_dir}/compare/priorities.json ${tmp_dir}/priorities.json
echo "member priorities are OK"

delete_cluster ${cluster}
}

main() {
Expand All @@ -101,14 +130,18 @@ main() {

deploy_minio

desc "Case 1: Deploying a new cluster with replsetOverrides"
test_deploy_with_overrides
desc "Case 1: Deploying a new cluster with hostname overrides"
test_deploy_with_host_overrides
desc "Case 1: PASSED"

desc "Case 2: Patching a running cluster with replsetOverrides"
test_override_after_deploy
desc "Case 2: Patching a running cluster to override hostnames"
test_override_host_after_deploy
desc "Case 2: PASSED"

desc "Case 3: Overriding member priorities"
test_override_priority
desc "Case 3: PASSED"

desc "All cases PASSED"
}

Expand Down
1 change: 0 additions & 1 deletion e2e-tests/run-distro.csv
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ ldap
ldap-tls
mongod-major-upgrade
mongod-major-upgrade-sharded
monitoring-2-0
non-voting
one-pod
pitr
Expand Down
5 changes: 5 additions & 0 deletions e2e-tests/scheduled-backup/conf/some-name-rs0-2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,26 +48,31 @@ spec:
tasks:
- name: every-min-minio
enabled: true
keep: 1
schedule: "* * * * *"
compressionType: gzip
storageName: minio
- name: every-min-aws-s3
enabled: true
keep: 1
schedule: "* * * * *"
compressionType: gzip
storageName: aws-s3
- name: every-min-gcp-cs
enabled: true
keep: 1
schedule: "* * * * *"
compressionType: gzip
storageName: gcp-cs
- name: every-min-azure-blob
enabled: true
keep: 1
schedule: "* * * * *"
compressionType: gzip
storageName: azure-blob
- name: weekly
enabled: true
keep: 1
schedule: "0 0 * * 0"
compressionType: gzip
storageName: aws-s3
Expand Down
1 change: 1 addition & 0 deletions e2e-tests/scheduled-backup/conf/some-name-rs0-3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ spec:
tasks:
- name: every-min-minio
enabled: true
keep: 1
type: physical
schedule: "* * * * *"
compressionType: gzip
Expand Down
Loading

0 comments on commit 5da01b3

Please sign in to comment.