summaryrefslogtreecommitdiff
path: root/docker/base/set_configs.py
AgeCommit message (Collapse)AuthorFilesLines
2020-09-14Fix 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 (cherry picked from commit c5320eb22386c34d83435fa0b9aa03b178996b52)
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
2015-12-18Merge "Create empty file by using os.mknod"Jenkins1-2/+1
2015-12-18Simplify logic of set_configs.py a little bitMartin André1-24/+9
TrivialFix Change-Id: Ic1c9fc76f4a5725ee76460c727197a96fe5d5359
2015-12-18Create empty file by using os.mknodJeffrey Zhang1-2/+1
it is more safe and pythonic. Change-Id: I728649af37cee8d1e255bb0a389cbc532e551c74
2015-12-18Remove wrong comment descriptionJeffrey Zhang1-3/+1
Base on the code logic, all the source, dest, owner and perm field is required. Change-Id: Iba5b4b2c2bd3ca0b97a3c29655e87c9701a84350
2015-12-07Add Python 3.x support in set_configs.pyMichal Rostecki1-4/+4
Change-Id: I348c69e5411135da8434e9278a48a5777ff2a72d Partially-Implements: blueprint python3
2015-12-02Add support for copying files from a "zk://" sourceAngus Salkeld1-1/+77
Co-Authored-By: Michal Rostecki <mrostecki@mirantis.com> Implements: blueprint zookeeper Change-Id: I176f063d3802716846b921e210c1569d28bd90d8
2015-11-17Add support for loading kolla config from ENVAngus Salkeld1-10/+27
Implements: blueprint zookeeper Change-Id: Ibabcb5d6d304be9290633338c513f16651d4479a
2015-10-06Bring Kolla inline with FHSSam Yaple1-1/+1
This brings Kolla images inline with FHS and should make finding locations of things more consistent and reliable with the linux world at large. Change-Id: Iece5b4da4bace0fb8b1f41a65ab2c852ec73e6f8 Closes-Bug: #1485742
2015-09-29Fix ceph after config-external removalSam Yaple1-3/+5
Change-Id: I46dc2f02dda8219878eee3755b0891f4c3450682 Partially-Implements: blueprint replace-config-external
2015-09-28Allow conf files to be optionalSam Yaple1-6/+17
There are situations where we need to copy-if-exists mainly in cluster setups. This is needed to replace config-external for ceph right now Change-Id: I3c0898d8c584338a38e6ce4c4146e145910c5a52 Partially-Implements: blueprint replace-config-external
2015-09-17Refactor set_configs.pySam Yaple1-144/+119
This refactor brings the logging in line with the rest of Kolla. The fucntion names were updated to reflect thier new role. Additionally, it fixes several issues with the permissions which currently break all containers that use set_configs.py It will also work with source being a directory or a file now. Change-Id: I4a197a343e3baf3bd31532debdff5972adb8aefa Partially-Implements: blueprint replace-config-external
2015-09-15Replace config-external with a JSON filerthallisey1-0/+218
Replace config-external with JSON file. The JSON file will be placed in each of the services directories with expected location and destination. Set-configs.py will be responsible for interpreting the JSON file, creating the necessary directories, moving config files, and and providing a command line for start.sh to run the service with the correct config files specified. Partially-Implements: blueprint replace-config-external Change-Id: I5e2e69dfe3ae7f938fcf51f1cd450aaa10e7f1e3