Move .env ownership to this repo and default CDC to pgoutput - #74
Move .env ownership to this repo and default CDC to pgoutput#74DmitriiAn wants to merge 4 commits into
Conversation
Add pgcopydb-helpers/env-template as the reference ~/.env. The user copies it to ~/.env on the migration instance. The provisioning templates no longer create that file. The file cannot be named .env here: .gitignore blocks the name to keep credentials out of git, and the templates deploy with "cp -r pgcopydb-helpers/* /home/ubuntu/", where the shell glob does not match dotfiles. Move the remaining hardcoded tunables into ~/.env: - OUTPUT_PLUGIN, new, default pgoutput. planetscale/pgcopydb#58 adds the pgoutput plugin and makes it the pgcopydb default. It is part of PostgreSQL core, so the source server needs no extension. Set OUTPUT_PLUGIN=wal2json to keep the previous plugin. - SPLIT_TABLES_LARGER_THAN, default 50GB, was a literal in three scripts. - FILTER_FILE, default ~/filters.ini, was a literal in five scripts. run-migration.sh, resume-migration.sh and resume-cdc.sh now log the effective plugin, jobs, split size and filter path to migration.log. drop-replication-slots.sh also drops the source publication. pgcopydb creates one named after the replication slot for pgoutput, so without this it is left behind on the source after every migration. The drop needs ownership of the publication, so the script warns and continues on failure. Every script that sources ~/.env now checks the file exists first and prints the cp command if it does not. Without a guard the scripts failed with a raw "No such file or directory" from the shell, which is reachable now that no template creates the file. Checked with bash -n and shellcheck on the helper scripts and the terraform templates, and cfn-lint on the CloudFormation template.
|
@teknogeek0 |
Summary
~/.envis now owned by this repo instead of the provisioning templates, and every remaining hardcoded tunable moves into it. CDC defaults to thepgoutputplugin.env-templateNew file
pgcopydb-helpers/env-templateis the reference~/.env. On the instance:It cannot be named
.envin the repo..gitignoreblocks that name to keep credentials out of git, and the templates deploy withcp -r pgcopydb-helpers/* /home/ubuntu/, where the shell glob does not match dotfiles. Naming itenv-templatemeans it deploys with the scripts and needs no template change.Tunables moved into
~/.envTABLE_JOBSINDEX_JOBSSPLIT_TABLES_LARGER_THANOUTPUT_PLUGINwal2jsonin 3 scriptsFILTER_FILE~/filters.inirun-migration.sh,resume-migration.shandresume-cdc.shnow log the effective plugin, jobs, split size and filter path tomigration.log.pgoutput
planetscale/pgcopydb#58 adds the
pgoutputplugin and makes it the pgcopydb default. This PR follows it.pgoutputis part of PostgreSQL core, so the source server needs no extension, and it sends about 4.5x less network volume thanwal2json. SetOUTPUT_PLUGIN=wal2jsonto keep the previous plugin.drop-replication-slots.shalso drops the source publication now. pgcopydb creates one named after the replication slot forpgoutput, so without this it is left behind on the source after every migration. The drop needs ownership of the publication, so the script warns and continues on failure.Templates
The three templates no longer create
~/.env.pgcopydb-templates/README.mdnow gives thecp ~/env-template ~/.envsteps.Missing
.envguardNo template creates
~/.envany more, so a fresh instance has none. Every script that sources it failed with a raw shell error:verify-migration.shalready guarded this. The same check is now in the other 13 scripts:Docs
pgcopydb-helpers/README.mdandAGENTS.mdare rewritten around theenv-templateflow, each with a single configuration table and an output-plugin section.Tests
No automated suite in this repo. Checked manually:
bash -non all helper scripts and both terraform templates: pass.shellcheck -S erroron all helper scripts: clean, apart from the pre-existingSC2148infilters-lib.sh.cfn-linton the CloudFormation template: exit 0, no output.FILTER_FILE=~/filters.iniexpands correctly throughset -a; source, and defaults apply with an empty.env..envguard: exits 1 with the message above.