Adapt sync-cli to support synthetics PLs replication for DDR#526
Draft
melkouri wants to merge 3 commits into
Draft
Adapt sync-cli to support synthetics PLs replication for DDR#526melkouri wants to merge 3 commits into
melkouri wants to merge 3 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
synthetics_private_locationsresource, enabling PL replication from a source org (R1) to a destination org (R2).Related PRs:
Description of the Change
New CLI option:
--datadog-host-overrideconstants.py(DD_DATADOG_HOST_OVERRIDEenv var),options.py(CLI flag), andconfiguration.py(threaded toConfigurationdataclass)Updated
synthetics_private_locations.py:excluded_attributes, addedddr_metadataso DDR metadata on the destination is not diffed against the sourcecreate_resource()During sync, when a source PL needs to be created at the destination:
GET /api/v1/synthetics/private-locations/{id}?include_pl_info=trueto obtainpl_id,org_id,datacenter,public_key_test, andpublic_key_resultnullmetadata from the request body (DDR endpoint rejects it)ddr_metadatawith the source PL mapping (source_pl_id,source_name,source_dc,source_org_id)test_encryption_public_keyas the JSON-stringifiedpublic_key_testobjectresult_encryption_public_keyas{"pem": ..., "fingerprint": ...}mapped from the source'spublic_key_resultdatadog_host_overrideresp["private_location"]instead of the normal create response which includesconfigandresult_encryptionat the top level)_save_pl_config()new helper that saves each created PL's config to{destination_resources_path}/synthetics_private_locations_config/{sanitized_pl_name}.jsoncontainingpublicKeysByMainDC(anddatadogHostOverrideif specified). This config is needed later to run the PL worker in R2.Design decision: The
pl_infofields are fetched on-demand increate_resource()from the source API rather than stored in state files. This keeps state files clean (consistent with other resources) and avoids stale data since the fields are only needed at create time.Verification Process
Tested end-to-end on staging (
app.datad0g.com) between two orgs:import: confirmed source state saved correctly (3 PLs imported, 0 failures)sync: confirmed all 3 PLs created successfully in destination org (R2) via DDR endpoint (0 failures)synthetics_private_locations_config/reset: confirmed all Synced destination PLs deleted successfullyRelease Notes
Added DDR (Disaster Recovery) support for
synthetics_private_locationsresource. New--datadog-host-overrideCLI option for optional CNAME override during PL replication.