]> git.apps.os.sepia.ceph.com Git - ceph-build.git/commitdiff
Standardize on "label" name for parameter 2157/head
authorDan Mick <dmick@redhat.com>
Wed, 9 Aug 2023 02:05:25 +0000 (19:05 -0700)
committerDan Mick <dmick@redhat.com>
Wed, 9 Aug 2023 22:25:54 +0000 (15:25 -0700)
The Jenkins UI (or at least the Python binding) uses "label", not
"labels" (for reconfig only, because it uses XML, and the XML contains
the tag 'label'.  Sadly that's not true for create.)

Avoid the confusion that wasted my time.

Signed-off-by: Dan Mick <dmick@redhat.com>
ansible/examples/builder.yml
ansible/library/jenkins_node

index b6a7019b70d85a1857b07b8a7ff019b5f4a2cc77..a1e099e9248f9352b01c03aad12097e24ec650b2 100644 (file)
@@ -17,7 +17,7 @@
     - api_uri: 'https://jenkins.ceph.com'
     - jenkins_credentials_uuid: 'jenkins-build'
     - nodename: '{{ nodename }}'
-    - labels: "{{ jenkins_labels[inventory_hostname] }}"
+    - label: "{{ jenkins_labels[inventory_hostname] }}"
     - grant_sudo: true
     - osc_user: 'username'
     - osc_pass: 'password'
         # mapping from Jenkins back to whatever service created the current
         # node
         name: "{{ ansible_default_ipv4.address }}+{{ nodename }}"
-        labels: "{{ labels | default('') }}"
+        label: "{{ label | default('') }}"
         host: "{{ ansible_default_ipv4.address }}"
         credentialsId: "{{ jenkins_credentials_uuid }}"
         remoteFS: '/home/{{ jenkins_user }}/build'
             # mapping from Jenkins back to whatever service created the current
             # node
             name: "{{ ansible_default_ipv4.address }}+{{ ansible_hostname }}"
-            labels: "{{ labels }}"
+            label: "{{ label }}"
             host: "{{ ansible_default_ipv4.address }}"
             credentialsId: "{{ jenkins_credentials_uuid }}"
             launcher: 'hudson.slaves.JNLPLauncher'
index e20c9d2ce7004c729ee3090e094f411ad1963000..5a3a84016cec8f518f1252b97fb245252213ec54 100644 (file)
@@ -48,9 +48,9 @@ options:
     required: false
     default: null
 
-  labels:
+  label:
     description:
-      - Labels to associate with a node, like "amd64" or "python"
+      - List of labels in a string, space-separated, to associate with a node, like "amd64" or "python"
     required: false
     default: null
 
@@ -144,9 +144,6 @@ def maybe_convert_string_to_list(v):
 
 def sanitize_update_params(kw):
 
-    def translate_labels(labels):
-        return 'label', ' '.join(labels)
-
     # this list may be smaller than it needs to be, but these are
     # the only ones I want to support for now
     VALID_UPDATE_PARAMS = {
@@ -154,12 +151,11 @@ def sanitize_update_params(kw):
         'name': None,
         'remoteFS': None,
         'numExecutors': None,
-        'labels': translate_labels,
+        'label': None,
     }
     update_kws = dict()
     invalid = list()
     for k, v in kw.items():
-        v = maybe_convert_string_to_list(v)
         if k not in VALID_UPDATE_PARAMS:
             invalid.append(k)
         else:
@@ -191,6 +187,9 @@ def create_or_modify(uri, user, password, name, **kw):
 
         j.reconfig_node(name, new_xconfig)
     else:
+        if 'label' in params:
+            params['labels'] = params['label']
+            params.pop('label')
         j.create_node(name, launcher_params=launcher_params, **params)
         if not j.node_exists(name):
             return False, "Failed to create node '%s'." % name
@@ -234,7 +233,7 @@ def main():
             name=dict(required=True),
             executors=dict(required=False, default=2),
             description=dict(required=False, default=None),
-            labels=dict(required=False, default=None),
+            label=dict(required=False, default=None),
             host=dict(required=False, default=None),
             credentialsId=dict(required=False, default=None),
             launcher=dict(required=False, default='hudson.plugins.sshslaves.SSHLauncher'),
@@ -254,7 +253,7 @@ def main():
     name = module.params['name']
     executors = module.params['executors']
     description = module.params.get('description')
-    labels = module.params.get('labels')
+    label = module.params.get('label')
     exclusive = module.params.get('exclusive', False)
     host = module.params.get('host')
     remoteFS = module.params.get('remoteFS')
@@ -284,7 +283,7 @@ def main():
             name,
             executors=executors,
             description=description,
-            labels=labels,
+            label=label,
             exclusive=exclusive,
             host=host,
             credentialsId=credentialsId,