Skip to content

Add UpstreamPulp.remote_policy for remotes created during replication - #8016

Open
pablomh wants to merge 2 commits into
pulp:mainfrom
pablomh:replica-remote-download-policy
Open

pablomh wants to merge 2 commits into
pulp:mainfrom
pablomh:replica-remote-download-policy

Conversation

@pablomh

@pablomh pablomh commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Remotes created by replicate() never received an explicit download policy, so they used Remote.policy's default (immediate) and downloaded all artifacts.
  • Add nullable UpstreamPulp.remote_policy (immediate / on_demand / streamed) and copy it onto remotes via _build_remote_settings() when set. When unset (null), remotes are explicitly set to Remote.IMMEDIATE so that clearing remote_policy after a previous non-default value correctly reverts existing remotes.
  • Distinct from UpstreamPulp.policy (all / labeled / nodelete). Katello can set remote_policy=on_demand for Capsules.
  • Extract _build_remote_settings() as a standalone function for the shared remote field mapping, replacing the inline dict.

Test plan

  • Unit: _build_remote_settings returns Remote.IMMEDIATE when remote_policy is unset and includes it when set to on_demand
  • Functional: test_replication_remote_policy — create with on_demand, update to streamed, clear to null (verify revert to immediate)
  • Functional: test_replication_remote_settings_propagation — asserts default immediate when remote_policy is not set
  • CI green on this PR

Made with Cursor

@pablomh
pablomh force-pushed the replica-remote-download-policy branch 2 times, most recently from fc37121 to 4745030 Compare August 27, 2026 08:31
@pablomh
pablomh force-pushed the replica-remote-download-policy branch from 4745030 to 9b931ed Compare August 27, 2026 08:36
@pablomh
pablomh force-pushed the replica-remote-download-policy branch from 9b931ed to b45c5d5 Compare August 27, 2026 09:52
@pablomh

pablomh commented Aug 27, 2026

Copy link
Copy Markdown
Contributor Author

CI error seems unrelated and pre-existing.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think we need these unit tests.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed after rebase.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this migration will need to be rebased from main.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@pablomh
pablomh force-pushed the replica-remote-download-policy branch from b45c5d5 to 5016cbe Compare September 16, 2026 17:12
@pablomh
pablomh force-pushed the replica-remote-download-policy branch from 5016cbe to fcd20f3 Compare September 16, 2026 17:15
replicate() never set Remote.policy, so new remotes defaulted to immediate
and downloaded all artifacts. Let UpstreamPulp carry the intended download
policy so Capsules can replicate with on_demand.

Always include policy in the remote settings dict so that clearing
remote_policy (setting it to null) correctly reverts existing remotes
back to Remote.IMMEDIATE instead of leaving the old value stale.

Assisted-By: Cursor
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The generated Python client uses exclude_none=True in model_dump(),
which silently drops None values from raw dicts. By constructing the
PatchedUpstreamPulp model explicitly, Pydantic tracks remote_policy
in model_fields_set and serializes it as null in the PATCH body.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@pablomh
pablomh force-pushed the replica-remote-download-policy branch from d3d1daa to 429c5a3 Compare September 17, 2026 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants