Skip to content

Commit 11f65c6

Browse files
keukoosfrickler
authored andcommitted
Add mechanism for patching files in containers
This patch adds a way to patch files in a Docker image built by Kolla. This is very useful for several reasons, specifically: - Custom modifications - The stable branch of some library has a fix but no pip package has been released - Eliminates the need to package your own pip packages - Eliminates the need to invent your own versioning to prevent upstream versioning - Eliminates the need to manage a pip server - In other words, it eliminates the need to get a wheel into the image and install it manually using any method not previously mentioned It is also highly desirable because, although Kolla can replace the source for a service with a custom URL for a tarball or its own Git repo, it cannot do this for dependencies pulled from pip. I would also like to point out that this is a feature with its own code path and works only if the user "inserts" a patch into the folder patches/docker-image/something.patch and creates an analogous series file for patch source code. Simply said, this code will never interfere with the upstream build process since this feature is not intended for use in upstream. It is rather meant for downstream users who know what they are doing. Now they just have an option to patch their images. Everything works on all layers of the Docker image and stores a report of applied patches which can then be seen in /etc. This mechanism is similar as debian patch quilt. Change-Id: I61d0790c5d4d070b7ea9e8c99c0a76ff5d22bf9d
1 parent 36c1267 commit 11f65c6

File tree

210 files changed

+610
-5
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

210 files changed

+610
-5
lines changed

doc/source/admin/image-building.rst

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,59 @@ To remove a package from that list, say ``locales``, one would do:
301301
An example of this is the Grafana plugins, which are mentioned in the next
302302
section.
303303

304+
Patching customization
305+
----------------------
306+
307+
Kolla provides functionality to apply patches to Docker images during the build
308+
process. This allows users to modify existing files or add new ones as part of
309+
the image creation.
310+
311+
You need to define a ``patches_path`` in the ``[DEFAULT]`` section of
312+
the ``/etc/kolla/kolla-build.conf`` file. This directory will be used to store
313+
patches for the images.
314+
315+
.. path etc/kolla/kolla-build.conf
316+
.. code-block:: ini
317+
318+
[DEFAULT]
319+
patches_path = /path/to/your/patches
320+
321+
Create a directory for each image you want to patch, following a directory
322+
structure similar to the Debian patch quilt format. Refer to
323+
`quilt documentation <https://linux.die.net/man/1/quilt>`_. for more details.
324+
325+
- ``<patches_path>/image_name/`` : The directory for the specific image.
326+
- ``<patches_path>/image_name/some-patch`` : Contains the patch content.
327+
- ``<patches_path>/image_name/another-patch`` : Contains the patch content.
328+
- ``<patches_path>/image_name/series`` : Lists the order in which the patches
329+
will be applied.
330+
331+
For example, if you want to patch the ``nova-api`` image, the structure would
332+
look like this:
333+
334+
.. code-block:: console
335+
336+
/path/to/your/patches/nova-api/some-patch
337+
/path/to/your/patches/nova-api/another-patch
338+
/path/to/your/patches/nova-api/series
339+
340+
The ``series`` file should list the patches in the order they should be
341+
applied:
342+
343+
.. code-block:: console
344+
345+
some-patch
346+
another-patch
347+
348+
When the images are built using ``kolla-build``, the patches defined in the
349+
``patches_path`` will automatically be applied to the corresponding images.
350+
351+
After the patches are applied, Kolla stores information about the applied
352+
patches in ``/etc/kolla/patched``. The patch files themselves are stored
353+
in the ``/patches`` directory within the image. This allows you to track
354+
which patches have been applied to each image for debugging or
355+
verification purposes.
356+
304357
Grafana plugins
305358
^^^^^^^^^^^^^^^
306359

docker/aodh/aodh-api/Dockerfile.j2

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,7 @@ LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build
1010
COPY extend_start.sh /usr/local/bin/kolla_aodh_extend_start
1111
RUN chmod 644 /usr/local/bin/kolla_aodh_extend_start
1212

13+
{{ macros.kolla_patch_sources() }}
14+
1315
{% block aodh_api_footer %}{% endblock %}
1416
{% block footer %}{% endblock %}

docker/aodh/aodh-base/Dockerfile.j2

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,6 @@ RUN ln -s aodh-base-source/* aodh \
3434
&& touch /usr/local/bin/kolla_aodh_extend_start \
3535
&& chmod 644 /usr/local/bin/kolla_extend_start /usr/local/bin/kolla_aodh_extend_start
3636

37+
{{ macros.kolla_patch_sources() }}
38+
3739
{% block aodh_base_footer %}{% endblock %}

docker/aodh/aodh-evaluator/Dockerfile.j2

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build
77

88
{% import "macros.j2" as macros with context %}
99

10+
{{ macros.kolla_patch_sources() }}
11+
1012
{% block aodh_evaluator_footer %}{% endblock %}
1113
{% block footer %}{% endblock %}
1214

docker/aodh/aodh-expirer/Dockerfile.j2

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build
77

88
{% import "macros.j2" as macros with context %}
99

10+
{{ macros.kolla_patch_sources() }}
11+
1012
{% block aodh_expirer_footer %}{% endblock %}
1113
{% block footer %}{% endblock %}
1214

docker/aodh/aodh-listener/Dockerfile.j2

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build
77

88
{% import "macros.j2" as macros with context %}
99

10+
{{ macros.kolla_patch_sources() }}
11+
1012
{% block aodh_listener_footer %}{% endblock %}
1113
{% block footer %}{% endblock %}
1214

docker/aodh/aodh-notifier/Dockerfile.j2

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build
77

88
{% import "macros.j2" as macros with context %}
99

10+
{{ macros.kolla_patch_sources() }}
11+
1012
{% block aodh_notifier_footer %}{% endblock %}
1113
{% block footer %}{% endblock %}
1214

docker/barbican/barbican-api/Dockerfile.j2

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ COPY extend_start.sh /usr/local/bin/kolla_barbican_extend_start
1111

1212
RUN chmod 644 /usr/local/bin/kolla_barbican_extend_start
1313

14+
{{ macros.kolla_patch_sources() }}
15+
1416
{% block barbican_api_footer %}{% endblock %}
1517
{% block footer %}{% endblock %}
1618

docker/barbican/barbican-base/Dockerfile.j2

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,6 @@ RUN ln -s barbican-base-source/* barbican \
3838
&& touch /usr/local/bin/kolla_barbican_extend_start \
3939
&& chmod 644 /usr/local/bin/kolla_extend_start /usr/local/bin/kolla_barbican_extend_start
4040

41+
{{ macros.kolla_patch_sources() }}
42+
4143
{% block barbican_base_footer %}{% endblock %}

docker/barbican/barbican-keystone-listener/Dockerfile.j2

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build
77

88
{% import "macros.j2" as macros with context %}
99

10+
{{ macros.kolla_patch_sources() }}
11+
1012
{% block barbican_keystone_listener_footer %}{% endblock %}
1113
{% block footer %}{% endblock %}
1214

0 commit comments

Comments
 (0)