Skip to content

Commit eda2ed5

Browse files
authored
Merge pull request #29 from ATIX-AG/optimize_sync
Add --optimize/--no-optimize option for syncs
2 parents ed62015 + aab087a commit eda2ed5

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

CHANGES/31.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Added support for the new --optimize/--no-optimize sync option.

pulpcore/cli/deb/repository.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
label_select_option,
1919
list_command,
2020
name_option,
21+
pulp_option,
2122
repository_href_option,
2223
repository_option,
2324
resource_option,
@@ -97,11 +98,22 @@ def repository(ctx: click.Context, pulp_ctx: PulpContext, repo_type: str) -> Non
9798
"during sync. When disabled, the sync is purely additive."
9899
),
99100
)
101+
@pulp_option(
102+
"--optimize/--no-optimize",
103+
default=None,
104+
help=(
105+
"Using optimize sync, will skip the processing of metadata if the checksum has not changed "
106+
"since the last sync. This greately improves re-sync performance in such cases. Disable if "
107+
"the sync result does not match expectations."
108+
),
109+
needs_plugins=[PluginRequirement("deb", min="2.20.0.dev")],
110+
)
100111
@pass_repository_context
101112
def sync(
102113
repository_ctx: PulpRepositoryContext,
103114
remote: EntityFieldDefinition,
104115
mirror: Optional[bool],
116+
optimize: Optional[bool],
105117
) -> None:
106118
repository = repository_ctx.entity
107119
repository_href = repository_ctx.pulp_href
@@ -111,6 +123,9 @@ def sync(
111123
if mirror is not None:
112124
body["mirror"] = mirror
113125

126+
if optimize is not None:
127+
body["optimize"] = optimize
128+
114129
if isinstance(remote, PulpEntityContext):
115130
body["remote"] = remote.pulp_href
116131
elif repository["remote"] is None:

tests/scripts/pulp_deb/test_deb_sync_publish.sh

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,22 @@ expect_succ pulp deb remote create \
2525
--distribution "$DEB_DISTRIBUTION"
2626

2727
expect_succ pulp deb repository create \
28-
--name "${ENTITIES_NAME}_repo"
29-
30-
expect_succ pulp deb repository sync \
3128
--name "${ENTITIES_NAME}_repo" \
3229
--remote "${ENTITIES_NAME}_remote"
3330

31+
expect_succ pulp deb repository sync \
32+
--name "${ENTITIES_NAME}_repo"
33+
34+
if pulp debug has-plugin --name deb --min-version 2.20.0.dev; then
35+
expect_succ pulp deb repository sync \
36+
--name "${ENTITIES_NAME}_repo" \
37+
--optimize
38+
39+
expect_succ pulp deb repository sync \
40+
--name "${ENTITIES_NAME}_repo" \
41+
--no-optimize
42+
fi
43+
3444
expect_succ pulp deb publication create \
3545
--repository "${ENTITIES_NAME}_repo" \
3646
--simple "True"

0 commit comments

Comments
 (0)