Skip to content

Commit b13608d

Browse files
authored
Revert "Remove remaining references to internal_stack (#3633)" (#3645)
Signed-off-by: Itai Segall <itai.segall@digitalasset.com>
1 parent fb140ba commit b13608d

File tree

3 files changed

+50
-37
lines changed

3 files changed

+50
-37
lines changed

build-tools/cncluster

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1735,16 +1735,23 @@ subcommand_whitelist[backup_nodes]='Backup one or more CN nodes in the cluster'
17351735
function subcmd_backup_nodes() {
17361736
_cluster_must_exist
17371737

1738-
if [ "$#" -lt 1 ]; then
1739-
echo "Usage: $0 <migration_id> [node...]"
1738+
if [ "$#" -lt 2 ]; then
1739+
echo "Usage: $0 <migration_id> <internal_stack> [node...]"
17401740
exit 1
17411741
fi
17421742

17431743
if [[ ! "$1" =~ ^[0-9]+$ ]]; then
17441744
echo "Usage: $0 <migration_id> [node...]"
17451745
_error "<migration_id> must be a positive integer"
17461746
fi
1747+
1748+
if [[ "$2" != "true" && "$2" != "false" ]]; then
1749+
echo "Usage: $0 <internal_stack> [node...]"
1750+
_error "<internal_stack> must be either \"true\" or \"false\""
1751+
fi
1752+
17471753
migration_id=$1
1754+
internal_stack=$2
17481755

17491756
if [ $# -eq 2 ]; then
17501757
nodes="sv-1 sv-2 sv-3 sv-da-1 validator1 splitwell"
@@ -1757,11 +1764,11 @@ function subcmd_backup_nodes() {
17571764
case "$node" in
17581765
sv-1|sv-2|sv-3|sv-4|sv-da-1)
17591766
_info "Backing up sv node $node"
1760-
SPLICE_SV=$node SPLICE_MIGRATION_ID=$migration_id "$SPLICE_ROOT"/cluster/scripts/node-backup.sh sv "$node" "$migration_id"
1767+
SPLICE_SV=$node SPLICE_MIGRATION_ID=$migration_id "$SPLICE_ROOT"/cluster/scripts/node-backup.sh sv "$node" "$migration_id" "$internal_stack"
17611768
;;
17621769
validator1|splitwell)
17631770
_info "Backing up validator node $node"
1764-
SPLICE_SV=$node SPLICE_MIGRATION_ID=$migration_id "$SPLICE_ROOT"/cluster/scripts/node-backup.sh validator "$node" "$migration_id"
1771+
SPLICE_SV=$node SPLICE_MIGRATION_ID=$migration_id "$SPLICE_ROOT"/cluster/scripts/node-backup.sh validator "$node" "$migration_id" "$internal_stack"
17651772
;;
17661773
*)
17671774
_error "Unknown node $node"
@@ -1798,15 +1805,16 @@ function subcmd_restore_node() {
17981805

17991806
node="${1-}"
18001807
migration_id="${2-}"
1801-
backup_run_id="${3-}"
1808+
internal_stack="${3-}"
1809+
backup_run_id="${4-}"
18021810

18031811
if [ -z "$node" ] || [ -z "$migration_id" ]; then
1804-
_error "Usage: $SCRIPTNAME restore_node <namespace_name> <migration_id> [<backup_run_id>]"
1812+
_error "Usage: $SCRIPTNAME restore_node <namespace_name> <migration_id> <internal_stack> [<backup_run_id>]"
18051813
fi
18061814

18071815
if [ -z "$backup_run_id" ]; then
18081816
_info "No backup run_id given, looking for the latest full backup"
1809-
backup_run_id=$(SPLICE_SV=$node SPLICE_MIGRATION_ID=$migration_id "$SPLICE_ROOT"/cluster/scripts/find-recent-backup.sh "$node" "$migration_id")
1817+
backup_run_id=$(SPLICE_SV=$node SPLICE_MIGRATION_ID=$migration_id "$SPLICE_ROOT"/cluster/scripts/find-recent-backup.sh "$node" "$migration_id" "$internal_stack")
18101818
if [[ -z "$backup_run_id" || "$backup_run_id" == "null" ]]; then
18111819
_error "No recent backup found for $node"
18121820
fi
@@ -1823,11 +1831,11 @@ function subcmd_restore_node() {
18231831
_info "Silencing SV report creation alerts for $sv_name for 1 hour"
18241832
subcmd_silence_grafana_alerts "1 hour" "alertname=Report Creation Time Lag" "report_publisher=$sv_name"
18251833
_info "Restoring sv node $node"
1826-
SPLICE_SV=$node SPLICE_MIGRATION_ID=$migration_id "$SPLICE_ROOT"/cluster/scripts/node-restore.sh $force "$node" "$migration_id" "$backup_run_id" cometbft sequencer participant mediator cn-apps
1834+
SPLICE_SV=$node SPLICE_MIGRATION_ID=$migration_id "$SPLICE_ROOT"/cluster/scripts/node-restore.sh $force "$node" "$migration_id" "$backup_run_id" "$internal_stack" cometbft sequencer participant mediator cn-apps
18271835
;;
18281836
validator1|splitwell)
18291837
_info "Restoring validator node $node"
1830-
SPLICE_SV=$node SPLICE_MIGRATION_ID=$migration_id "$SPLICE_ROOT"/cluster/scripts/node-restore.sh $force "$node" "$migration_id" "$backup_run_id" participant validator
1838+
SPLICE_SV=$node SPLICE_MIGRATION_ID=$migration_id "$SPLICE_ROOT"/cluster/scripts/node-restore.sh $force "$node" "$migration_id" "$backup_run_id" "$internal_stack" participant validator
18311839
;;
18321840
*)
18331841
_error "Unknown node $node"

cluster/scripts/find-recent-backup.sh

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ source "${TOOLS_LIB}/libcli.source"
1111
source "${SPLICE_ROOT}/cluster/scripts/utils.source"
1212

1313
function usage() {
14-
_info "Usage: $0 <namespace> <migration_id>"
14+
_info "Usage: $0 <namespace> <migration_id> <internal (true|false)>"
1515
}
1616

1717
function is_full_backup_kube() {
@@ -64,15 +64,16 @@ function latest_full_backup_run_id_gcloud() {
6464
local migration_id=$2
6565
local is_sv=$3
6666
local expected_components=$4
67+
local internal=$5
6768
local num_components
6869
num_components=$(echo "$expected_components" | wc -w)
6970
local stack
7071

7172
declare -A run_ids_dict
7273

7374
for component in $expected_components; do
74-
stack=$(get_stack_for_namespace_component "$namespace" "$component")
75-
instance="$(create_component_instance "$component" "$migration_id" "$namespace")"
75+
stack=$(get_stack_for_namespace_component "$namespace" "$component" "$internal")
76+
instance="$(create_component_instance "$component" "$migration_id" "$namespace" "$internal")"
7677
local full_component_instance="$namespace-$instance-pg"
7778

7879
local cloudsql_id
@@ -109,26 +110,27 @@ function latest_full_backup_run_id_gcloud() {
109110
}
110111

111112
function main() {
112-
if [ "$#" -lt 2 ]; then
113+
if [ "$#" -lt 3 ]; then
113114
usage
114115
exit 1
115116
fi
116117

117118
local namespace=$1
118119
local migration_id=$2
120+
local internal=$3
119121

120122
case "$namespace" in
121123
sv-1|sv-2|sv-3|sv-4|sv-da-1)
122124
is_sv=true
123125
full_instance="$namespace-cn-apps-pg"
124126
expected_components="cn-apps sequencer participant mediator"
125-
stack=$(get_stack_for_namespace_component "$namespace" "cn-apps")
127+
stack=$(get_stack_for_namespace_component "$namespace" "cn-apps" "$internal")
126128
;;
127129
*)
128130
is_sv=false
129131
full_instance="$namespace-validator-pg"
130132
expected_components="validator participant"
131-
stack=$(get_stack_for_namespace_component "$namespace" "participant")
133+
stack=$(get_stack_for_namespace_component "$namespace" "participant" "$internal")
132134
;;
133135
esac
134136

@@ -138,7 +140,7 @@ function main() {
138140
backup_run_id=$(latest_full_backup_run_id_kube "$namespace" "$migration_id" "$is_sv" "$expected_components")
139141
echo "$backup_run_id"
140142
elif [ "$type" == "canton:cloud:postgres" ]; then
141-
backup_run_id=$(latest_full_backup_run_id_gcloud "$namespace" "$migration_id" "$is_sv" "$expected_components")
143+
backup_run_id=$(latest_full_backup_run_id_gcloud "$namespace" "$migration_id" "$is_sv" "$expected_components" "$internal")
142144
echo "$backup_run_id"
143145
elif [ -z "$type" ]; then
144146
_error "No postgres instance $full_instance found in stack ${stack}. Is the cluster deployed with split DB instances?"

cluster/scripts/node-backup.sh

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -208,16 +208,17 @@ function backup_component() {
208208
local component=$2
209209
local requested_component=$3
210210
local migration_id=$4
211+
local internal=$5
211212

212213
local stack
213-
stack=$(get_stack_for_namespace_component "$namespace" "$component")
214+
stack=$(get_stack_for_namespace_component "$namespace" "$component" "$internal")
214215

215216
if [ "$component" == "$requested_component" ] || [ -z "$requested_component" ]; then
216217
if [ "$component" == "cometbft-$migration_id" ]; then
217218
backup_pvc "cometBFT" "$namespace" "global-domain-$migration_id-cometbft-cometbft-data" "$migration_id"
218219
else
219220
local db_name
220-
db_name=$(create_component_instance "$component" "$migration_id" "$namespace")
221+
db_name=$(create_component_instance "$component" "$migration_id" "$namespace" "$internal")
221222
SPLICE_SV=$namespace SPLICE_MIGRATION_ID=$migration_id backup_postgres "$component" "$namespace" "$db_name-pg" "$migration_id" "$stack"
222223
fi
223224
else
@@ -230,15 +231,16 @@ function wait_for_backup() {
230231
local component=$2
231232
local requested_component=$3
232233
local migration_id=$4
234+
local internal=$5
233235

234236
local stack
235-
stack=$(get_stack_for_namespace_component "$namespace" "$component")
237+
stack=$(get_stack_for_namespace_component "$namespace" "$component" "$internal")
236238

237239
if [ "$component" == "$requested_component" ] || [ -z "$requested_component" ]; then
238240
if [ "$component" == "cometbft-$migration_id" ]; then
239241
wait_for_pvc_backup "cometBFT" "$namespace" "global-domain-$migration_id-cometbft-cometbft-data"
240242
else
241-
instance=$(create_component_instance "$component" "$migration_id" "$namespace")
243+
instance=$(create_component_instance "$component" "$migration_id" "$namespace" "$internal")
242244
wait_for_postgres_backup "$component" "$namespace" "$instance-pg" "$migration_id" "$stack"
243245
fi
244246
else
@@ -247,44 +249,45 @@ function wait_for_backup() {
247249
}
248250

249251
function usage() {
250-
echo "Usage: $0 <sv|validator> <namespace> <migration id> [<component_name>]"
252+
echo "Usage: $0 <sv|validator> <namespace> <migration id> <internal (true|false)> [<component_name>]"
251253
}
252254

253255
function main() {
254-
if [ "$#" -lt 3 ]; then
256+
if [ "$#" -lt 4 ]; then
255257
usage
256258
exit 1
257259
fi
258260

259261
local namespace=$2
260262
local migration_id=$3
261-
local requested_component="${4:-}"
263+
local internal=$4 # "true" for internal stack, "false" for external stack
264+
local requested_component="${5:-}"
262265

263266
# TODO(#9361): support multiple domains / non-default-ID'd ones
264267
if [ "$1" == "validator" ]; then
265268
_info "Backing up validator $namespace"
266-
backup_component "$namespace" "validator" "$requested_component" "$migration_id"
267-
wait_for_backup "$namespace" "validator" "$requested_component" "$migration_id"
269+
backup_component "$namespace" "validator" "$requested_component" "$migration_id" "$internal"
270+
wait_for_backup "$namespace" "validator" "$requested_component" "$migration_id" "$internal"
268271
# CN apps must be strictly before participant, so we sync on apps before starting the participant backup
269-
backup_component "$namespace" "participant" "$requested_component" "$migration_id"
270-
wait_for_backup "$namespace" "participant" "$requested_component" "$migration_id"
272+
backup_component "$namespace" "participant" "$requested_component" "$migration_id" "$internal"
273+
wait_for_backup "$namespace" "participant" "$requested_component" "$migration_id" "$internal"
271274
elif [ "$1" == "sv" ]; then
272275
_info "Backing up SV node $namespace"
273276

274-
backup_component "$namespace" "cn-apps" "$requested_component" "$migration_id"
275-
backup_component "$namespace" "mediator" "$requested_component" "$migration_id"
276-
backup_component "$namespace" "sequencer" "$requested_component" "$migration_id"
277-
backup_component "$namespace" "cometbft-$migration_id" "$requested_component" "$migration_id"
277+
backup_component "$namespace" "cn-apps" "$requested_component" "$migration_id" "$internal"
278+
backup_component "$namespace" "mediator" "$requested_component" "$migration_id" "$internal"
279+
backup_component "$namespace" "sequencer" "$requested_component" "$migration_id" "$internal"
280+
backup_component "$namespace" "cometbft-$migration_id" "$requested_component" "$migration_id" "$internal"
278281

279-
wait_for_backup "$namespace" "cn-apps" "$requested_component" "$migration_id"
282+
wait_for_backup "$namespace" "cn-apps" "$requested_component" "$migration_id" "$internal"
280283

281284
# CN apps must be strictly before participant, so we sync on apps before starting the participant backup
282-
backup_component "$namespace" "participant" "$requested_component" "$migration_id"
285+
backup_component "$namespace" "participant" "$requested_component" "$migration_id" "$internal"
283286

284-
wait_for_backup "$namespace" "participant" "$requested_component" "$migration_id"
285-
wait_for_backup "$namespace" "mediator" "$requested_component" "$migration_id"
286-
wait_for_backup "$namespace" "sequencer" "$requested_component" "$migration_id"
287-
wait_for_backup "$namespace" "cometbft-$migration_id" "$requested_component" "$migration_id"
287+
wait_for_backup "$namespace" "participant" "$requested_component" "$migration_id" "$internal"
288+
wait_for_backup "$namespace" "mediator" "$requested_component" "$migration_id" "$internal"
289+
wait_for_backup "$namespace" "sequencer" "$requested_component" "$migration_id" "$internal"
290+
wait_for_backup "$namespace" "cometbft-$migration_id" "$requested_component" "$migration_id" "$internal"
288291
else
289292
usage
290293
exit 1

0 commit comments

Comments
 (0)