Skip to content

Commit 8d529da

Browse files
committed
Rename "bootstrap" to "migrate" mode
Fixes #18
1 parent d5abb88 commit 8d529da

File tree

5 files changed

+39
-40
lines changed

5 files changed

+39
-40
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,15 @@ partitionmanager:
8989
table4: {}
9090
```
9191
92-
For tables which are either partitioned but not yet using this tool's schema, or which have no empty partitions, the `bootstrap` command can be useful for proposing alterations to run manually. Note that `bootstrap` proposes commands that are likely to require partial copies of each table, so likely they will require a maintenance period.
92+
For tables which are either partitioned but not yet using this tool's schema, or which have no empty partitions, the `migrate` command can be useful for proposing alterations to run manually. Note that `migrate` proposes commands that are likely to require partial copies of each table, so likely they will require a maintenance period.
9393

9494
```sh
95-
partition-manager --mariadb ~/bin/rootsql-dev-primary bootstrap --out /tmp/bootstrap.yml --table orders
95+
partition-manager --mariadb ~/bin/rootsql-dev-primary migrate --out /tmp/migrate.yml --table orders
9696
INFO:write_state_info:Writing current state information
9797
INFO:write_state_info:(Table("orders"): {'id': 9236}),
9898
9999
# wait some time
100-
partition-manager --mariadb ~/bin/rootsql-dev-primary bootstrap --in /tmp/bootstrap.yml --table orders
100+
partition-manager --mariadb ~/bin/rootsql-dev-primary migrate --in /tmp/migrate.yml --table orders
101101
INFO:calculate_sql_alters:Reading prior state information
102102
INFO:calculate_sql_alters:Table orders, 24.0 hours, [9236] - [29236], [20000] pos_change, [832.706363653845]/hour
103103
orders:
@@ -110,7 +110,7 @@ orders:
110110

111111
- At start, if any configuration file specified as a CLI argument, read that configuration file to set all other values.
112112
- Then, process all remaining command line arguments, overriding values loaded from the configuration file in case of conflicts.
113-
- From those command-line arguments, determine whether to collect statistics `stats`, determine an initial partition layout `bootstrap`, or operate in the normal `maintain` mode.
113+
- From those command-line arguments, determine whether to collect statistics `stats`, determine an initial partition layout `migrate`, or operate in the normal `maintain` mode.
114114
- Use the configuration information as inputs to the required algorithm.
115115

116116
### How does `partman` determine when an additional partition is needed?
@@ -156,9 +156,9 @@ Procedure:
156156

157157
The results of the algorithm are converted into `ALTER` statements; if the user configured `--noop` they're emitted to console and the logs for each table. If not set to `--noop`, the application will execute the ALTERs at the database server and emit the results, including execution time as prometheus statistics if so configured.
158158

159-
#### "Bootstrap" algorithm
159+
#### "Migrate" algorithm
160160

161-
The bootstrap mode is a limited form of the "Maintain" Algorithm, using a temporary state file to determine rates-of-change. The bootstrap mode also does not limit itself to only affecting empty partitions, it can and will request changes that will prompt row copies, in order to prepare a table for future use of the "Maintain" algorithm.
161+
The migrate mode is a limited form of the "Maintain" Algorithm, using a temporary state file to determine rates-of-change. The migrate mode also does not limit itself to only affecting empty partitions, it can and will request changes that will prompt row copies, in order to prepare a table for future use of the "Maintain" algorithm.
162162

163163
## TODOs
164164

partitionmanager/cli.py

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
import traceback
1010
import yaml
1111

12-
import partitionmanager.bootstrap
12+
import partitionmanager.migrate
13+
import partitionmanager.sql
14+
import partitionmanager.stats
1315
import partitionmanager.table_append_partition as pm_tap
1416
import partitionmanager.types
15-
import partitionmanager.stats
16-
import partitionmanager.sql
1717

1818
PARSER = argparse.ArgumentParser(
1919
description="""
@@ -235,49 +235,48 @@ def stats_cmd(args):
235235
STATS_PARSER.set_defaults(func=stats_cmd)
236236

237237

238-
def bootstrap_cmd(args):
239-
"""Runs bootstrap actions on the config that results from the CLI arguments.
238+
def migrate_cmd(args):
239+
"""Runs migration actions on the config that results from the CLI arguments.
240240
241241
Helper for argparse.
242242
"""
243243
conf = config_from_args(args)
244244

245245
if args.outfile:
246-
partitionmanager.bootstrap.write_state_info(conf, args.outfile)
246+
partitionmanager.migrate.write_state_info(conf, args.outfile)
247247

248248
if args.infile:
249-
return partitionmanager.bootstrap.calculate_sql_alters_from_state_info(
249+
return partitionmanager.migrate.calculate_sql_alters_from_state_info(
250250
conf, args.infile
251251
)
252252
return {}
253253

254254

255-
BOOTSTRAP_PARSER = SUBPARSERS.add_parser(
256-
"bootstrap",
257-
help="bootstrap partitions that haven't been used with this tool before",
255+
MIGRATE_PARSER = SUBPARSERS.add_parser(
256+
"migrate", help="migrate partitions that haven't been used with this tool before"
258257
)
259-
BOOTSTRAP_GROUP = BOOTSTRAP_PARSER.add_mutually_exclusive_group()
260-
BOOTSTRAP_GROUP.add_argument(
258+
MIGRATE_GROUP = MIGRATE_PARSER.add_mutually_exclusive_group()
259+
MIGRATE_GROUP.add_argument(
261260
"--in", "-i", dest="infile", type=argparse.FileType("r"), help="input YAML"
262261
)
263-
BOOTSTRAP_GROUP.add_argument(
262+
MIGRATE_GROUP.add_argument(
264263
"--out", "-o", dest="outfile", type=argparse.FileType("w"), help="output YAML"
265264
)
266-
BOOTSTRAP_PARSER.add_argument(
265+
MIGRATE_PARSER.add_argument(
267266
"--table",
268267
"-t",
269268
type=partitionmanager.types.SqlInput,
270269
nargs="+",
271270
help="table names, overwriting config",
272271
)
273-
BOOTSTRAP_PARSER.add_argument(
272+
MIGRATE_PARSER.add_argument(
274273
"--assume-partitioned-on",
275274
type=partitionmanager.types.SqlInput,
276275
action="append",
277276
help="Assume tables are partitioned by this column name, can be specified "
278277
"multiple times for multi-column partitions",
279278
)
280-
BOOTSTRAP_PARSER.set_defaults(func=bootstrap_cmd)
279+
MIGRATE_PARSER.set_defaults(func=migrate_cmd)
281280

282281

283282
def do_partition(conf):

partitionmanager/cli_test.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
from pathlib import Path
77
from .cli import (
88
all_configured_tables_are_compatible,
9-
bootstrap_cmd,
9+
migrate_cmd,
1010
config_from_args,
1111
do_partition,
1212
PARSER,
1313
partition_cmd,
1414
stats_cmd,
1515
)
16-
from .bootstrap import calculate_sql_alters_from_state_info
16+
from .migrate import calculate_sql_alters_from_state_info
1717

1818

1919
fake_exec = Path(__file__).absolute().parent.parent / "test_tools/fake_mariadb.sh"
@@ -410,13 +410,13 @@ def test_cli_sqlurl_override_yaml(self):
410410
datetime.now(),
411411
)
412412

413-
def test_bootstrap_cmd_out(self):
413+
def test_migrate_cmd_out(self):
414414
with tempfile.NamedTemporaryFile() as outfile:
415415
args = PARSER.parse_args(
416416
[
417417
"--mariadb",
418418
str(fake_exec),
419-
"bootstrap",
419+
"migrate",
420420
"--out",
421421
outfile.name,
422422
"--table",
@@ -425,7 +425,7 @@ def test_bootstrap_cmd_out(self):
425425
]
426426
)
427427

428-
output = bootstrap_cmd(args)
428+
output = migrate_cmd(args)
429429
self.assertEqual({}, output)
430430

431431
out_yaml = yaml.safe_load(Path(outfile.name).read_text())
@@ -438,13 +438,13 @@ def test_bootstrap_cmd_out(self):
438438
{"tables": {"partitioned_yesterday": {"id": 150}, "two": {"id": 150}}},
439439
)
440440

441-
def test_bootstrap_cmd_out_unpartitioned(self):
441+
def test_migrate_cmd_out_unpartitioned(self):
442442
with tempfile.NamedTemporaryFile() as outfile:
443443
args = PARSER.parse_args(
444444
[
445445
"--mariadb",
446446
str(fake_exec),
447-
"bootstrap",
447+
"migrate",
448448
"--out",
449449
outfile.name,
450450
"--table",
@@ -456,15 +456,15 @@ def test_bootstrap_cmd_out_unpartitioned(self):
456456
with self.assertRaisesRegex(
457457
Exception, "Table unpartitioned is not partitioned"
458458
):
459-
bootstrap_cmd(args)
459+
migrate_cmd(args)
460460

461-
def test_bootstrap_cmd_out_unpartitioned_with_override(self):
461+
def test_migrate_cmd_out_unpartitioned_with_override(self):
462462
with tempfile.NamedTemporaryFile() as outfile:
463463
args = PARSER.parse_args(
464464
[
465465
"--mariadb",
466466
str(fake_exec),
467-
"bootstrap",
467+
"migrate",
468468
"--assume-partitioned-on",
469469
"id",
470470
"--out",
@@ -473,7 +473,7 @@ def test_bootstrap_cmd_out_unpartitioned_with_override(self):
473473
"unpartitioned",
474474
]
475475
)
476-
output = bootstrap_cmd(args)
476+
output = migrate_cmd(args)
477477
self.assertEqual({}, output)
478478

479479
out_yaml = yaml.safe_load(Path(outfile.name).read_text())
@@ -483,7 +483,7 @@ def test_bootstrap_cmd_out_unpartitioned_with_override(self):
483483

484484
self.assertEqual(out_yaml, {"tables": {"unpartitioned": {"id": 150}}})
485485

486-
def test_bootstrap_cmd_in(self):
486+
def test_migrate_cmd_in(self):
487487
with tempfile.NamedTemporaryFile(mode="w+") as infile:
488488
yaml.dump(
489489
{
@@ -497,7 +497,7 @@ def test_bootstrap_cmd_in(self):
497497
[
498498
"--mariadb",
499499
str(fake_exec),
500-
"bootstrap",
500+
"migrate",
501501
"--in",
502502
infile.name,
503503
"--table",
@@ -571,7 +571,7 @@ def test_bootstrap_cmd_in(self):
571571
},
572572
)
573573

574-
def test_bootstrap_cmd_in_unpartitioned_with_override(self):
574+
def test_migrate_cmd_in_unpartitioned_with_override(self):
575575
with tempfile.NamedTemporaryFile(mode="w+") as infile:
576576
yaml.dump(
577577
{
@@ -585,7 +585,7 @@ def test_bootstrap_cmd_in_unpartitioned_with_override(self):
585585
[
586586
"--mariadb",
587587
str(fake_exec),
588-
"bootstrap",
588+
"migrate",
589589
"--assume-partitioned-on",
590590
"id",
591591
"--in",
@@ -633,7 +633,7 @@ def test_bootstrap_cmd_in_unpartitioned_with_override(self):
633633
},
634634
)
635635

636-
def test_bootstrap_cmd_in_out(self):
636+
def test_migrate_cmd_in_out(self):
637637
with tempfile.NamedTemporaryFile() as outfile, tempfile.NamedTemporaryFile(
638638
mode="w+"
639639
) as infile:
@@ -642,7 +642,7 @@ def test_bootstrap_cmd_in_out(self):
642642
[
643643
"--mariadb",
644644
str(fake_exec),
645-
"bootstrap",
645+
"migrate",
646646
"--out",
647647
outfile.name,
648648
"--in",
File renamed without changes.

partitionmanager/bootstrap_test.py renamed to partitionmanager/migrate_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import yaml
44
from datetime import datetime, timedelta
55

6-
from .bootstrap import (
6+
from .migrate import (
77
_generate_sql_copy_commands,
88
_get_time_offsets,
99
_suffix,

0 commit comments

Comments
 (0)