Skip to content

Commit

Permalink
Refractor cleanup local files for unregistration processes (#3520)
Browse files Browse the repository at this point in the history
Signed-off-by: ahitacat <[email protected]>
  • Loading branch information
ahitacat authored Sep 13, 2022
1 parent d9ec49d commit 8ff1200
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
18 changes: 8 additions & 10 deletions insights/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
from .archive import InsightsArchive
from .support import registration_check
from .constants import InsightsConstants as constants
from .schedule import get_scheduler

NETWORK = constants.custom_network_log_level
LOG_FORMAT = ("%(asctime)s %(levelname)8s %(name)s %(message)s")
Expand Down Expand Up @@ -200,16 +199,18 @@ def get_registration_status(config, pconn):
return registration_check(pconn)


def __cleanup_local_files():
write_unregistered_file()
delete_cache_files()
write_to_disk(constants.machine_id_file, delete=True)
logger.debug('Unregistered and removed machine-id')


# -LEGACY-
def _legacy_handle_unregistration(config, pconn):
"""
returns (bool): True success, False failure
"""
def __cleanup_local_files():
write_unregistered_file()
get_scheduler(config).remove_scheduling()
delete_cache_files()
write_to_disk(constants.machine_id_file, delete=True)

check = get_registration_status(config, pconn)

Expand Down Expand Up @@ -248,10 +249,7 @@ def handle_unregistration(config, pconn):
unreg = pconn.unregister()
if unreg or config.force:
# only set if unreg was successful or --force was set
write_unregistered_file()
delete_cache_files()
write_to_disk(constants.machine_id_file, delete=True)
logger.debug('Unregistered and removed machine-id')
__cleanup_local_files()
return unreg


Expand Down
1 change: 1 addition & 0 deletions insights/client/phase/v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ def post_update(client, config):
# put this first to avoid conflicts with register
if config.unregister:
if client.unregister():
get_scheduler(config).remove_scheduling()
sys.exit(constants.sig_kill_ok)
else:
sys.exit(constants.sig_kill_bad)
Expand Down

0 comments on commit 8ff1200

Please sign in to comment.