aboutsummaryrefslogtreecommitdiff
path: root/docker/base/set_configs.py
AgeCommit message (Collapse)AuthorFilesLines
2026-05-05set_configs: Add support for creating directories and setting permsMichal Nasiadka1-0/+22
Change-Id: Id63c035fafaa68a9004c65161c5a3a3ad5544f02 Signed-off-by: Michal Nasiadka <mnasiadka@gmail.com>
2025-06-19Fix kolla-set-configs --check to detect state mismatchMichal Arbet1-0/+54
If a configuration file is tracked in the state file but no longer appears in config.json, it should either be restored or removed. This patch introduces a new exception StateMismatch and updates execute_config_check() to detect such cases. If any destination path is present in the defaults state but missing from config.json, we now raise StateMismatch. A dedicated unit test has been added to verify this behavior. Closes-Bug: #2114173 Signed-off-by: Michal Arbet <michal.arbet@ultimum.io> Change-Id: I6e0b4aaa5722990e3ac647578023f474db3d4381
2024-11-06Fix handling configs in base imageMichal Arbet1-0/+151
This commit restructures the handling of configuration files in set_configs.py, introducing functions for managing default configuration files first. Closes-Bug: #2060855 Change-Id: If91e0330dc149143c82d2183b8ddf6fa9f68d80e
2024-11-05Enhance logging format for better readabilityMichal Arbet1-1/+5
Added timestamp with milliseconds, log level, and custom date format to improve clarity and make logs more useful for debugging. Change-Id: Ice2d601eddb54bbb0e7e3be6f03ba6db58256c1f
2024-09-16Fix state checking via kolla_set_configsMichal Arbet1-0/+14
Kolla checks the status of its configurations using kolla_set_configs --check. However, this doesn't work for the command block in the config.json file. This means that if only the command value changes, but not the config_files block, which is common practice in Kolla-Ansible btw, the container will not report the changes. This is undesirable and important to fix, especially considering the planned rework of notifiers in Kolla-Ansible [1]. [1] https://review.opendev.org/c/openstack/kolla-ansible/+/773243/14 Closes-Bug: #2080861 Change-Id: I2a290da38ea34b05ce3da8fb8b39b6252bf2da47
2024-08-21Merge "Add exclude for permissions in kolla config.json file"Zuul1-2/+14
2024-08-21Add exclude for permissions in kolla config.json fileMinSun1-2/+14
When using recursive mode to set permissions for a directory as defined in kolla config.json, all the subdirectories and files will receive the same permissions. This change adds the option to exclude specific files or directories - either a name or a regular expression can be used. Closes-Bug: #1931294 Closes-Bug: #1972168 Co-Authored-By: Jakub Darmach <jakub@stackhpc.com> Change-Id: If2f39736e2af34cd91d0976051ff66f06e96ab42
2023-08-29Merge "Add comprehensive checks for container restarts"Zuul1-1/+3
2023-04-24Fix typo in set_configsDawud M1-1/+1
Change-Id: I62a62bf80a7d3c7708cb5e836dc81dd1364d5a40
2023-03-09Add comprehensive checks for container restartsDawud M1-1/+3
When adding a dashboard to grafana the containers aren't restarted when they should be. This is due to a bug in Kolla where the logic to determine whether or the container needs to be restarted fails in the case where the file does not exist in the container. This patch adds more comprehensive checks for container restarts in the set_configs.py file. This patch also adds a test to ensure that the functions work as expected. Closes-Bug: #1997984 Co-Authored-By: Will Szumski <will@stackhpc.com> Change-Id: I67f5f12700d7b55f26bff81e9b54559303da6d83
2022-08-29Fix CVE-2022-38060Radosław Piliszek1-17/+2
Closes-Bug: #1985784 Change-Id: I66476a2b396e2cbe41e68ac51f57aae1806b2ed8
2022-04-05Emit log when copying file/directory permissionsYamato Tanaka1-0/+1
Currently, kolla sets file permissions at _set_properties_from_file() method, but no logs are emitted here. This can make it difficult to investigate the cause of issues which are caused by setting permissions. This patch makes _set_properties_from_file() output a log. Closes-Bug: #1966825 Change-Id: I91116931aa30fd2c5e51ed1ac04663fcfa4a5f36
2022-01-28Ensure set_configs sets execute bit on directoriesJakub Darmach1-0/+10
While handling permissions for directories, set_configs.py configures them same as for files - i.e. 0640 set in config.json which works fine for file will cause any potential subdirectories to lack traverse permission. Check and permission change was added to handle_permissions function to add +x if +r is present for user, group, others. Change-Id: Ic6e3ae4ff40c6ce5a5c0646ed309a2938903f6c0
2021-02-10Make kolla_set_configs open files in binary modeRadosław Piliszek1-1/+1
This fixes comparisons when files are not Unicode-encoded. A relevant unit test is included. It can be used as a base for other _cmp_file method unit tests if the need arises. Change-Id: Ic638516eb92d24ad247a7866fd1b5e2ac0400388 Closes-Bug: #1913952
2020-08-28Fix kolla_set_configs --check with a directoryMark Goddard1-5/+6
There are several issues with kolla_set_configs --check: 1. We calculate the destination path incorrectly when comparing a file in a directory, due to passing arguments to os.path.relpath in the wrong order 2. For directories that have not changed, we also attempt to compare them as files, which fails when they are open()ed. 3. If the config JSON does not have a config_files key, it fails with a KeyError. The first two issues affect the fluentd container, which specifies directories as the source, without using a glob. The third affects OVN containers. This patch fixes these issues. Closes-Bug: #1890567 Change-Id: I8921befe51da4282121443849177a7ca5ebe8822
2020-04-15Remove support for CentOS 7Marcin Juszkiewicz1-1/+1
With the move to RHEL/CentOS 8 we no longer have Python 2 in our images so there is no need for checking which Python version (2.x or 3.x) is used inside of containers. We also no longer have to support yum as a value for distro_package_manager. Partially-Implements: blueprint centos-rhel-8 Change-Id: Ie45cf3465fedddbde7856961527421883ba3d5c9
2020-01-24Add error message when merge failsAlex Schultz1-1/+9
If the source cfg directory contains a path (e.g. /etc/pki/ca-trust/extracted/) which is also bind mounted into the container as read-only, when it attempts to merge the paths together the resulting exception doesn't really indicate what happened. Change-Id: I73bbfd31586012e1fd64d30f9ce1d7eb2256d210 Related-Bug: #1860607
2019-01-18Make set_config.py compatible with both Py2 and Py3Damien Ciabrini1-1/+1
When asserting the validity of config files, we currently use viewkeys(), which has been removed in Python3, so a kolla container cannot set the config with Python3 only. "Traceback (most recent call last):", " File \"/usr/local/bin/kolla_set_configs\", line 406, in main", " config = load_config()", " File \"/usr/local/bin/kolla_set_configs\", line 297, in load_config", " validate_config(config)", " File \"/usr/local/bin/kolla_set_configs\", line 238, in validate_config", " if not data.viewkeys() >= required_keys:", "AttributeError: 'dict' object has no attribute 'viewkeys'" Use keys() instead, which is compatible with both Python2 and Python3, and has no visible performance disadvantage and wrap it in a set() call so that we are guranteed to compare sets. Change-Id: I5f53c8f5a390a9df3ebb60659ebdcef41e3a9cad Co-Authored-By: Michele Baldessari <michele@acksyn.org>
2019-01-15Ensure /run_command is readable by all usersDamien Ciabrini1-1/+7
On some distro, running kolla_start via su changes the default UMASK, and consequently set_configs.py generates a /run_command that is not world-readable, and kolla cannot start the configured service. Make sure /run_command always has 'go+r' permissions. Change-Id: I6304f5937c512068ee1fb8aac5c88a2bd086e387
2017-07-17Only copy symlinks when merge and preserve_properties are setMartin André1-1/+1
The kolla-kubernetes config files live in a ..data directory in the config volume and are symlinked with relative path at the root of the config volume. This naturally breaks with the link copy feature introduce in I92a404b8d301937dc1847d42576e30db43951990. This commit restores the original behavior to copy the target of the link unless both 'merge' and 'preserve_properties' options are set, in which case the link itself is copied. Change-Id: I5d768687208205fb50ef5ab93675f47e98ea6351
2017-07-06Make set_configs.py work with symlinksMartin André1-4/+8
Closes-Bug: #1702305 Change-Id: I92a404b8d301937dc1847d42576e30db43951990
2017-07-04Merge "Improve logging of set_configs.py"Jenkins1-8/+9
2017-07-03Improve logging of set_configs.pyMartin André1-8/+9
Remove duplicate logging for file copying, and clarify some log messages. Change-Id: I4dfaffa62f79a32a7fd6060b92ccb119f657f854
2017-07-02Fix argument to handle_permissionsChulmin Kang1-2/+3
Fix the format of argument passed to handle_permissions function, so that handle_permissions can handle permissions and ownerships of config_files. Change-Id: Ic07975a16973df22cdaa6685fc326620812f8f65 Closes-Bug: #1701876
2017-06-27Introduce merge and preserve_properties for config_filesMartin André1-21/+45
The `merge` option will basically copy all the files recursively inside the container without removing the existing files or directory, while the `preserve_properties` option keeps the file attributes (permissions, ownership, timestamps) in the container. This is useful if you have extracted some config files from a container and want to use them in another container based on the same image. This makes TripleO usage of Kolla much more robust. Change-Id: I78dcec741a941dc21adba33ba33a6dc6ff1d217c
2017-06-21Allow setting copied files group more preciselyMartin André1-26/+22
Previously with the config_files structure of config.json, the group name was automatically set to the one of the user name. It is now possible to set the group name in the same fashion than the 'permissions' structure with: owner: 'desired_owner:desired_group' Closes-Bug: #1696095 Change-Id: Ibae9f74e2351c81a717294467aedc51ea773c41e
2017-06-21Delete unused set_permissions functionMartin André1-40/+0
Change-Id: If6b4a76cf36c639e80a749ec9c938d06435eda51
2017-06-21In set_configs.py support perm parameter in permissions sectionChristian Berendt1-5/+17
This allows to set permissions for configuration files. TrivialFix Change-Id: Ida2ed62eaba8908fb0bd50bb0be00fb5f9b1adc3
2017-05-09Catch exception during calling os.chmod in set_configs.pyJeffrey Zhang1-1/+7
set_perms may fail in some case, but it is not critical. Just leave a warning rather than exit. Change-Id: I757c7b60611fb6c0547bd1b26ec8a8af03684e5f Closes-Bug: 1689454
2017-03-30Optimize the codezhuzeyu1-20/+19
Keeping function code together can make the structure clear Change-Id: Ia16b43b902543bc57869579acba2f6b3d5f2ca54
2017-01-18Fix the set config errorJeffrey Zhang1-101/+169
* fix wrong handle for directory * refactor the code Closes-Bug: #1563741 Change-Id: I83869e074cb2924f1c5b49a67e57aefef623a8b0
2017-01-11Fix string formatting on error logFlavio Percoco1-1/+1
The missing parenthesys caused a string formatting error, which hides the actual failure when running the container. Change-Id: Ieebf4abd536ccfceeba645c52b109b00faf4ee57
2016-12-11Fix some typopangliye1-1/+1
Co-Authored-By: caoyuan <cao.yuan@99cloud.net> TrivialFix Change-Id: Ie576114a3f6f4579a4df3175232a5f6c63c7a795
2016-12-01Consistently use a exception vs sys.exitJoshua Harlow1-38/+79
This also makes it so that the config check accumulates errors instead of bailing out immediatly (using a sys.exit) which seems nicer than blowing up on the first error. Change-Id: I915ef5a018969eee87ac1ab3ddc88fc1b89a3448
2016-11-15Allow for specifying a KOLLA_CONFIG_FILEJoshua Harlow1-1/+3
Incases where it is useful to place many config.json files under the same directory (ie one for config_glance_api.json or one for config_glance_registry.json) we should be able to specify which file under that directory do we actually want to use (instead of assuming it is always config.json). Change-Id: I42eeb093d29bac27d71ee08e55e115c2d8b5e9ae
2016-10-14move sys.exit out of try finally block in set_config.py fileJeffrey Zhang1-2/+1
when code exit by using sys.exit in try..catch block, it will skip catch and run the code in finally. Because SystemExit does not inherit from Exception. This patch moves sys.exit out of finally block. Then it won't execute when script exits by sys.exit Change-Id: I6457b1b861d2f9fdadce788ac6b719f46c7f2af3 Partial-Bug: #1631503
2016-10-13Fix rabbitmq upgrade permission issueJeffrey Zhang1-3/+47
During the upgrade from Mitaka to Newton, the uid/gid may change for the same image. Especially on Ubuntu, we moved to Ubuntu Xenial in Newton and it added systemd related user which break all the uid/gid during an upgrade. It will the permissions in all docker named volumes. This fix extends set_config.py to set the proper permission during container start. This is super light then add commands in extend_start.sh file or add ansible tasks. This patch just fixes rabbitmq case. Other services will be fixed in following patches. Partial-Bug: #1631503 Change-Id: Ib17027b97abbc9bf4e3cd503601b8010325b5c5b
2016-07-14External Ceph support - Implementation GlanceMathias Ewald1-11/+13
Most simple implementation of external ceph support. We use INI merge to configure RBD backend for Glance and copy ceph.conf and keyring provided by the user into the container. Set_configs.py had to be extended to support globbing (wildcards) in order to copy ceph keyring file which is named depending on the cephx user name. Partially-Implements Blueprint: external-ceph Partially-Implements Blueprint: selectable-ceph Change-Id: Iacadbd8ec9956e9f075206ea03b28f044cb6ffb8
2016-05-02Remove dependencies on kazoo and friendsSteven Dake1-70/+1
Since kolla-mesos has been retired, there is no need in the code base to keep the zookeeper implementation. As a result, just remove it. If we were to keep it we need virtualenvs for that part of the code base which installs the python dependencies related to it for from-binary installs. This just simplifies the implementation tremendously and culls dead code. Change-Id: Ieda226e652d67f5b5667112f4f2556f3171366d3 Closes-Bug: #1577194
2016-03-19Fix 'optional' config.json valuesSamYaple1-1/+1
These values are optional only when the services are not enabled. If the file does not exist we should not warn, but rather inform. Ceph-mon is an exception here since its bootstrap process means the files may or may not exist initially. TrivialFix Change-Id: Ic02bece76d480e99deecf612036f37abb5604135
2016-03-02Reconfigure cinder serviceJeffrey Zhang1-2/+8
Change-Id: I8d207d1782acfebf5c07de39df3257fd9bdbbada Partially-implements: bp kolla-reconfig
2016-02-27Reconfigure keystone serviceJeffrey Zhang1-3/+50
Partially-implements: bp kolla-reconfig Change-Id: Ied293e59bf4531e88a0e5e5bf9a5f5f495d2a0e7
2016-02-25Import module rather than funciton in the set_configs.py fileJeffrey Zhang1-2/+2
TrivialFix Change-Id: I352ef1176407edf093667644ce6adbd48eb63865
2016-02-02Fix wrong behavior when the source is a directoryAntoine Roux1-1/+1
TrivialFix Change-Id: Ie723fb35f15be0a500b428b2b58e6b4c5321df0c
2015-12-31Merge "Python 3 deprecated the logger.warn method in favor of warning"Jenkins1-1/+1
2015-12-30Make the logging more safeJeffrey Zhang1-1/+2
TrivialFix Change-Id: I72c541c1846e503486b402e88d5b29364920fc83
2015-12-29Python 3 deprecated the logger.warn method in favor of warningWanlong Gao1-1/+1
Python 3 deprecated the logger.warn method, see: https://docs.python.org/3/library/logging.html#logging.warning, so we prefer to use warning to avoid DeprecationWarning. Change-Id: Ic4e07276def17ef39764601c8a7e0991f9a4efbc Closes-Bug: 1508442
2015-12-22Merge "Use c-style string interpolation for log messages"Jenkins1-21/+18
2015-12-18Merge "Simplify logic of set_configs.py a little bit"Jenkins1-24/+9
2015-12-18Use c-style string interpolation for log messagesMartin André1-21/+18
TrivialFix Change-Id: I7ddebc7b6f71e50254801324fa2bf093fdaa8ce0