Skip to content

Commit

Permalink
Remove automatic registration delay for rhsmcertd
Browse files Browse the repository at this point in the history
* Card ID: CCT-67

The delay was introduced in early versions of the code when Python was
not reliable for long-running tasks. Since we want to make automatic
registration in both standard and anonymous flow to be as fast as
possible, this delay is removed.

This splay period is now performed by the Python code in case the we
have obtained the anonymous entitlement certificates; before we ask for
the identity certificate.
  • Loading branch information
m-horky committed Jan 18, 2024
1 parent cf046a0 commit 19dcdc1
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions src/daemons/rhsmcertd.c
Original file line number Diff line number Diff line change
Expand Up @@ -915,13 +915,11 @@ main (int argc, char *argv[])
// NOTE: We put the initial checks on a timer so that in the case of systemd,
// we can ensure that the network interfaces are all up before the initial
// checks are done.
int auto_reg_initial_delay = 0;
int auto_attach_initial_delay = 0;
int cert_check_initial_delay = 0;
if (run_now) {
info ("Initial checks will be run now!");
} else {
int auto_reg_offset = 0;
int auto_attach_offset = 0;
int cert_check_offset = 0;
if (splay_enabled == true) {
Expand Down Expand Up @@ -960,16 +958,10 @@ main (int argc, char *argv[])
}
#endif
srand((unsigned int) seed);
auto_reg_offset = gen_random(auto_reg_interval_seconds);
auto_attach_offset = gen_random(heal_interval_seconds);
cert_check_offset = gen_random(cert_interval_seconds);
}

if (auto_reg_enabled) {
auto_reg_initial_delay = INITIAL_DELAY_SECONDS + auto_reg_offset;
info ("Waiting %.1f minutes plus %d splay seconds [%d seconds total] before performing first auto-register",
INITIAL_DELAY_SECONDS / 60.0, auto_reg_offset, auto_reg_initial_delay);
}
auto_attach_initial_delay = INITIAL_DELAY_SECONDS + auto_attach_offset;
info ("Waiting %.1f minutes plus %d splay seconds [%d seconds total] before performing first auto-attach.",
INITIAL_DELAY_SECONDS / 60.0, auto_attach_offset, auto_attach_initial_delay);
Expand All @@ -994,8 +986,7 @@ main (int argc, char *argv[])
auto_attach_data.next_update_file = NEXT_AUTO_ATTACH_UPDATE_FILE;

if (auto_reg_enabled) {
g_timeout_add(auto_reg_initial_delay * 1000,
(GSourceFunc) initial_auto_register, (gpointer) &auto_register_data);
initial_auto_register((gpointer) &auto_register_data);
}
g_timeout_add (cert_check_initial_delay * 1000,
(GSourceFunc) initial_cert_check, (gpointer) &cert_check_data);
Expand All @@ -1006,7 +997,7 @@ main (int argc, char *argv[])
// time. This works for most users, since the cert_interval aligns with
// runs of heal_interval (i.e., heal_interval % cert_interval = 0)
if (auto_reg_enabled) {
log_update (auto_reg_initial_delay, NEXT_AUTO_REGISTER_UPDATE_FILE);
log_update (0, NEXT_AUTO_REGISTER_UPDATE_FILE);
}
log_update (cert_check_initial_delay, NEXT_CERT_UPDATE_FILE);
log_update (auto_attach_initial_delay, NEXT_AUTO_ATTACH_UPDATE_FILE);
Expand Down

0 comments on commit 19dcdc1

Please sign in to comment.