Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding RTD prefix for docker only in setting.py and all other places where is needed #6040

Merged
merged 4 commits into from
Oct 10, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/config-file/v1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ The ``build`` block configures specific aspects of the documentation build.
build.image
```````````

* Default: :djangosetting:`DOCKER_DEFAULT_VERSION`
* Default: :djangosetting:`RTD_DOCKER_DEFAULT_VERSION`
* Options: ``stable``, ``latest``

The build image to use for specific builds.
Expand Down
4 changes: 2 additions & 2 deletions docs/doc_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ def django_setting_role(typ, rawtext, text, lineno, inliner, options=None,
def python_supported_versions_role(typ, rawtext, text, lineno, inliner,
options=None, content=None):
"""Up to date supported python versions for each build image."""
image = '{}:{}'.format(settings.DOCKER_DEFAULT_IMAGE, text)
image_settings = settings.DOCKER_IMAGE_SETTINGS[image]
image = '{}:{}'.format(settings.RTD_DOCKER_DEFAULT_IMAGE, text)
image_settings = settings.RTD_DOCKER_IMAGE_SETTINGS[image]
python_versions = image_settings['python']['supported_versions']
node_list = []
separator = ', '
Expand Down
22 changes: 11 additions & 11 deletions readthedocs/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class BuildConfigBase:
'submodules',
]

default_build_image = settings.DOCKER_DEFAULT_VERSION
default_build_image = settings.RTD_DOCKER_DEFAULT_VERSION

version = None

Expand Down Expand Up @@ -266,7 +266,7 @@ def valid_build_images(self):
``readthedocs/build`` part) plus ``stable`` and ``latest``.
"""
images = {'stable', 'latest'}
for k in settings.DOCKER_IMAGE_SETTINGS:
for k in settings.RTD_DOCKER_IMAGE_SETTINGS:
_, version = k.split(':')
if re.fullmatch(r'^[\d\.]+$', version):
images.add(version)
Expand All @@ -282,12 +282,12 @@ def get_valid_python_versions_for_image(self, build_image):
Returns supported versions for the ``DOCKER_DEFAULT_VERSION`` if not
``build_image`` found.
"""
if build_image not in settings.DOCKER_IMAGE_SETTINGS:
if build_image not in settings.RTD_DOCKER_IMAGE_SETTINGS:
build_image = '{}:{}'.format(
settings.DOCKER_DEFAULT_IMAGE,
settings.RTD_DOCKER_DEFAULT_IMAGE,
self.default_build_image,
)
return settings.DOCKER_IMAGE_SETTINGS[build_image]['python']['supported_versions']
return settings.RTD_DOCKER_IMAGE_SETTINGS[build_image]['python']['supported_versions']

def as_dict(self):
config = {}
Expand Down Expand Up @@ -324,7 +324,7 @@ def get_valid_python_versions(self):
return self.env_config['python']['supported_versions']
except (KeyError, TypeError):
versions = set()
for _, options in settings.DOCKER_IMAGE_SETTINGS.items():
for _, options in settings.RTD_DOCKER_IMAGE_SETTINGS.items():
versions = versions.union(
options['python']['supported_versions']
)
Expand Down Expand Up @@ -379,7 +379,7 @@ def validate_build(self):
if 'build' in self.env_config:
build = self.env_config['build'].copy()
else:
build = {'image': settings.DOCKER_IMAGE}
build = {'image': settings.RTD_DOCKER_IMAGE}

# User specified
if 'build' in self.raw_config:
Expand All @@ -393,12 +393,12 @@ def validate_build(self):
if ':' not in build['image']:
# Prepend proper image name to user's image name
build['image'] = '{}:{}'.format(
settings.DOCKER_DEFAULT_IMAGE,
settings.RTD_DOCKER_DEFAULT_IMAGE,
build['image'],
)
# Update docker default settings from image name
if build['image'] in settings.DOCKER_IMAGE_SETTINGS:
self.env_config.update(settings.DOCKER_IMAGE_SETTINGS[build['image']])
if build['image'] in settings.RTD_DOCKER_IMAGE_SETTINGS:
self.env_config.update(settings.RTD_DOCKER_IMAGE_SETTINGS[build['image']])

# Allow to override specific project
config_image = self.defaults.get('build_image')
Expand Down Expand Up @@ -700,7 +700,7 @@ def validate_build(self):
with self.catch_validation_error('build.image'):
image = self.pop_config('build.image', self.default_build_image)
build['image'] = '{}:{}'.format(
settings.DOCKER_DEFAULT_IMAGE,
settings.RTD_DOCKER_DEFAULT_IMAGE,
validate_choice(
image,
self.valid_build_images,
Expand Down
12 changes: 6 additions & 6 deletions readthedocs/doc_builder/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@
PDF_RE = re.compile('Output written on (.*?)')

# Docker
DOCKER_SOCKET = settings.DOCKER_SOCKET
DOCKER_VERSION = settings.DOCKER_VERSION
DOCKER_IMAGE = settings.DOCKER_IMAGE
DOCKER_IMAGE_SETTINGS = settings.DOCKER_IMAGE_SETTINGS
DOCKER_SOCKET = settings.RTD_DOCKER_SOCKET
DOCKER_VERSION = settings.RTD_DOCKER_VERSION
DOCKER_IMAGE = settings.RTD_DOCKER_IMAGE
DOCKER_IMAGE_SETTINGS = settings.RTD_DOCKER_IMAGE_SETTINGS

old_config = settings.DOCKER_BUILD_IMAGES
old_config = settings.RTD_DOCKER_BUILD_IMAGES
if old_config:
log.warning(
'Old config detected, DOCKER_BUILD_IMAGES->DOCKER_IMAGE_SETTINGS',
)
DOCKER_IMAGE_SETTINGS.update(old_config)

DOCKER_LIMITS = {'memory': '200m', 'time': 600}
DOCKER_LIMITS.update(settings.DOCKER_LIMITS)
DOCKER_LIMITS.update(settings.RTD_DOCKER_LIMITS)

DOCKER_TIMEOUT_EXIT_CODE = 42
DOCKER_OOM_EXIT_CODE = 137
Expand Down
2 changes: 1 addition & 1 deletion readthedocs/projects/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@ def repo_nonblockinglock(self, version, max_lock_age=None):
if max_lock_age is None:
max_lock_age = (
self.container_time_limit or
settings.DOCKER_LIMITS.get('time') or
settings.RTD_DOCKER_LIMITS.get('time') or
settings.REPO_LOCK_SECONDS
)

Expand Down
2 changes: 1 addition & 1 deletion readthedocs/projects/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ def run(
"""
try:
if docker is None:
docker = settings.DOCKER_ENABLE
docker = settings.RTD_DOCKER_ENABLE
self.version = self.get_version(version_pk)
self.project = self.version.project
self.build = self.get_build(build_pk)
Expand Down
24 changes: 12 additions & 12 deletions readthedocs/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,16 +335,16 @@ def USE_PROMOS(self): # noqa
SENTRY_CELERY_IGNORE_EXPECTED = True

# Docker
DOCKER_ENABLE = False
DOCKER_SOCKET = 'unix:///var/run/docker.sock'
RTD_DOCKER_ENABLE = False
RTD_DOCKER_SOCKET = 'unix:///var/run/docker.sock'
# This settings has been deprecated in favor of DOCKER_IMAGE_SETTINGS
DOCKER_BUILD_IMAGES = None
DOCKER_LIMITS = {'memory': '200m', 'time': 600}
DOCKER_DEFAULT_IMAGE = 'readthedocs/build'
DOCKER_VERSION = 'auto'
DOCKER_DEFAULT_VERSION = 'latest'
DOCKER_IMAGE = '{}:{}'.format(DOCKER_DEFAULT_IMAGE, DOCKER_DEFAULT_VERSION)
DOCKER_IMAGE_SETTINGS = {
RTD_DOCKER_BUILD_IMAGES = None
RTD_DOCKER_LIMITS = {'memory': '200m', 'time': 600}
RTD_DOCKER_DEFAULT_IMAGE = 'readthedocs/build'
RTD_DOCKER_VERSION = 'auto'
RTD_DOCKER_DEFAULT_VERSION = 'latest'
RTD_DOCKER_IMAGE = '{}:{}'.format(RTD_DOCKER_DEFAULT_IMAGE, RTD_DOCKER_DEFAULT_VERSION)
RTD_DOCKER_IMAGE_SETTINGS = {
'readthedocs/build:1.0': {
'python': {'supported_versions': [2, 2.7, 3, 3.4]},
},
Expand All @@ -363,9 +363,9 @@ def USE_PROMOS(self): # noqa
}

# Alias tagged via ``docker tag`` on the build servers
DOCKER_IMAGE_SETTINGS.update({
'readthedocs/build:stable': DOCKER_IMAGE_SETTINGS.get('readthedocs/build:4.0'),
'readthedocs/build:latest': DOCKER_IMAGE_SETTINGS.get('readthedocs/build:5.0'),
RTD_DOCKER_IMAGE_SETTINGS.update({
'readthedocs/build:stable': RTD_DOCKER_IMAGE_SETTINGS.get('readthedocs/build:4.0'),
'readthedocs/build:latest': RTD_DOCKER_IMAGE_SETTINGS.get('readthedocs/build:5.0'),
})

# All auth
Expand Down