]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/tasks/openssl_keys.py: sort cert configs before creating certs
authorKefu Chai <kchai@redhat.com>
Wed, 8 Apr 2020 11:22:06 +0000 (19:22 +0800)
committerKefu Chai <kchai@redhat.com>
Wed, 3 Jun 2020 11:57:00 +0000 (19:57 +0800)
we cannot rely on the order in which items are arranged in a dict, the
order varies from version to another. in Python2, it happens to work,
and we can always have the self-signed cert added first. but in Python3,
it does not. and an exception is thrown
```
teuthology.exceptions.ConfigError: ssl: ca root not found for
certificate rgw.client.0
```

in this change, before creating certs, the settings are reordered so
that the self-signed ones are created first.

Signed-off-by: Kefu Chai <kchai@redhat.com>
(cherry picked from commit f28a5fef3b8ddb97962f91cc78174fd6e1431fed)

qa/tasks/openssl_keys.py

index 657aa7d55782507e45817a5addd5d9f080274641..3cc4ed8a5ec6fa6a711092dfa0709d6624a713da 100644 (file)
@@ -64,8 +64,9 @@ class OpenSSLKeys(Task):
 
         # use testdir/ca as a working directory
         self.cadir = '/'.join((misc.get_testdir(self.ctx), 'ca'))
-
-        for name, config in self.config.items():
+        # make sure self-signed certs get added first, they don't have 'ca' field
+        configs = sorted(self.config.items(), key=lambda x: 'ca' in x[1])
+        for name, config in configs:
             # names must be unique to avoid clobbering each others files
             if name in self.ctx.ssl_certificates:
                 raise ConfigError('ssl: duplicate certificate name {}'.format(name))