Skip to content

Commit

Permalink
Add a config to specify the number of minutes to wait before performi…
Browse files Browse the repository at this point in the history
…ng a system reboot
  • Loading branch information
HoussemNasri committed Oct 22, 2023
1 parent 36b8ccb commit a2282d4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
21 changes: 21 additions & 0 deletions java/code/src/com/redhat/rhn/common/conf/ConfigDefaults.java
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,11 @@ public class ConfigDefaults {
*/
public static final String UNIFY_CUSTOM_CHANNEL_MANAGEMENT = "java.unify_custom_channel_management";

/**
* Specify the number of minutes to wait before performing a system reboot
* */
public static final String REBOOT_DELAY = "java.reboot_delay";

/**
* Disable SSL redirection
*/
Expand Down Expand Up @@ -1147,4 +1152,20 @@ public boolean isSsl() {
public long getRhuiDefaultOrgId() {
return Config.get().getInt(RHUI_DEFAULT_ORG_ID, 1);
}

/**
* Returns the number of minutes to wait before performing a system reboot
*
* @return the minutes to wait before a system reboot
* */
public int getRebootDelay() {
int rebootDelay = Config.get().getInt(REBOOT_DELAY, 3);
// A value of 0 would cause a direct shutdown which makes it impossible for salt to return
// the result back, resulting in a failed action.
if (rebootDelay < 1) {
rebootDelay = 1;
}

return rebootDelay;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1273,10 +1273,11 @@ private Map<LocalCall<?>, List<MinionSummary>> hardwareRefreshListAction(
}

private Map<LocalCall<?>, List<MinionSummary>> rebootAction(List<MinionSummary> minionSummaries) {
int rebootDelay = ConfigDefaults.get().getRebootDelay();
return minionSummaries.stream().collect(
Collectors.groupingBy(
m -> m.isTransactionalUpdate() ? TransactionalUpdate.reboot() :
com.suse.salt.netapi.calls.modules.System.reboot(Optional.of(3))
com.suse.salt.netapi.calls.modules.System.reboot(Optional.of(rebootDelay))
)
);
}
Expand Down

0 comments on commit a2282d4

Please sign in to comment.