Browse Source

Merge "Fix mismatching fixed vs unique container names" into stable/stein

tags/4.5.1
Zuul 1 month ago
parent
commit
0be2e7a9b2
4 changed files with 25 additions and 9 deletions
  1. 6
    4
      paunch/__init__.py
  2. 3
    1
      paunch/builder/base.py
  3. 6
    1
      paunch/builder/compose1.py
  4. 10
    3
      paunch/builder/podman.py

+ 6
- 4
paunch/__init__.py View File

@@ -187,13 +187,14 @@ def debug(config_id, container_name, action, config, managed_by, labels=None,
187 187
             log=log
188 188
         )
189 189
     if action == 'print-cmd':
190
+        uname = r.unique_container_name(container_name)
190 191
         cmd = [
191 192
             r.cont_cmd,
192 193
             'run',
193 194
             '--name',
194
-            r.unique_container_name(container_name)
195
+            uname
195 196
         ]
196
-        builder.container_run_args(cmd, container_name)
197
+        builder.container_run_args(cmd, container_name, uname)
197 198
 
198 199
         if '--health-cmd' in cmd:
199 200
             health_check_arg_index = cmd.index('--health-cmd') + 1
@@ -208,13 +209,14 @@ def debug(config_id, container_name, action, config, managed_by, labels=None,
208 209
 
209 210
         print(' '.join(cmd))
210 211
     elif action == 'run':
212
+        uname = r.unique_container_name(container_name)
211 213
         cmd = [
212 214
             r.cont_cmd,
213 215
             'run',
214 216
             '--name',
215
-            r.unique_container_name(container_name)
217
+            uname
216 218
         ]
217
-        if builder.container_run_args(cmd, container_name):
219
+        if builder.container_run_args(cmd, container_name, uname):
218 220
             return r.execute_interactive(cmd, log)
219 221
     elif action == 'dump-yaml':
220 222
         print(yaml.safe_dump(config, default_flow_style=False))

+ 3
- 1
paunch/builder/base.py View File

@@ -105,7 +105,9 @@ class BaseBuilder(object):
105 105
                 ]
106 106
                 self.label_arguments(cmd, container)
107 107
                 self.log.debug("Start container {}.".format(container))
108
-                validations_passed = self.container_run_args(cmd, container)
108
+                validations_passed = self.container_run_args(cmd,
109
+                                                             container,
110
+                                                             container_name)
109 111
             elif action == 'exec':
110 112
                 cmd = [self.runner.cont_cmd, 'exec']
111 113
                 validations_passed = self.cont_exec_args(cmd, container)

+ 6
- 1
paunch/builder/compose1.py View File

@@ -22,13 +22,18 @@ class ComposeV1Builder(base.BaseBuilder):
22 22
         super(ComposeV1Builder, self).__init__(config_id, config, runner,
23 23
                                                labels, log)
24 24
 
25
-    def container_run_args(self, cmd, container):
25
+    def container_run_args(self, cmd, container, delegate=None):
26 26
         """Prepare the run command args, from the container configuration.
27 27
 
28 28
         :param cmd: The list of command options to be modified
29 29
         :param container: A dict with container configurations
30
+        :delegate: A compatibility parameter for podman, does nothing here
30 31
         :returns: True if configuration is valid, otherwise False
31 32
         """
33
+        if delegate and container != delegate:
34
+            self.log.debug("Delegate {} of container {} has no special "
35
+                           "meanings for this context and will be "
36
+                           "ignored".format(delegate, container))
32 37
         cconfig = self.config[container]
33 38
         if cconfig.get('detach', True):
34 39
             cmd.append('--detach=true')

+ 10
- 3
paunch/builder/podman.py View File

@@ -23,17 +23,24 @@ class PodmanBuilder(base.BaseBuilder):
23 23
                                             labels, log, cont_log_path,
24 24
                                             healthcheck_disabled)
25 25
 
26
-    def container_run_args(self, cmd, container):
26
+    def container_run_args(self, cmd, container, delegate=None):
27 27
         """Prepare the run command args, from the container configuration.
28 28
 
29 29
         :param cmd: The list of command options to be modified
30 30
         :param container: A dict with container configurations
31
+        :param delegate: A predictable/unique name of the actual container
31 32
         :returns: True if configuration is valid, otherwise False
32 33
         """
34
+        if delegate and container != delegate:
35
+            self.log.debug("Container {} has a delegate "
36
+                           "{}".format(container, delegate))
37
+        if not delegate:
38
+            delegate = container
33 39
         cconfig = self.config[container]
34 40
 
35
-        # write out a pid file so we can restart the container via systemd
36
-        cmd.append('--conmon-pidfile=/var/run/{}.pid'.format(container))
41
+        # write out a pid file so we can restart the container delegate
42
+        # via systemd
43
+        cmd.append('--conmon-pidfile=/var/run/{}.pid'.format(delegate))
37 44
 
38 45
         if cconfig.get('detach', True):
39 46
             cmd.append('--detach=true')

Loading…
Cancel
Save