Skip to content

Commit ad4d0ac

Browse files
authored
Merge pull request #313 from gerrod3/default_ondemand
Sync default policy is on_demand.
2 parents 89f9b94 + 3834110 commit ad4d0ac

File tree

6 files changed

+49
-32
lines changed

6 files changed

+49
-32
lines changed

CHANGES/7401.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Change the default download policy to 'on_demand', as bulk syncs of PyPI would use several terabytes of disk space.

docs/_scripts/remote.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
http POST $BASE_ADDR/pulp/api/v3/remotes/python/python/ \
33
name='bar' \
44
url='https://pypi.org/' \
5-
includes:='[{"name": "shelf-reader"}]'
5+
includes:='["shelf-reader"]'
66

77
# Export an environment variable for the new remote URI.
88
export REMOTE_HREF=$(http $BASE_ADDR/pulp/api/v3/remotes/python/python/ \

docs/workflows/sync.rst

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,25 @@ itself, a fixture, or even an instance of Pulp 2.
3838
Remote GET Response::
3939

4040
{
41-
"pulp_created": "2019-04-29T15:58:01.196433Z",
42-
"pulp_href": "/pulp/api/v3/remotes/python/python/1962b474-1545-4de1-adf4-4bf211679752/",
43-
"pulp_last_updated": "2019-04-29T15:58:01.196446Z",
44-
"download_concurrency": 20,
41+
"ca_cert": null,
42+
"client_cert": null,
43+
"client_key": null,
44+
"download_concurrency": 10,
4545
"excludes": [],
4646
"includes": [
47-
{
48-
"name": "shelf-reader",
49-
"version_specifier": ""
50-
}
47+
"shelf-reader"
5148
],
5249
"name": "bar",
53-
"policy": "immediate",
50+
"password": null,
51+
"policy": "on_demand",
5452
"prereleases": false,
55-
"proxy_url": "",
56-
"ssl_validation": true,
53+
"proxy_url": null,
54+
"pulp_created": "2020-10-15T22:08:07.943369Z",
55+
"pulp_href": "/pulp/api/v3/remotes/python/python/bbcfa980-ea53-425c-b03b-17c9c2867bba/",
56+
"pulp_last_updated": "2020-10-15T22:08:07.943404Z",
57+
"tls_validation": true,
5758
"url": "https://pypi.org/",
58-
"validate": true
59+
"username": null
5960
}
6061

6162
Reference: `Python Remote Usage <../restapi.html#tag/remotes>`_
@@ -71,13 +72,10 @@ about will be synced::
7172
name='complex-remote' \
7273
url='https://pypi.org/' \
7374
includes:='[
74-
{ "name": "django",
75-
"version_specifier": "~=2.0,!=2.0.1",
76-
},
77-
{"name": "pip-tools",
78-
"version_specifier": ">=1.12,<=2.0"},
79-
{"name": "scipy"},
80-
{"name": "shelf-reader"}
75+
"django~=2.0,!=2.0.1",
76+
"pip-tools>=1.12,<=2.0",
77+
"scipy",
78+
"shelf-reader"
8179
]'
8280

8381
You can also use version specifiers to "exclude" certain versions of a project, like so::
@@ -86,16 +84,34 @@ You can also use version specifiers to "exclude" certain versions of a project,
8684
name='complex-remote' \
8785
url='https://pypi.org/' \
8886
includes:='[
89-
{"name": "django", "version_specifier": ""},
90-
{"name": "scipy", "version_specifier": ""}
87+
"django",
88+
"scipy"
9189
]' \
9290
excludes:='[
93-
{"name": "django", "version_specifier": "~=1.0"},
94-
{"name": "scipy"}
91+
"django~=1.0",
92+
"scipy"
9593
]'
9694

9795
Reference: `Python Remote Usage <../restapi.html#tag/remotes>`_
9896

97+
Creating a remote to sync all of PyPi
98+
_____________________________________
99+
100+
A remote can be setup to sync all of PyPi by not specifying any included packages like so::
101+
102+
$ http POST $BASE_ADDR/pulp/api/v3/remotes/python/python/ \
103+
name='PyPi-mirror' \
104+
url='https://pypi.org/' \
105+
excludes:='[
106+
"django~=1.0",
107+
"scipy"
108+
]'
109+
110+
By not setting the "includes" field Pulp will ask PyPi for all of its available packages to sync, minus the ones from
111+
the excludes field. Default Python remotes are created with syncing policy "on_demand" because the most common
112+
Python remotes involve syncing with PyPi which requires terabytes of disk space. This can be changed by
113+
modifying the "policy" field.
114+
99115
Sync repository foo with remote
100116
-------------------------------
101117

pulp_python/app/serializers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ class PythonRemoteSerializer(core_serializers.RemoteSerializer):
265265
help_text=_("The policy to use when downloading content. The possible values include: "
266266
"'immediate', 'on_demand', and 'cache_only'. 'immediate' is the default."),
267267
choices=core_models.Remote.POLICY_CHOICES,
268-
default=core_models.Remote.IMMEDIATE
268+
default=core_models.Remote.ON_DEMAND
269269
)
270270

271271
def validate_includes(self, value):
@@ -316,7 +316,7 @@ class PythonBanderRemoteSerializer(serializers.Serializer):
316316
help_text=_("The policy to use when downloading content. The possible values include: "
317317
"'immediate', 'on_demand', and 'cache_only'. 'immediate' is the default."),
318318
choices=core_models.Remote.POLICY_CHOICES,
319-
default=core_models.Remote.IMMEDIATE
319+
default=core_models.Remote.ON_DEMAND
320320
)
321321

322322

pulp_python/tests/functional/api/test_crud_remotes.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -208,23 +208,23 @@ def tearDownClass(cls):
208208
cls.remote_api.delete(result["pulp_href"])
209209

210210
def test_01_no_defined_policy(self):
211-
"""Verify the default policy `immediate`.
211+
"""Verify the default policy `on_demand`.
212212
213-
When no policy is defined, the default policy of `immediate`
213+
When no policy is defined, the default policy of `on_demand`
214214
is applied.
215215
"""
216216
del self.body["policy"]
217217
self.remote.update(self.remote_api.create(self.body).to_dict())
218-
self.assertEqual(self.remote["policy"], "immediate", self.remote)
218+
self.assertEqual(self.remote["policy"], "on_demand", self.remote)
219219

220220
@skip_if(len, "policies", 1)
221221
def test_02_change_policy(self):
222222
"""Verify ability to change policy to value other than the default.
223223
224-
Update the remote policy to a valid value other than `immedaite`
224+
Update the remote policy to a valid value other than `on_demand`
225225
and verify the new set value.
226226
"""
227-
changed_policy = choice([item for item in self.policies if item != "immediate"])
227+
changed_policy = choice([item for item in self.policies if item != "on_demand"])
228228
response = self.remote_api.partial_update(
229229
self.remote["pulp_href"], {"policy": changed_policy}
230230
)

pulp_python/tests/functional/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@
212212
DEFAULT_BANDER_REMOTE_BODY = {
213213
"url": "https://pypi.org",
214214
"download_concurrency": 3,
215-
"policy": "immediate",
215+
"policy": "on_demand",
216216
"prereleases": False,
217217
"excludes": ["example1", "example2"]
218218
}

0 commit comments

Comments
 (0)