Skip to content

Commit 2d71937

Browse files
egeguneshors
andauthored
K8SPSMDB-1290: Bump PBM to v2.9.0 (#1828)
* K8SPSMDB-1290: Bump PBM to v2.9.0 Revert "K8SPSMDB-1274: Disable balancer before restore" This reverts commit 07a3aa6. * address review comments --------- Co-authored-by: Viacheslav Sarzhan <slava.sarzhan@percona.com>
1 parent 69e3e6a commit 2d71937

File tree

13 files changed

+279
-190
lines changed

13 files changed

+279
-190
lines changed

e2e-tests/balancer/conf/some-name-rs0.yml

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ spec:
2929
storage: 3Gi
3030
expose:
3131
enabled: false
32-
runtimeClassName: container-rc
3332

3433
mongos:
3534
size: 3
@@ -38,7 +37,6 @@ spec:
3837
localPingThresholdMs: 15
3938
expose:
4039
type: ClusterIP
41-
runtimeClassName: container-rc
4240

4341
replsets:
4442
- name: rs0
@@ -58,7 +56,42 @@ spec:
5856
resources:
5957
requests:
6058
storage: 1Gi
61-
runtimeClassName: container-rc
59+
size: 3
60+
- name: rs1
61+
affinity:
62+
antiAffinityTopologyKey: none
63+
expose:
64+
enabled: false
65+
resources:
66+
limits:
67+
cpu: 500m
68+
memory: 1G
69+
requests:
70+
cpu: 100m
71+
memory: 0.1G
72+
volumeSpec:
73+
persistentVolumeClaim:
74+
resources:
75+
requests:
76+
storage: 1Gi
77+
size: 3
78+
- name: rs2
79+
affinity:
80+
antiAffinityTopologyKey: none
81+
expose:
82+
enabled: false
83+
resources:
84+
limits:
85+
cpu: 500m
86+
memory: 1G
87+
requests:
88+
cpu: 100m
89+
memory: 0.1G
90+
volumeSpec:
91+
persistentVolumeClaim:
92+
resources:
93+
requests:
94+
storage: 1Gi
6295
size: 3
6396
secrets:
6497
users: some-users

e2e-tests/balancer/data.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
db = db.getSiblingDB('app');
2+
3+
var bulk = db.city.initializeUnorderedBulkOp();
4+
5+
for (var i=0; i<3000000; i++) {
6+
bulk.insert({ "name": "city-"+i, "zipcode": i });
7+
}
8+
9+
bulk.execute();

e2e-tests/balancer/run

Lines changed: 43 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ test_dir=$(realpath "$(dirname "$0")")
66
. "${test_dir}/../functions"
77
set_debug
88

9-
log() {
10-
echo "[$(date +%Y-%m-%dT%H:%M:%S%z)]" $*
11-
}
12-
139
check_balancer() {
1410
local cluster=$1
1511
local expected=$2 # should be "true" (enabled) or "false" (disabled)
@@ -64,43 +60,73 @@ check_backup_and_restore() {
6460
check_balancer ${cluster} ${balancer_end_state} 10
6561
}
6662

63+
write_data() {
64+
local cluster=$1
65+
66+
log 'create user'
67+
run_mongos \
68+
'db.createUser({user:"user",pwd:"pass",roles:[{db:"app",role:"readWrite"}]})' \
69+
"userAdmin:userAdmin123456@$cluster-mongos.$namespace" \
70+
"mongodb" ".svc.cluster.local" "--quiet" "27017" "mongosh"
71+
sleep 2
72+
73+
log 'enable sharding'
74+
run_mongos \
75+
'sh.enableSharding("app")' \
76+
"clusterAdmin:clusterAdmin123456@$cluster-mongos.$namespace" \
77+
"mongodb" ".svc.cluster.local" "--quiet" "27017" "mongosh"
78+
sleep 2
79+
80+
log 'shard collection'
81+
run_mongos \
82+
'sh.shardCollection("app.city", { _id: 1 } )' \
83+
"clusterAdmin:clusterAdmin123456@$cluster-mongos.$namespace" \
84+
"mongodb" ".svc.cluster.local" "--quiet" "27017" "mongosh"
85+
86+
log 'write data'
87+
run_script_mongos "${test_dir}/data.js" "user:pass@$cluster-mongos.$namespace" \
88+
"mongodb" ".svc.cluster.local" "--quiet" "mongosh"
89+
90+
}
91+
6792
main() {
6893
create_infra "$namespace"
6994

7095
deploy_minio
7196
apply_s3_storage_secrets
7297

73-
desc 'create first PSMDB cluster'
98+
log 'create PSMDB cluster'
7499
cluster="some-name"
75100
kubectl_bin apply \
76101
-f "$conf_dir/secrets.yml" \
77102
-f "$conf_dir/client-70.yml"
78103

79-
if version_gt "1.19" && [ $EKS -ne 1 ]; then
80-
$sed 's/docker/runc/g' "$conf_dir/container-rc.yaml" | kubectl_bin apply -f -
81-
elif version_gt "1.24" && [ $EKS -eq 1 ]; then
82-
$sed 's/docker/runc/g' "$conf_dir/container-rc.yaml" | kubectl_bin apply -f -
83-
else
84-
kubectl_bin apply -f "$conf_dir/container-rc.yaml"
85-
fi
86-
87104
apply_cluster "$test_dir/conf/$cluster-rs0.yml"
88105

89-
desc 'check if all 3 Pods started'
90-
wait_for_running $cluster-rs0 3 "false"
106+
log 'check if cfg pods started'
91107
wait_for_running $cluster-cfg 3 "false"
108+
109+
log 'check if all shards started'
110+
wait_for_running $cluster-rs0 3 "false"
111+
wait_for_running $cluster-rs1 3 "false"
112+
wait_for_running $cluster-rs2 3 "false"
113+
114+
log 'check if mongos pods started'
92115
wait_for_running $cluster-mongos 3
116+
93117
check_balancer ${cluster} "true" 10
94118

119+
write_data ${cluster}
120+
95121
check_backup_and_restore ${cluster} "0" "true"
96122

97-
desc 'disabling balancer'
123+
log 'disabling balancer'
98124
kubectl patch psmdb some-name --type=merge -p '{"spec":{"sharding":{"balancer":{"enabled":false}}}}'
99125
check_balancer ${cluster} "false" 10
100126

101127
check_backup_and_restore ${cluster} "1" "false"
102128

103-
desc 'enabling balancer'
129+
log 'enabling balancer'
104130
kubectl patch psmdb some-name --type=merge -p '{"spec":{"sharding":{"balancer":{"enabled":true}}}}'
105131
check_balancer ${cluster} "true" 10
106132

e2e-tests/functions

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ IMAGE_MONGOD_CHAIN=${IMAGE_MONGOD_CHAIN:-$'
1010
perconalab/percona-server-mongodb-operator:main-mongod6.0
1111
perconalab/percona-server-mongodb-operator:main-mongod7.0
1212
perconalab/percona-server-mongodb-operator:main-mongod8.0'}
13-
IMAGE_BACKUP=${IMAGE_BACKUP:-"perconalab/percona-server-mongodb-operator:main-backup"}
13+
IMAGE_BACKUP=${IMAGE_BACKUP:-"perconalab/percona-server-mongodb-operator:pbm-290"}
1414
SKIP_BACKUPS_TO_AWS_GCP_AZURE=${SKIP_BACKUPS_TO_AWS_GCP_AZURE:-1}
1515
PMM_SERVER_VER=${PMM_SERVER_VER:-"9.9.9"}
1616
IMAGE_PMM_CLIENT=${IMAGE_PMM_CLIENT:-"perconalab/pmm-client:dev-latest"}
@@ -774,31 +774,35 @@ run_mongos() {
774774
local uri="$2"
775775
local driver=${3:-mongodb}
776776
local suffix=${4:-.svc.cluster.local}
777-
local client_container=$(kubectl_bin get pods --selector=name=psmdb-client -o 'jsonpath={.items[].metadata.name}')
778777
local mongo_flag="$5"
779778
local port=${6:-"27017"}
779+
local mongo_bin=${7:-mongo}
780780

781781
suffix_port=$(echo "$suffix" | awk -F':' '{print $2}')
782782
if [[ -z $suffix_port ]]; then
783783
suffix="$suffix:$port"
784784
fi
785785

786+
local client_container=$(kubectl_bin get pods --selector=name=psmdb-client -o 'jsonpath={.items[].metadata.name}')
787+
786788
kubectl_bin exec ${client_container} -- \
787-
bash -c "printf '$command\n' | mongo $driver://$uri$suffix/admin $mongo_flag"
789+
bash -c "printf '$command\n' | ${mongo_bin} $driver://$uri$suffix/admin $mongo_flag"
788790
}
789791

790792
run_script_mongos() {
791793
local script="$1"
792794
local uri="$2"
793795
local driver=${3:-mongodb}
794796
local suffix=${4:-.svc.cluster.local}
795-
local client_container=$(kubectl_bin get pods --selector=name=psmdb-client -o 'jsonpath={.items[].metadata.name}')
796797
local mongo_flag="$5"
798+
local mongo_bin=${6:-mongo}
799+
800+
local client_container=$(kubectl_bin get pods --selector=name=psmdb-client -o 'jsonpath={.items[].metadata.name}')
797801

798802
name="$(basename $script)"
799803
kubectl_bin cp ${script} $namespace/${client_container}:/tmp
800804
kubectl_bin exec ${client_container} -- \
801-
bash -c "mongo $driver://$uri$suffix/admin $mongo_flag /tmp/${name}"
805+
bash -c "${mongo_bin} $driver://$uri$suffix/admin $mongo_flag /tmp/${name}"
802806
}
803807

804808
get_pmm_service_ip() {

go.mod

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ require (
1616
github.com/hashicorp/go-version v1.7.0
1717
github.com/onsi/ginkgo/v2 v2.22.2
1818
github.com/onsi/gomega v1.36.2
19-
github.com/percona/percona-backup-mongodb v1.8.1-0.20241212160532-0157f87a7eee
19+
github.com/percona/percona-backup-mongodb v1.8.1-0.20250214093445-06640a797614
2020
github.com/pkg/errors v0.9.1
2121
github.com/robfig/cron/v3 v3.0.1
2222
github.com/stretchr/testify v1.10.0
2323
go.mongodb.org/mongo-driver v1.17.2
2424
go.uber.org/zap v1.27.0
25-
golang.org/x/sync v0.10.0
25+
golang.org/x/sync v0.11.0
2626
google.golang.org/grpc v1.70.0
2727
gopkg.in/yaml.v2 v2.4.0
2828
k8s.io/api v0.32.1
@@ -83,7 +83,7 @@ require (
8383
github.com/jmespath/go-jmespath v0.4.1-0.20220621161143-b0104c826a24 // indirect
8484
github.com/josharian/intern v1.0.0 // indirect
8585
github.com/json-iterator/go v1.1.12 // indirect
86-
github.com/klauspost/compress v1.17.9 // indirect
86+
github.com/klauspost/compress v1.17.11 // indirect
8787
github.com/klauspost/pgzip v1.2.6 // indirect
8888
github.com/mailru/easyjson v0.7.7 // indirect
8989
github.com/mitchellh/mapstructure v1.5.0 // indirect
@@ -111,14 +111,14 @@ require (
111111
go.opentelemetry.io/otel/metric v1.32.0 // indirect
112112
go.opentelemetry.io/otel/trace v1.32.0 // indirect
113113
go.uber.org/multierr v1.11.0 // indirect
114-
golang.org/x/crypto v0.31.0 // indirect
114+
golang.org/x/crypto v0.33.0 // indirect
115115
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 // indirect
116116
golang.org/x/mod v0.22.0 // indirect
117-
golang.org/x/net v0.33.0 // indirect
117+
golang.org/x/net v0.35.0 // indirect
118118
golang.org/x/oauth2 v0.25.0 // indirect
119-
golang.org/x/sys v0.28.0 // indirect
120-
golang.org/x/term v0.27.0 // indirect
121-
golang.org/x/text v0.21.0 // indirect
119+
golang.org/x/sys v0.30.0 // indirect
120+
golang.org/x/term v0.29.0 // indirect
121+
golang.org/x/text v0.22.0 // indirect
122122
golang.org/x/time v0.7.0 // indirect
123123
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
124124
google.golang.org/genproto/googleapis/api v0.0.0-20250115164207-1a7da9e5054f // indirect

0 commit comments

Comments
 (0)