]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: use gpg key for add-repo on ubuntu/debian
authorAdam King <adking@redhat.com>
Thu, 10 Jun 2021 19:16:15 +0000 (15:16 -0400)
committerSebastian Wagner <sewagner@redhat.com>
Thu, 17 Jun 2021 08:47:02 +0000 (10:47 +0200)
We were using the ascii version of the gpg key which
was marked as an unsupported filetype by apt-get which
caused apt-get to not make use of the repo source we
were adding.

Additionally, added aomething to make sure we update the
package list after adding the source and key

Fixes: https://tracker.ceph.com/issues/44972
Fixes: https://tracker.ceph.com/issues/45009
Signed-off-by: Adam King <adking@redhat.com>
(cherry picked from commit 54055381fd61d290bf3b44ec01e7d4f3a0eb5f1c)

src/cephadm/cephadm

index c6f1efc4a32ebffe1415e3e96bf0b5e684bc6cd4..bd69ba73c3e1d44fc8c711cf4c6a68766e02ab0e 100755 (executable)
@@ -5769,9 +5769,9 @@ class Packager(object):
         if self.ctx.gpg_url:
             return self.ctx.gpg_url
         if self.stable or self.version:
-            return 'https://download.ceph.com/keys/release.asc', 'release'
+            return 'https://download.ceph.com/keys/release.gpg', 'release'
         else:
-            return 'https://download.ceph.com/keys/autobuild.asc', 'autobuild'
+            return 'https://download.ceph.com/keys/autobuild.gpg', 'autobuild'
 
     def enable_service(self, service):
         """
@@ -5809,8 +5809,8 @@ class Apt(Packager):
             logger.error('failed to fetch GPG repo key from %s: %s' % (
                 url, err))
             raise Error('failed to fetch GPG key')
-        key = response.read().decode('utf-8')
-        with open('/etc/apt/trusted.gpg.d/ceph.%s.gpg' % name, 'w') as f:
+        key = response.read()
+        with open('/etc/apt/trusted.gpg.d/ceph.%s.gpg' % name, 'wb') as f:
             f.write(key)
 
         if self.version:
@@ -5827,6 +5827,8 @@ class Apt(Packager):
         with open(self.repo_path(), 'w') as f:
             f.write(content)
 
+        self.update()
+
     def rm_repo(self):
         for name in ['autobuild', 'release']:
             p = '/etc/apt/trusted.gpg.d/ceph.%s.gpg' % name
@@ -5844,11 +5846,15 @@ class Apt(Packager):
         logger.info('Installing packages %s...' % ls)
         call_throws(self.ctx, ['apt-get', 'install', '-y'] + ls)
 
+    def update(self):
+        logger.info('Updating package list...')
+        call_throws(self.ctx, ['apt-get', 'update'])
+
     def install_podman(self):
         if self.distro == 'ubuntu':
             logger.info('Setting up repo for podman...')
             self.add_kubic_repo()
-            call_throws(self.ctx, ['apt-get', 'update'])
+            self.update()
 
         logger.info('Attempting podman install...')
         try:
@@ -6160,12 +6166,16 @@ def command_add_repo(ctx: CephadmContext):
             (x, y, z) = ctx.version.split('.')
         except Exception:
             raise Error('version must be in the form x.y.z (e.g., 15.2.0)')
+    if ctx.release:
+        # Pacific =/= pacific in this case, set to undercase to avoid confision
+        ctx.release = ctx.release.lower()
 
     pkg = create_packager(ctx, stable=ctx.release,
                           version=ctx.version,
                           branch=ctx.dev,
                           commit=ctx.dev_commit)
     pkg.add_repo()
+    logger.info('Completed adding repo.')
 
 
 def command_rm_repo(ctx: CephadmContext):
@@ -8195,7 +8205,7 @@ def main():
         # podman or docker?
         ctx.container_engine = find_container_engine(ctx)
         if ctx.func not in \
-                [command_check_host, command_prepare_host, command_add_repo]:
+                [command_check_host, command_prepare_host, command_add_repo, command_install]:
             check_container_engine(ctx)
         # command handler
         r = ctx.func(ctx)