Skip to content

Commit 3cd0736

Browse files
authored
Merge branch 'main' into K8SPSMDB-1211
2 parents 81d2898 + 165b97e commit 3cd0736

File tree

14 files changed

+93
-29
lines changed

14 files changed

+93
-29
lines changed

build/physical-restore-ps-entry.sh

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,36 @@
11
#!/bin/bash
22

3-
set -Eeuo pipefail
3+
set -e
44
set -o xtrace
55

6-
log=/tmp/pbm-agent.log
6+
PBM_AGENT_LOG=/tmp/pbm-agent.log
7+
MONGOD_LOG=/tmp/mongod.log
8+
PHYSICAL_RESTORE_DIR=/data/db/pbm-restore-logs
9+
10+
function handle_sigterm() {
11+
echo "Received SIGTERM, cleaning up..."
12+
13+
mkdir ${PHYSICAL_RESTORE_DIR}
14+
mv pbm.restore.log.* ${PBM_AGENT_LOG} ${MONGOD_LOG} ${PHYSICAL_RESTORE_DIR}/
15+
16+
echo "Restore finished, you can find logs in ${PHYSICAL_RESTORE_DIR}"
17+
exit 0
18+
}
19+
20+
trap 'handle_sigterm' 15
721

822
touch /opt/percona/restore-in-progress
923

10-
/opt/percona/pbm-agent 1>&2 2>${log} &
11-
/opt/percona/ps-entry.sh "$@" 1>&2 2>/tmp/mongod.log
24+
/opt/percona/pbm-agent >${PBM_AGENT_LOG} 2>&1 &
25+
pbm_pid=$!
26+
27+
/opt/percona/ps-entry.sh "$@" >${MONGOD_LOG} 2>&1 &
28+
mongod_pid=$!
1229

13-
echo "Physical restore in progress"
14-
tail -n +1 -f ${log}
15-
sleep infinity
30+
set +o xtrace
31+
echo "Physical restore in progress... pbm-agent logs: ${PBM_AGENT_LOG} mongod logs: ${MONGOD_LOG}"
32+
echo "Script PID: $$, pbm-agent PID: $pbm_pid, mongod PID: $mongod_pid"
33+
while true; do
34+
echo "Still in progress at $(date)"
35+
sleep 10
36+
done

cmd/manager/main.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"sigs.k8s.io/controller-runtime/pkg/webhook"
2828

2929
"github.com/percona/percona-server-mongodb-operator/pkg/apis"
30+
psmdbv1 "github.com/percona/percona-server-mongodb-operator/pkg/apis/psmdb/v1"
3031
"github.com/percona/percona-server-mongodb-operator/pkg/controller"
3132
"github.com/percona/percona-server-mongodb-operator/pkg/k8s"
3233
"github.com/percona/percona-server-mongodb-operator/pkg/mcs"
@@ -103,6 +104,23 @@ func main() {
103104
}),
104105
}
105106

107+
options.Controller.GroupKindConcurrency = map[string]int{
108+
"PerconaServerMongoDB." + psmdbv1.SchemeGroupVersion.Group: 1,
109+
"PerconaServerMongoDBBackup." + psmdbv1.SchemeGroupVersion.Group: 1,
110+
"PerconaServerMongoDBRestore." + psmdbv1.SchemeGroupVersion.Group: 1,
111+
}
112+
113+
if s := os.Getenv("MAX_CONCURRENT_RECONCILES"); s != "" {
114+
if i, err := strconv.Atoi(s); err == nil && i > 0 {
115+
options.Controller.GroupKindConcurrency["PerconaServerMongoDB."+psmdbv1.SchemeGroupVersion.Group] = i
116+
options.Controller.GroupKindConcurrency["PerconaServerMongoDBBackup."+psmdbv1.SchemeGroupVersion.Group] = i
117+
options.Controller.GroupKindConcurrency["PerconaServerMongoDBRestore."+psmdbv1.SchemeGroupVersion.Group] = i
118+
} else {
119+
setupLog.Error(err, "MAX_CONCURRENT_RECONCILES must be a positive number")
120+
os.Exit(1)
121+
}
122+
}
123+
106124
// Add support for MultiNamespace set in WATCH_NAMESPACE
107125
if len(namespace) > 0 {
108126
namespaces := make(map[string]cache.Config)

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ spec:
6767
type: integer
6868
compressionType:
6969
type: string
70-
psmdbCluster:
71-
type: string
7270
storageName:
7371
type: string
7472
type:

deploy/bundle.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ spec:
7171
type: integer
7272
compressionType:
7373
type: string
74-
psmdbCluster:
75-
type: string
7674
storageName:
7775
type: string
7876
type:
@@ -19844,3 +19842,5 @@ spec:
1984419842
value: 5s
1984519843
- name: DISABLE_TELEMETRY
1984619844
value: "false"
19845+
- name: MAX_CONCURRENT_RECONCILES
19846+
value: "1"

deploy/crd.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ spec:
7171
type: integer
7272
compressionType:
7373
type: string
74-
psmdbCluster:
75-
type: string
7674
storageName:
7775
type: string
7876
type:

deploy/cw-bundle.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ spec:
7171
type: integer
7272
compressionType:
7373
type: string
74-
psmdbCluster:
75-
type: string
7674
storageName:
7775
type: string
7876
type:
@@ -19863,3 +19861,5 @@ spec:
1986319861
value: 5s
1986419862
- name: DISABLE_TELEMETRY
1986519863
value: "false"
19864+
- name: MAX_CONCURRENT_RECONCILES
19865+
value: "1"

deploy/cw-operator.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,5 @@ spec:
4646
value: 5s
4747
- name: DISABLE_TELEMETRY
4848
value: "false"
49+
- name: MAX_CONCURRENT_RECONCILES
50+
value: "1"

deploy/operator.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,5 @@ spec:
4848
value: 5s
4949
- name: DISABLE_TELEMETRY
5050
value: "false"
51+
- name: MAX_CONCURRENT_RECONCILES
52+
value: "1"

e2e-tests/custom-replset-name/conf/backup-minio.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ kind: PerconaServerMongoDBBackup
33
metadata:
44
name: backup-minio
55
spec:
6-
psmdbCluster: some-name
6+
clusterName: some-name
77
storageName: minio

e2e-tests/functions

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,36 @@ simple_data_check() {
343343
fi
344344
}
345345

346+
get_mongod_pods() {
347+
local cluster=$1
348+
349+
kubectl_bin get pod \
350+
--no-headers \
351+
-l app.kubernetes.io/instance=${cluster} \
352+
-l app.kubernetes.io/component=mongod
353+
354+
}
355+
356+
collect_physical_restore_logs() {
357+
local cluster=$1
358+
local restore=$2
359+
360+
for pod in $(get_mongod_pods ${cluster}); do
361+
desc "pbm-agent logs from ${pod}"
362+
kubectl_bin exec -it ${pod} -- cat /tmp/pbm-agent.log || true
363+
done
364+
}
365+
366+
is_physical_backup() {
367+
local backup=$1
368+
369+
if [[ $(kubectl_bin get psmdb-backup ${backup} -o jsonpath={.status.type}) == "physical" ]]; then
370+
return 0
371+
fi
372+
373+
return 1
374+
}
375+
346376
wait_restore() {
347377
local backup_name=$1
348378
local cluster_name=$2
@@ -384,6 +414,11 @@ wait_restore() {
384414
| grep -v 'Getting tasks for pod' \
385415
| grep -v 'Getting pods from source' \
386416
| tail -100
417+
418+
if is_physical_backup ${backup_name}; then
419+
collect_physical_restore_logs
420+
fi
421+
387422
kubectl_bin get psmdb-restore restore-${backup_name} -o yaml
388423
kubectl_bin describe psmdb-restore restore-${backup_name}
389424
echo "Restore object restore-${backup_name} is in ${current_state} state."

0 commit comments

Comments
 (0)