Skip to content

Commit

Permalink
Merge pull request #140 from mshitrit/fix-ignoring-safe-time-to-reboo…
Browse files Browse the repository at this point in the history
…t-config

config value of safe time to reboot was calculated wrongly
  • Loading branch information
openshift-merge-robot authored Sep 7, 2023
2 parents 6f8d6a5 + 9aeb491 commit 6b819a4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions api/v1alpha1/selfnoderemediationconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ import (
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

const (
ConfigCRName = "self-node-remediation-config"
defaultWatchdogPath = "/dev/watchdog"
defaultSafetToAssumeNodeRebootTimeout = 180
defaultIsSoftwareRebootEnabled = true
ConfigCRName = "self-node-remediation-config"
defaultWatchdogPath = "/dev/watchdog"
DefaultSafeToAssumeNodeRebootTimeout = 180
defaultIsSoftwareRebootEnabled = true
)

// SelfNodeRemediationConfigSpec defines the desired state of SelfNodeRemediationConfig
Expand Down Expand Up @@ -162,7 +162,7 @@ func NewDefaultSelfNodeRemediationConfig() SelfNodeRemediationConfig {
ObjectMeta: metav1.ObjectMeta{Name: ConfigCRName},
Spec: SelfNodeRemediationConfigSpec{
WatchdogFilePath: defaultWatchdogPath,
SafeTimeToAssumeNodeRebootedSeconds: defaultSafetToAssumeNodeRebootTimeout,
SafeTimeToAssumeNodeRebootedSeconds: DefaultSafeToAssumeNodeRebootTimeout,
IsSoftwareRebootEnabled: defaultIsSoftwareRebootEnabled,
},
}
Expand Down
8 changes: 4 additions & 4 deletions controllers/selfnoderemediationconfig_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,11 @@ func (r *SelfNodeRemediationConfigReconciler) syncConfigDaemonSet(ctx context.Co
data.Data["EndpointHealthCheckUrl"] = snrConfig.Spec.EndpointHealthCheckUrl
data.Data["HostPort"] = snrConfig.Spec.HostPort

timeToAssumeNodeRebooted := snrConfig.Spec.SafeTimeToAssumeNodeRebootedSeconds
if timeToAssumeNodeRebooted == 0 {
timeToAssumeNodeRebooted = 180
safeTimeToAssumeNodeRebootedSeconds := snrConfig.Spec.SafeTimeToAssumeNodeRebootedSeconds
if safeTimeToAssumeNodeRebootedSeconds == 0 {
safeTimeToAssumeNodeRebootedSeconds = selfnoderemediationv1alpha1.DefaultSafeToAssumeNodeRebootTimeout
}
data.Data["TimeToAssumeNodeRebooted"] = fmt.Sprintf("\"%d\"", timeToAssumeNodeRebooted)
data.Data["TimeToAssumeNodeRebooted"] = fmt.Sprintf("\"%d\"", safeTimeToAssumeNodeRebootedSeconds)

data.Data["IsSoftwareRebootEnabled"] = fmt.Sprintf("\"%t\"", snrConfig.Spec.IsSoftwareRebootEnabled)

Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,10 @@ func initSelfNodeRemediationAgent(mgr manager.Manager) {
apiServerTimeout := getDurEnvVarOrDie("API_SERVER_TIMEOUT") //timeout for each api-connectivity check
peerDialTimeout := getDurEnvVarOrDie("PEER_DIAL_TIMEOUT") //timeout for establishing connection to peer
peerRequestTimeout := getDurEnvVarOrDie("PEER_REQUEST_TIMEOUT") //timeout for each peer request
timeToAssumeNodeRebooted := getDurEnvVarOrDie("TIME_TO_ASSUME_NODE_REBOOTED")
timeToAssumeNodeRebootedInSeconds := getIntEnvVarOrDie("TIME_TO_ASSUME_NODE_REBOOTED")
peerHealthDefaultPort := getIntEnvVarOrDie("HOST_PORT")

safeRebootCalc := reboot.NewSafeTimeCalculator(mgr.GetClient(), wd, maxErrorThreshold, apiCheckInterval, apiServerTimeout, peerDialTimeout, peerRequestTimeout, timeToAssumeNodeRebooted)
safeRebootCalc := reboot.NewSafeTimeCalculator(mgr.GetClient(), wd, maxErrorThreshold, apiCheckInterval, apiServerTimeout, peerDialTimeout, peerRequestTimeout, time.Duration(timeToAssumeNodeRebootedInSeconds)*time.Second)
if err = mgr.Add(safeRebootCalc); err != nil {
setupLog.Error(err, "failed to add safe reboot time calculator to the manager")
os.Exit(1)
Expand Down

0 comments on commit 6b819a4

Please sign in to comment.