Open kdienes opened 1 year ago
So, there are two directions in the assignments database: there is a hint--what would we like to assign, and there is a reservation--what is currently assigned. dump_assignments only dumps out the hint.
The intent of dump_assignments is to allow you to store hints for IP and MAC addresses in a persistent manner so that they can be reused even when the state directory is cleared.
In retrospect I may have incorrectly implied that dump_assignments was intended as a debugging tool. It's great if it helps with that, but that's not its primary purpose.
dump_assignments does take a path argument and you can dump somewhere other than the seed_path.
I'd be happy to figure out a different heuristic for when the command should be registered. I want something efficient to compute (so not going over all the networks in the layout to see if they have pools defined, or use persistent_random_mac), indicating there is a high chance the persistent_assignments is used in the layout. My goal is not to register too many irrelevant commands on a carthage layout so that !help doesn't drown a user in things they think might be useful/apply to their circumstance, but actually do not.
--Sam
I assume that it's setting webserver and radiosim as persistent because those are the two addresses you might want to have be stable externally, or something along those lines?
I agree that it makes sense for dump_assignments to only exist when you are using dumped assignments. I think a somewhat-generalized K/V dump/inspect command would be helpful, because I know that I'm not going to be the only one who ends up looking at an mdb file trying to figure out why Carthage is picking a particular address. It's a shame that you probably can't put a comment in the mdb file itself, but I wonder if dropping a README.txt into the mdb/ directory would be easy and helpful.
Why is persistent_seed_path only an add_provider() and not a configvar? Is it "because loading persistent state from a file is part of a layout, and we use configvars for environment-specific configuration"?
"Klee" == Klee Dienes @.***> writes:
Klee> I assume that it's setting webserver and radiosim as
Klee> persistent because those are the two addresses you might want
Klee> to have be stable externally, or something along those lines?
It dumps all addresses that you have assigned through a pool corresponding to models still in the layout. Klee> Why is persistent_seed_path only an add_provider() and not a Klee> configvar? Is it "because loading persistent state from a Klee> file is part of a layout, and we use configvars for Klee> environment-specific configuration"?
More or less, yes. Whether a layout wants its assignments persisted across state directory resets is a property of the layout not the config.
Assume my goal is to understand the persistent assignments that are being used by Carthage.
I can find
/root/.carthage/state/persistent_assignments/*.mdb
I can install lmdb-utils and run
mdb_dump -p /root/.carthage/state/persistent_assignments
and get a dump that's not ideal but at least usableIf someone gives me a hint, and I figure out that I need to add
add_provider(carthage.kvstore.persistent_seed_path, 'seed.yml')
, I can use thedump_assignments
command to get a yaml dump of the assignments, I think. It writes it to the file and then I have to read the file, which is a bit awkward but OK. But the file has a lot fewer K/V pairs than there are in the mdb file, which makes me suspicious.I suspect that I want !dump_assignments to be able to dump to stdout even if I don't define persistent_seed_path. I might also want to be able to set it in config.yml?