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

[1.29] fix: perform autoreg waiting when performing standard autoreg #3463

Merged
merged 2 commits into from
Oct 2, 2024
Merged
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
33 changes: 22 additions & 11 deletions src/subscription_manager/scripts/rhsmcertd_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,25 @@ def _collect_cloud_info(cloud_list: List[str]) -> dict:
return result


def _auto_register_wait() -> None:
"""Delay during the automatic registration.

Wait for an amount of time during automatic registration, looking at the
configured splay and autoregistration interval.
"""
cfg = config.get_config_parser()
if cfg.get("rhsmcertd", "splay") == "0":
log.debug("Trying to obtain the identity immediately, splay is disabled.")
else:
registration_interval = int(cfg.get("rhsmcertd", "auto_registration_interval"))
splay_interval: int = random.randint(60, registration_interval * 60)
log.debug(
f"Waiting a period of {splay_interval} seconds "
f"(about {splay_interval // 60} minutes) before attempting to obtain the identity."
)
time.sleep(splay_interval)


def _auto_register(cp_provider: "CPProvider") -> ExitStatus:
"""Try to perform automatic registration.

Expand Down Expand Up @@ -220,6 +239,8 @@ def _auto_register_standard(uep: "UEPConnection", token: Dict[str, str]) -> None
"""
log.debug("Registering the system through standard automatic registration.")

_auto_register_wait()

service = RegisterService(cp=uep)
service.register(org=None, jwt_token=token)

Expand All @@ -245,17 +266,7 @@ def _auto_register_anonymous(uep: "UEPConnection", token: Dict[str, str]) -> Non
manager.install_temporary_certificates(uuid=token["anonymousConsumerUuid"], jwt=token["token"])

# Step 2: Wait
cfg = config.get_config_parser()
if cfg.get("rhsmcertd", "splay") == "0":
log.debug("Trying to obtain the identity immediately, splay is disabled.")
else:
registration_interval = int(cfg.get("rhsmcertd", "auto_registration_interval"))
splay_interval: int = random.randint(60, registration_interval * 60)
log.debug(
f"Waiting a period of {splay_interval} seconds "
f"(about {splay_interval // 60} minutes) before attempting to obtain the identity."
)
time.sleep(splay_interval)
_auto_register_wait()

# Step 3: Obtain the identity certificate
log.debug("Obtaining system identity")
Expand Down
Loading