Merge lp:~foli/landscape-charm/tools-fixes into lp:~landscape/landscape-charm/tools

Proposed by Michael Foley
Status: Merged
Merged at revision: 26
Proposed branch: lp:~foli/landscape-charm/tools-fixes
Merge into: lp:~landscape/landscape-charm/tools
Diff against target: 29 lines (+4/-1)
1 file modified
db-migrator.py (+4/-1)
To merge this branch: bzr merge lp:~foli/landscape-charm/tools-fixes
Reviewer Review Type Date Requested Status
Chad Smith Approve
Alberto Donato (community) Approve
Review via email: mp+303389@code.launchpad.net

Description of the change

db-migrator: correct store_name for account, add another exclude, print dump/restore commands

the printing of the dump/restore commands is optional, they can be removed on merge if unwanted, but I have found them useful in debugging and to see progress.

This is for work on cRT#92053.

To post a comment you must log in.
Revision history for this message
Chad Smith (chad.smith) wrote :

+1 on this correction to tools store_name. Thanks Michael.

review: Approve
lp:~foli/landscape-charm/tools-fixes updated
24. By Michael Foley

[foli] db-migrator: add generic table exclude argument option, cRT#92053

25. By Michael Foley

[foli] db-migrator: add generic table exclude argument option, cRT#92053

Revision history for this message
Michael Foley (foli) wrote :

Have additionally added a generic table exclude argument option

lp:~foli/landscape-charm/tools-fixes updated
26. By Michael Foley

[foli] db-migrator: add generic table exclude argument option, cRT#92053

Revision history for this message
Chad Smith (chad.smith) wrote :

While the exclude tables argument is good for quick dev and migration checking, I'm sort of averse to adding a generic exclude tables argument.

All of these exclude tables arguments in this tool in general feel like a bandaid for something that landscape broke by not properly dropping a table that we no longer use when we removed it from our model. Hard-coding these known shortcomings in the code is the lesser evil than adding the flexibility to specify any exclude-tables on the commandline because it raises our awareness of patches that landscape now needs to clean up these orphaned tables.

If we further extend the db-migrator tool to allow users to override the intended behavior, we risk losing the data (the feedback loop from the pain of changing the tool) which was needed to just get the migration to work in the first place.

to be noted, the issues you have run into currently with ec2_region and change_package_lock_request and metadata_*_seq have each resulted in landscape db patches in trunk for our next release (so this won't hit other customers at some point).

Revision history for this message
Chad Smith (chad.smith) wrote :

Do you think we can drop the additional exclude-tables argument, but accept the rest of the patch?

review: Needs Information
lp:~foli/landscape-charm/tools-fixes updated
27. By Michael Foley

[foli] db-migrator: revert generic table exclude argument option

Revision history for this message
Michael Foley (foli) wrote :

> Do you think we can drop the additional exclude-tables argument, but accept
> the rest of the patch?

That is fine by me. I was not clear on what the original intention of the tool was, so your arguments make sense to me.

As you said the issues I have run into are being patched and handled so I don't need the generic exclude tables ability. I have been given a command to manually rename the metadata_id_seq sequence to annotation_id_seq, and I will just have to remove extraneous backup tables that someone created in one of our databases to make it clean before migration.

I have reverted my most recent changes, only leaving the "--exclude-table=change_package_lock_request*" and s/account/account-1/ fixes, as well as leaving printing the dump/restore commands being run.

Revision history for this message
Alberto Donato (ack) wrote :

Looks good, +1.

I have a minor comment inline

review: Approve
Revision history for this message
Chad Smith (chad.smith) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'db-migrator.py'
2--- db-migrator.py 2016-08-18 17:45:48 +0000
3+++ db-migrator.py 2016-08-24 22:18:21 +0000
4@@ -163,9 +163,10 @@
5 ]
6 if store_name == "main":
7 options.append("--exclude-table=ec2_region*")
8- if store_name == "account":
9+ if store_name == "account-1":
10 options.append("--exclude-table=create_package_lock_request*")
11 options.append("--exclude-table=remove_package_lock_request*")
12+ options.append("--exclude-table=change_package_lock_request*")
13 user = stores_info["admin"]["user"]
14 if user:
15 options.append("--user={}".format(user))
16@@ -175,6 +176,7 @@
17 env = os.environ.copy()
18 if password:
19 env["PGPASSWORD"] = password
20+ print "Running: {}".format(" ".join(cmd))
21 subprocess.check_call(cmd, env=env)
22
23
24@@ -199,6 +201,7 @@
25 env = os.environ.copy()
26 if password:
27 env["PGPASSWORD"] = password
28+ print "Running: {}".format(" ".join(cmd))
29 subprocess.check_output(cmd, env=env)
30
31

Subscribers

People subscribed via source and target branches

to all changes: