Skip to content

Commit d647187

Browse files
scripts: Add an abstraction for how to restart pods.
1 parent 04be961 commit d647187

File tree

4 files changed

+237
-140
lines changed

4 files changed

+237
-140
lines changed

scripts/prod/restart_all_nodes_together.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
NamespaceAndInstructionArgs,
1111
RestartStrategy,
1212
Service,
13+
ServiceRestarter,
1314
get_configmap,
1415
get_current_block_number,
1516
get_logs_explorer_url,
@@ -124,15 +125,22 @@ def main():
124125
f"Please check logs and verify that the node has proposed a block that was accepted. Logs URL: {url}"
125126
)
126127

128+
namespace_and_instruction_args = NamespaceAndInstructionArgs(
129+
namespace_list,
130+
context_list,
131+
post_restart_instructions,
132+
)
133+
restarter = ServiceRestarter.from_restart_strategy(
134+
RestartStrategy.ALL_AT_ONCE,
135+
namespace_and_instruction_args,
136+
Service.Core,
137+
)
138+
127139
update_config_and_restart_nodes(
128140
config_overrides,
129-
NamespaceAndInstructionArgs(
130-
namespace_list,
131-
context_list,
132-
post_restart_instructions,
133-
),
141+
namespace_and_instruction_args,
134142
Service.Core,
135-
RestartStrategy.ALL_AT_ONCE,
143+
restarter,
136144
)
137145

138146

scripts/prod/set_node_revert_mode.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
NamespaceAndInstructionArgs,
1010
RestartStrategy,
1111
Service,
12+
ServiceRestarter,
1213
get_current_block_number,
1314
get_logs_explorer_url,
1415
print_colored,
@@ -51,16 +52,23 @@ def set_revert_mode(
5152
post_restart_instructions.append(
5253
f"Please check logs and verify that revert has completed (both in the batcher and for sync). Logs URL: {url}"
5354
)
55+
5456
namespace_and_instruction_args = NamespaceAndInstructionArgs(
5557
namespace_list,
5658
context_list,
5759
post_restart_instructions,
5860
)
61+
restarter = ServiceRestarter.from_restart_strategy(
62+
restart_strategy,
63+
namespace_and_instruction_args,
64+
Service.Core,
65+
)
66+
5967
update_config_and_restart_nodes(
6068
config_overrides,
6169
namespace_and_instruction_args,
6270
Service.Core,
63-
restart_strategy,
71+
restarter,
6472
)
6573

6674

scripts/prod/update_config_and_restart_nodes.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
from update_config_and_restart_nodes_lib import (
99
ApolloArgsParserBuilder,
1010
Colors,
11+
RestartStrategy,
1112
NamespaceAndInstructionArgs,
1213
Service,
14+
ServiceRestarter,
1315
print_colored,
1416
print_error,
1517
update_config_and_restart_nodes,
@@ -69,7 +71,7 @@ def service_type_converter(service_name: str) -> Service:
6971
if service_name.startswith("Service."):
7072
service_name = service_name[8:]
7173

72-
service_name = service_name.lower()
74+
# service_name = service_name.lower()
7375

7476
try:
7577
return Service[service_name]
@@ -150,15 +152,20 @@ def main():
150152
print_error("No config overrides provided")
151153
sys.exit(1)
152154

153-
update_config_and_restart_nodes(
154-
config_overrides,
155-
NamespaceAndInstructionArgs(
156-
NamespaceAndInstructionArgs.get_namespace_list_from_args(args),
157-
NamespaceAndInstructionArgs.get_context_list_from_args(args),
158-
None,
159-
),
160-
args.service,
155+
namespace_and_instruction_args = NamespaceAndInstructionArgs(
156+
NamespaceAndInstructionArgs.get_namespace_list_from_args(args),
157+
NamespaceAndInstructionArgs.get_context_list_from_args(args),
158+
None,
159+
)
160+
161+
restarter = ServiceRestarter.from_restart_strategy(
161162
args.restart_strategy,
163+
namespace_and_instruction_args,
164+
args.service,
165+
)
166+
167+
update_config_and_restart_nodes(
168+
config_overrides, namespace_and_instruction_args, args.service, restarter
162169
)
163170

164171

0 commit comments

Comments
 (0)