Skip to content

Replicas should atomically update their distributions#7492

Merged
dralley merged 2 commits intopulp:mainfrom
dralley:atomic-replication
Apr 1, 2026
Merged

Replicas should atomically update their distributions#7492
dralley merged 2 commits intopulp:mainfrom
dralley:atomic-replication

Conversation

@dralley
Copy link
Copy Markdown
Contributor

@dralley dralley commented Mar 18, 2026

It's not ideal for distributions to pick up replica changes at random time intervals as various tasks complete, ideally the entire replica is presented as updated at once (or with the smallest possible window).

closes #7333

📜 Checklist

  • Commits are cleanly separated with meaningful messages (simple features and bug fixes should be squashed to one commit)
  • A changelog entry or entries has been added for any significant changes
  • Follows the Pulp policy on AI Usage
  • (For new features) - User documentation and test coverage has been added

See: Pull Request Walkthrough

@dralley dralley force-pushed the atomic-replication branch 3 times, most recently from 95d534b to 8c05e06 Compare March 24, 2026 03:20
@dralley dralley force-pushed the atomic-replication branch 7 times, most recently from 2ca9bc6 to 88a62e8 Compare March 31, 2026 06:39
It's not ideal for distributions to pick up replica changes at random
time intervals as various tasks complete, ideally the entire replica is
presented as updated at once (or with the smallest possible window).

closes pulp#7333
Assisted-By: claude-opus-4.6
@dralley dralley force-pushed the atomic-replication branch from 88a62e8 to a92f9e2 Compare March 31, 2026 12:25
@dralley dralley marked this pull request as ready for review March 31, 2026 12:44
elif upstream_distribution.get("repository_version"):
# Extract repository href from repository_version href
repo_href = upstream_distribution["repository_version"].rsplit("versions/", 1)[0]
manifest = self.repository_ctx_cls(self.pulp_ctx, repo_href).entity["manifest"]
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.

This is tricky, it implies that other plugins may also have compatibility issues without modification

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.

I believe pulp_python may also need a tweak

@dralley
Copy link
Copy Markdown
Contributor Author

dralley commented Mar 31, 2026

Pulp Python: pulp/pulp_python#1174

Pulp Container: pulp/pulp_container#2301

Copy link
Copy Markdown
Contributor

@gerrod3 gerrod3 left a comment

Choose a reason for hiding this comment

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

It looks good, some questions before I approve.

if k not in ("repository_version", "repository", "publication")
}
create_data["name"] = upstream_distribution["name"]
create_data["pulp_labels"] = distribution_data["pulp_labels"]
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.

I remember putting the pulp_labels outside of distribution_extra_fields since not every plugin called the super method when they overwrote it, but maybe with this change we could do that now.

@dralley dralley force-pushed the atomic-replication branch from 645e954 to 56c4df9 Compare April 1, 2026 06:03
@dralley dralley marked this pull request as draft April 1, 2026 06:03
@dralley dralley force-pushed the atomic-replication branch 2 times, most recently from 4087809 to 0b10f41 Compare April 1, 2026 06:10
@dralley
Copy link
Copy Markdown
Contributor Author

dralley commented Apr 1, 2026

Want me to squash the dead code commit?

@dralley dralley marked this pull request as ready for review April 1, 2026 06:18
Comment on lines +195 to +196
# Clear repository and publication so they don't conflict when
# finalize_replication sets repository_version atomically.
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.

While this is needed for the update, we are now going to create a scenario on the first replication after upgrade where distros will start returning 404s until the replication completes.

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.

@gerrod3 You're talking about the very first replication after the upgrade, before the repository version has been set? But after that it should be OK, right?

Maybe that's an acceptable cost as long as it's documented - unless you would rather be more lenient with clearing it now at the expense of being a bit less idempotent? I guess we would then need to deal with the possibility that repository might be set later on, and clear it when setting the repository_version?

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.

Why don't we just remove the repository and publication fields from extra_data and then in the atomic update set both to None. This way we guarantee a smooth update and replication will always correctly update the distribution to the next repo-version even if the user was meddling with them.

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.

This approach is simpler and I think I prefer it, but it will still have a problem on the first replication, which is that the existing replicated repos which have repository set will still not have them cleared until the end. Therefore, the first replication post-upgrade would likely have the old non-atomic behavior.

Honestly that is still better than 404s though.

@dralley dralley force-pushed the atomic-replication branch 3 times, most recently from 11ca478 to 7c33cd5 Compare April 1, 2026 18:29
gerrod3
gerrod3 previously approved these changes Apr 1, 2026
Copy link
Copy Markdown
Contributor

@gerrod3 gerrod3 left a comment

Choose a reason for hiding this comment

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

Thanks for all the changes, looks good.

Comment on lines -176 to -177
"repository": get_url(repository),
"publication": None,
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.

Yay for simplicity!

@dralley dralley force-pushed the atomic-replication branch from 7c33cd5 to 8434df5 Compare April 1, 2026 19:39
Generated-By: claude-opus-4.6
@dralley dralley force-pushed the atomic-replication branch from 8434df5 to 9e2158e Compare April 1, 2026 19:41
@dralley dralley enabled auto-merge (rebase) April 1, 2026 19:44
@dralley dralley merged commit 7a4fb51 into pulp:main Apr 1, 2026
13 of 14 checks passed
@dralley dralley deleted the atomic-replication branch April 1, 2026 20:13
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.

Distribution updates during replication should be atomic

2 participants