Skip to content

Commit b2218bd

Browse files
egeguneshors
andauthored
K8SPSMDB-1412: More PBM v2.10.0 fixes (#2076)
* K8SPSMDB-1412: Fix s3-compatible GCS backups/restore during upgrade * K8SPSMDB-1412: Fix deleting GCS backups taken by PBM <2.10.0 * fix e2e tests * #r2401189813 * #r2401060318 * #r2401169742 * #r2398982035 * don't reconcile pbm config if backups are disabled * fix deleting pitr chunks with s3-compatible gcs * fix deleting incremental-base backups * add upgrade-partial-backup e2e test * run new test * fix resync for GCS * improvements * fix backupSource.gcs * fix cluster-wide deployments in tests --------- Co-authored-by: Viacheslav Sarzhan <slava.sarzhan@percona.com>
1 parent 63de1f4 commit b2218bd

File tree

28 files changed

+786
-46
lines changed

28 files changed

+786
-46
lines changed

config/crd/bases/psmdb.percona.com_perconaservermongodbs.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24826,10 +24826,10 @@ spec:
2482624826
type: object
2482724827
status:
2482824828
properties:
24829-
backup:
24830-
type: string
2483124829
backupConfigHash:
2483224830
type: string
24831+
backupImage:
24832+
type: string
2483324833
backupVersion:
2483424834
type: string
2483524835
conditions:

deploy/bundle.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25621,10 +25621,10 @@ spec:
2562125621
type: object
2562225622
status:
2562325623
properties:
25624-
backup:
25625-
type: string
2562625624
backupConfigHash:
2562725625
type: string
25626+
backupImage:
25627+
type: string
2562825628
backupVersion:
2562925629
type: string
2563025630
conditions:

deploy/crd.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25621,10 +25621,10 @@ spec:
2562125621
type: object
2562225622
status:
2562325623
properties:
25624-
backup:
25625-
type: string
2562625624
backupConfigHash:
2562725625
type: string
25626+
backupImage:
25627+
type: string
2562825628
backupVersion:
2562925629
type: string
2563025630
conditions:

deploy/cw-bundle.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25621,10 +25621,10 @@ spec:
2562125621
type: object
2562225622
status:
2562325623
properties:
25624-
backup:
25625-
type: string
2562625624
backupConfigHash:
2562725625
type: string
25626+
backupImage:
25627+
type: string
2562825628
backupVersion:
2562925629
type: string
2563025630
conditions:

e2e-tests/functions

Lines changed: 85 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,27 @@ get_operator_pod() {
166166
-o 'jsonpath={.items[].metadata.name}' ${OPERATOR_NS:+-n $OPERATOR_NS}
167167
}
168168

169+
wait_operator_pod() {
170+
local pod=$1
171+
172+
set +o xtrace
173+
retry=0
174+
echo -n "waiting for pod/$pod to be ready"
175+
until kubectl_bin get pod/$pod ${OPERATOR_NS:+-n $OPERATOR_NS} -o jsonpath='{.status.containerStatuses[0].ready}' 2>/dev/null | grep --quiet 'true'; do
176+
sleep 1
177+
echo -n .
178+
let retry+=1
179+
if [[ $retry -ge 360 ]]; then
180+
kubectl_bin describe pod/$pod
181+
kubectl_bin logs $pod ${OPERATOR_NS:+-n $OPERATOR_NS}
182+
echo max retry count $retry reached. something went wrong with operator or kubernetes cluster
183+
exit 1
184+
fi
185+
done
186+
echo ".OK"
187+
set_debug
188+
}
189+
169190
wait_pod() {
170191
local pod=$1
171192

@@ -456,7 +477,7 @@ apply_rbac() {
456477
}
457478

458479
deploy_operator() {
459-
desc 'start PSMDB operator'
480+
desc "start PSMDB operator: ${IMAGE}"
460481

461482
local cr_file
462483
if [ -f "${test_dir}/conf/crd.yaml" ]; then
@@ -472,7 +493,7 @@ deploy_operator() {
472493
(.spec.template.spec.containers[].image = "'${IMAGE}'") |
473494
((.. | select(.[] == "DISABLE_TELEMETRY")) |= .value="true") |
474495
((.. | select(.[] == "LOG_LEVEL")) |= .value="DEBUG")' ${src_dir}/deploy/cw-operator.yaml \
475-
| kubectl_bin apply -f -
496+
| kubectl_bin apply ${OPERATOR_NS:+-n $OPERATOR_NS} -f -
476497
else
477498
apply_rbac rbac
478499
yq eval '
@@ -481,10 +502,10 @@ deploy_operator() {
481502
((.. | select(.[] == "LOG_LEVEL")) |= .value="DEBUG")' ${src_dir}/deploy/operator.yaml \
482503
| kubectl_bin apply -f -
483504
fi
484-
sleep 2
485-
wait_pod $(get_operator_pod)
505+
sleep 20
506+
wait_operator_pod $(get_operator_pod)
486507
echo "Print operator info from log"
487-
kubectl_bin logs $(get_operator_pod) | grep 'Manager starting up'
508+
kubectl_bin logs ${OPERATOR_NS:+-n $OPERATOR_NS} $(get_operator_pod) | grep 'Manager starting up'
488509
}
489510

490511
deploy_operator_gh() {
@@ -501,13 +522,41 @@ deploy_operator_gh() {
501522
kubectl_bin apply -f "https://raw.githubusercontent.com/percona/percona-server-mongodb-operator/${git_tag}/deploy/${rbac_yaml}.yaml"
502523
curl -s "https://raw.githubusercontent.com/percona/percona-server-mongodb-operator/${git_tag}/deploy/${operator_yaml}.yaml" >"${tmp_dir}/${operator_yaml}_${git_tag}.yaml"
503524

504-
$sed -i -e "s^image: .*^image: ${IMAGE}^" "${tmp_dir}/${operator_yaml}_${git_tag}.yaml"
505-
kubectl_bin apply -f "${tmp_dir}/${operator_yaml}_${git_tag}.yaml"
525+
yq eval '
526+
(.spec.template.spec.containers[].image = "'${IMAGE}'") |
527+
((.. | select(.[] == "DISABLE_TELEMETRY")) |= .value="true") |
528+
((.. | select(.[] == "LOG_LEVEL")) |= .value="DEBUG")' "${tmp_dir}/${operator_yaml}_${git_tag}.yaml" \
529+
| kubectl_bin apply ${OPERATOR_NS:+-n $OPERATOR_NS} -f -
506530

507531
sleep 2
508-
wait_pod "$(get_operator_pod)"
532+
wait_operator_pod "$(get_operator_pod)"
533+
echo "Print operator info from log"
534+
kubectl_bin logs ${OPERATOR_NS:+-n $OPERATOR_NS} $(get_operator_pod) | grep 'Manager starting up'
535+
}
536+
537+
deploy_operator_gh_release() {
538+
local git_tag="$1"
539+
540+
desc "start operator ${git_tag}"
541+
kubectl_bin apply -f "https://raw.githubusercontent.com/percona/percona-server-mongodb-operator/${git_tag}/deploy/crd.yaml" --server-side
542+
local rbac_yaml="rbac"
543+
local operator_yaml="operator"
544+
if [ -n "${OPERATOR_NS}" ]; then
545+
rbac_yaml="cw-rbac"
546+
operator_yaml="cw-operator"
547+
fi
548+
kubectl_bin apply -f "https://raw.githubusercontent.com/percona/percona-server-mongodb-operator/${git_tag}/deploy/${rbac_yaml}.yaml"
549+
curl -s "https://raw.githubusercontent.com/percona/percona-server-mongodb-operator/${git_tag}/deploy/${operator_yaml}.yaml" >"${tmp_dir}/${operator_yaml}_${git_tag}.yaml"
550+
551+
yq eval '
552+
((.. | select(.[] == "DISABLE_TELEMETRY")) |= .value="true") |
553+
((.. | select(.[] == "LOG_LEVEL")) |= .value="DEBUG")' "${tmp_dir}/${operator_yaml}_${git_tag}.yaml" \
554+
| kubectl_bin apply ${OPERATOR_NS:+-n $OPERATOR_NS} -f -
555+
556+
sleep 20
557+
wait_operator_pod "$(get_operator_pod)"
509558
echo "Print operator info from log"
510-
kubectl_bin logs $(get_operator_pod) | grep 'Manager starting up'
559+
kubectl_bin logs ${OPERATOR_NS:+-n $OPERATOR_NS} $(get_operator_pod) | grep 'Manager starting up'
511560
}
512561

513562
deploy_minio() {
@@ -1406,6 +1455,14 @@ apply_cluster() {
14061455
fi
14071456
}
14081457

1458+
# get_cluster_gh echoes the default cr.yaml on github
1459+
# so caller can do intended modifications and apply it
1460+
get_cluster_gh() {
1461+
local git_tag=$1
1462+
1463+
curl -s "https://raw.githubusercontent.com/percona/percona-server-mongodb-operator/${git_tag}/deploy/cr.yaml"
1464+
}
1465+
14091466
spinup_psmdb() {
14101467
local cluster=$1
14111468
local config=$2
@@ -1513,9 +1570,10 @@ run_backup() {
15131570
}
15141571

15151572
check_backup_deletion() {
1516-
path=$1
1517-
storage_name=$2
1518-
retry=0
1573+
local path=$1
1574+
local storage_name=$2
1575+
local retry=0
1576+
15191577
until [[ $(curl -sw '%{http_code}' -o /dev/null $path) -eq 403 ]] || [[ $(curl -sw '%{http_code}' -o /dev/null $path) -eq 404 ]]; do
15201578
if [ $retry -ge 10 ]; then
15211579
echo max retry count $retry reached. something went wrong with operator or kubernetes cluster
@@ -1545,6 +1603,21 @@ create_infra() {
15451603
fi
15461604
}
15471605

1606+
create_infra_gh_release() {
1607+
local ns="$1"
1608+
local git_tag="$2"
1609+
1610+
check_crd_for_deletion "${git_tag}"
1611+
if [ -n "${OPERATOR_NS}" ]; then
1612+
create_namespace "${OPERATOR_NS}"
1613+
deploy_operator_gh_release "${git_tag}"
1614+
create_namespace "${ns}"
1615+
else
1616+
create_namespace "${ns}"
1617+
deploy_operator_gh_release "${git_tag}"
1618+
fi
1619+
}
1620+
15481621
create_infra_gh() {
15491622
local ns="$1"
15501623
local git_tag="$2"

e2e-tests/run-backups.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ pitr-physical-backup-source
2222
pitr-sharded
2323
pitr-to-new-cluster
2424
scheduled-backup
25+
upgrade-partial-backup

e2e-tests/run-pr.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,6 @@ upgrade
6767
upgrade-consistency
6868
upgrade-consistency-sharded-tls
6969
upgrade-sharded
70+
upgrade-partial-backup
7071
users
7172
version-service

e2e-tests/run-release.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,6 @@ upgrade
6767
upgrade-consistency
6868
upgrade-consistency-sharded-tls
6969
upgrade-sharded
70+
upgrade-partial-backup
7071
users
7172
version-service
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
switched to db myApp
2+
{ "_id" : , "x" : 100500 }
3+
{ "_id" : , "x" : 100501 }
4+
{ "_id" : , "x" : 100502 }
5+
{ "_id" : , "x" : 100503 }
6+
bye
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
switched to db myApp
2+
{ "_id" : , "x" : 100500 }
3+
bye

0 commit comments

Comments
 (0)