#1091 Stream collision only requires anonymous Koji session
Closed 7 months ago by mprahl. Opened 7 months ago by cqi.
cqi/fm-orchestrator use-anonymouse-koji-session  into  master

@@ -445,7 +445,7 @@ 

  

      @staticmethod

      @module_build_service.utils.retry(wait_on=(xmlrpclib.ProtocolError, koji.GenericError))

-     def get_session(config, owner):

+     def get_session(config, owner, login=True):

          koji_config = munch.Munch(koji.read_config(

              profile_name=config.koji_profile,

              user_config=config.koji_config,

@@ -454,31 +454,34 @@ 

          koji_config["timeout"] = 60 * 10

  

          address = koji_config.server

-         authtype = koji_config.authtype

-         log.info("Connecting to koji %r with %r." % (address, authtype))

+         log.info("Connecting to koji %r.", address)

          koji_session = koji.ClientSession(address, opts=koji_config)

-         if authtype == "kerberos":

-             ccache = getattr(config, "krb_ccache", None)

-             keytab = getattr(config, "krb_keytab", None)

-             principal = getattr(config, "krb_principal", None)

-             log.debug("  ccache: %r, keytab: %r, principal: %r" % (

-                 ccache, keytab, principal))

-             if keytab and principal:

-                 koji_session.krb_login(

-                     principal=principal,

-                     keytab=keytab,

-                     ccache=ccache

+ 

+         if login:

+             authtype = koji_config.authtype

+             log.info("Logging into koji with %r.", authtype)

+             if authtype == "kerberos":

+                 ccache = getattr(config, "krb_ccache", None)

+                 keytab = getattr(config, "krb_keytab", None)

+                 principal = getattr(config, "krb_principal", None)

+                 log.debug("  ccache: %r, keytab: %r, principal: %r" % (

+                     ccache, keytab, principal))

+                 if keytab and principal:

+                     koji_session.krb_login(

+                         principal=principal,

+                         keytab=keytab,

+                         ccache=ccache

+                     )

+                 else:

+                     koji_session.krb_login(ccache=ccache)

+             elif authtype == "ssl":

+                 koji_session.ssl_login(

+                     os.path.expanduser(koji_config.cert),

+                     None,

+                     os.path.expanduser(koji_config.serverca)

                  )

              else:

-                 koji_session.krb_login(ccache=ccache)

-         elif authtype == "ssl":

-             koji_session.ssl_login(

-                 os.path.expanduser(koji_config.cert),

-                 None,

-                 os.path.expanduser(koji_config.serverca)

-             )

-         else:

-             raise ValueError("Unrecognized koji authtype %r" % authtype)

+                 raise ValueError("Unrecognized koji authtype %r" % authtype)

  

          return koji_session

  

@@ -144,7 +144,7 @@ 

      modules_nsvc = req_data['stream_collision_modules']

      built_rpms = []

  

-     koji_session = KojiModuleBuilder.get_session(conf, None)

+     koji_session = KojiModuleBuilder.get_session(conf, None, login=False)

  

      for nsvc in modules_nsvc:

          name, stream, version, context = nsvc.split(':')

@mprahl PR#1030 only requires an anonymous Koji session to call API listTaggedRPMS. I also made another PR #1092 for FACTORY-3616. If you still think it should be good to handle stream collision in init handler, I can rebase that PR. :)

@cqi I appreciate the simplicity of this approach, but handling the stream collision in the init handler is the best approach since we want to make the API return quickly and have the longer tasks run on the backend where performance isn't quite as critical.

Pull-Request has been closed by mprahl

7 months ago