Skip to content

Commit

Permalink
Merge pull request #6040 from Iamshankhadeep/adding_rtd_prefix
Browse files Browse the repository at this point in the history
Adding RTD prefix for docker only in setting.py and all other places where is needed
  • Loading branch information
humitos authored Oct 10, 2019
2 parents af4ef4f + d06adf9 commit 6f3a980
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 43 deletions.
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
10 changes: 5 additions & 5 deletions docs/development/buildenvironments.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ There are several settings used to configure usage of virtual machines:
DOCKER_ENABLE
True/False value used to enable the Docker build environment.

Default: :djangosetting:`DOCKER_ENABLE`
Default: :djangosetting:`RTD_DOCKER_ENABLE`

DOCKER_LIMITS
A dictionary of limits to virtual machines. These limits include:
Expand All @@ -65,23 +65,23 @@ DOCKER_LIMITS
Examples: '200m' for 200MB of total memory, or '2g' for 2GB of
total memory.

Default: :djangosetting:`DOCKER_LIMITS`
Default: :djangosetting:`RTD_DOCKER_LIMITS`

DOCKER_IMAGE
Tag of a Docker image to use as a base image.

Default: :djangosetting:`DOCKER_IMAGE`
Default: :djangosetting:`RTD_DOCKER_IMAGE`

DOCKER_SOCKET
URI of the socket to connect to the Docker daemon. Examples include:
``unix:///var/run/docker.sock`` and ``tcp://127.0.0.1:2375``.

Default: :djangosetting:`DOCKER_SOCKET`
Default: :djangosetting:`RTD_DOCKER_SOCKET`

DOCKER_VERSION
Version of the API to use for the Docker API client.

Default: :djangosetting:`DOCKER_VERSION`
Default: :djangosetting:`RTD_DOCKER_VERSION`


Local development
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
24 changes: 12 additions & 12 deletions readthedocs/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,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 @@ -273,7 +273,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 @@ -286,15 +286,15 @@ def get_valid_python_versions_for_image(self, build_image):
The Docker image (``build_image``) has to be its complete name, already
validated: ``readthedocs/build:4.0``, not just ``4.0``.
Returns supported versions for the ``DOCKER_DEFAULT_VERSION`` if not
Returns supported versions for the ``RTD_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 @@ -331,7 +331,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 @@ -386,7 +386,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 @@ -400,12 +400,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 @@ -707,7 +707,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/doc_builder/environments.py
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ class DockerBuildEnvironment(BuildEnvironment):
"""
Docker build environment, uses docker to contain builds.
If :py:data:`settings.DOCKER_ENABLE` is true, build documentation inside a
If :py:data:`settings.RTD_DOCKER_ENABLE` is true, build documentation inside a
docker container, instead of the host system, using this build environment
class. The build command creates a docker container from a pre-built image,
defined by :py:data:`settings.DOCKER_IMAGE`. This container is started with
Expand Down
2 changes: 1 addition & 1 deletion readthedocs/projects/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,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
4 changes: 2 additions & 2 deletions readthedocs/projects/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ def run(
:param commit: commit sha of the version required for sending build status reports
:param record bool: record a build object in the database
:param docker bool: use docker to build the project (if ``None``,
``settings.DOCKER_ENABLE`` is used)
``settings.RTD_DOCKER_ENABLE`` is used)
:param force bool: force Sphinx build
:returns: whether build was successful or not
Expand All @@ -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 @@ -342,16 +342,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 @@ -370,9 +370,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
2 changes: 1 addition & 1 deletion readthedocs/settings/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def MIDDLEWARE(self):
DOCKER_IMAGE_SETTINGS = {
key.replace('readthedocs/build:', 'readthedocs/build-dev:'): settings
for (key, settings)
in DOCKER_IMAGE_SETTINGS.items()
in RTD_DOCKER_IMAGE_SETTINGS.items()
}
except NameError:
pass

0 comments on commit 6f3a980

Please sign in to comment.