Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refractor cleanup local files for unregistration processes #3520

Merged
merged 1 commit into from
Sep 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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