From fd45eede1c83296fca74a565e6f456a201afe08b Mon Sep 17 00:00:00 2001 From: Andrei Paplauski Date: Apr 03 2020 13:58:09 +0000 Subject: Delete empty kerberos class and function with their context Resolves: FACTORY-5985 --- diff --git a/freshmaker/handlers/__init__.py b/freshmaker/handlers/__init__.py index 852f547..b1d2be9 100644 --- a/freshmaker/handlers/__init__.py +++ b/freshmaker/handlers/__init__.py @@ -32,7 +32,7 @@ from freshmaker.kojiservice import koji_service, parse_NVR from freshmaker.models import ArtifactBuildState from freshmaker.types import EventState from freshmaker.models import ArtifactBuild, Event -from freshmaker.utils import krb_context, get_rebuilt_nvr +from freshmaker.utils import get_rebuilt_nvr from freshmaker.errors import UnprocessableEntity, ProgrammingError from freshmaker.odcsclient import create_odcs_client, FreshmakerODCSClient from freshmaker.odcsclient import COMPOSE_STATES @@ -572,8 +572,7 @@ class ContainerBuildHandler(BaseHandler): 'state': COMPOSE_STATES['done'], } - with krb_context(): - return create_odcs_client().get_compose(compose_id) + return create_odcs_client().get_compose(compose_id) def get_repo_urls(self, build): """ diff --git a/freshmaker/kojiservice.py b/freshmaker/kojiservice.py index af80799..5970475 100644 --- a/freshmaker/kojiservice.py +++ b/freshmaker/kojiservice.py @@ -335,8 +335,7 @@ def koji_service(profile=None, logger=None, login=True, dry_run=False): log.debug('Logging into %s with Kerberos authentication.', service.server) - with freshmaker.utils.krb_context(): - service.krb_login() + service.krb_login() # We are not logged in in dry run mode... if not dry_run and not service.logged_in: diff --git a/freshmaker/models.py b/freshmaker/models.py index b0499c4..6ada479 100644 --- a/freshmaker/models.py +++ b/freshmaker/models.py @@ -36,7 +36,7 @@ from flask_login import UserMixin from freshmaker import db, log from freshmaker import messaging -from freshmaker.utils import get_url_for, krb_context +from freshmaker.utils import get_url_for from freshmaker.types import (ArtifactType, ArtifactBuildState, EventState, RebuildReason) from freshmaker.events import ( @@ -707,9 +707,8 @@ class Compose(FreshmakerBase): @property def finished(self): from freshmaker.odcsclient import create_odcs_client - with krb_context(): - return 'done' == create_odcs_client().get_compose( - self.odcs_compose_id)['state_name'] + return 'done' == create_odcs_client().get_compose( + self.odcs_compose_id)['state_name'] @classmethod def get_lowest_compose_id(cls, session): diff --git a/freshmaker/odcsclient.py b/freshmaker/odcsclient.py index 0aebd96..11014d6 100644 --- a/freshmaker/odcsclient.py +++ b/freshmaker/odcsclient.py @@ -44,7 +44,6 @@ from freshmaker.errata import Errata from freshmaker.kojiservice import koji_service from freshmaker.consumer import work_queue_put from freshmaker.types import ArtifactBuildState -from freshmaker.utils import krb_context from freshmaker.events import ODCSComposeStateChangeEvent @@ -268,10 +267,9 @@ class FreshmakerODCSClient(object): compose_source, 'tag', packages) if not self.handler.dry_run: - with krb_context(): - new_compose = create_odcs_client().new_compose( - compose_source, 'tag', packages=packages, - sigkeys=conf.odcs_sigkeys, flags=["no_deps"]) + new_compose = create_odcs_client().new_compose( + compose_source, 'tag', packages=packages, + sigkeys=conf.odcs_sigkeys, flags=["no_deps"]) else: new_compose = self._fake_odcs_new_compose( compose_source, 'tag', packages=packages) @@ -296,9 +294,8 @@ class FreshmakerODCSClient(object): odcs = create_odcs_client() if not self.handler.dry_run: - with krb_context(): - new_compose = odcs.new_compose( - ' '.join(content_sets), 'pulp') + new_compose = odcs.new_compose( + ' '.join(content_sets), 'pulp') else: new_compose = self._fake_odcs_new_compose( content_sets, 'pulp') @@ -350,11 +347,10 @@ class FreshmakerODCSClient(object): arches = sorted(image['arches'].split()) if not self.handler.dry_run: - with krb_context(): - new_compose = create_odcs_client().new_compose( - "", 'build', packages=packages, builds=builds, - arches=arches, sigkeys=conf.odcs_sigkeys, - flags=["no_deps"]) + new_compose = create_odcs_client().new_compose( + "", 'build', packages=packages, builds=builds, + arches=arches, sigkeys=conf.odcs_sigkeys, + flags=["no_deps"]) else: new_compose = self._fake_odcs_new_compose( "", 'build', packages=packages, diff --git a/freshmaker/utils.py b/freshmaker/utils.py index 52036d7..53cbced 100644 --- a/freshmaker/utils.py +++ b/freshmaker/utils.py @@ -116,18 +116,6 @@ def get_rebuilt_nvr(artifact_type, nvr): return rebuilt_nvr -class krbContext(object): - def __enter__(self): - return self - - def __exit__(self, exc_type, exc_value, traceback): - pass - - -def krb_context(): - return krbContext() - - def load_class(location): """ Take a string of the form 'fedmsg.consumers.ircbot:IRCBotConsumer' and return the IRCBotConsumer class. diff --git a/tests/helpers.py b/tests/helpers.py index 5dcf6b1..ad5143f 100644 --- a/tests/helpers.py +++ b/tests/helpers.py @@ -82,15 +82,6 @@ class Patcher(object): class FreshmakerTestCase(unittest.TestCase): - def setUp(self): - # We don't have any valid Kerberos context during the tests, so disable - # it by default by patching it. - self.krb_context_patcher = patch('freshmaker.utils.krbContext') - self.krb_context_patcher.start() - - def tearDown(self): - self.krb_context_patcher.stop() - def get_event_from_msg(self, message): event = events.BaseEvent.from_fedmsg(message['body']['topic'], message['body']) return event