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

PB-8410 Fix global variable reset issue #406

Merged
merged 1 commit into from
Nov 26, 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
17 changes: 10 additions & 7 deletions pkg/drivers/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ const (
// PxbJobFailureRetryTimeoutKey defines timeout key name to be set after job failure due to mount failure
PxbJobFailureRetryTimeoutKey = "MOUNT_FAILURE_RETRY_TIMEOUT"
// PxbDefaultJobFailureRetryTimeout default timeout after job failure due to mount failure
PxbDefaultJobFailureRetryTimeout = "30"
// The value is set to little above the pod mount failure timeout of 2m
PxbDefaultJobFailureRetryTimeout = "150"
provisionersToUseAnyUid = "PROVISIONERS_TO_USE_ANYUID"
pvcStorageProvisionerKey = "volume.kubernetes.io/storage-provisioner"
)
Expand Down Expand Up @@ -917,9 +918,9 @@ func IsJobPodMountFailed(job *batchv1.Job, namespace string) bool {
if mountFailed {
timeSinceStart := time.Since(job.CreationTimestamp.Time)
if timeSinceStart >= JobFailureRetryTimeout {
logrus.Debugf("%v: job error. Timeout elapsed for volume mount failure of pod [%s/%s]", fn, namespace, pod[0].Name)
logrus.Debugf("%v: job error. Timeout elapsed %v/%v for volume mount failure of pod [%s/%s]", fn, timeSinceStart, JobFailureRetryTimeout, namespace, pod[0].Name)
} else {
logrus.Debugf("%v: error in volume mount for pod [%s/%s]. Retry until timeout", fn, namespace, pod[0].Name)
logrus.Debugf("%v: error in volume mount for pod [%s/%s]. Retry until timeout %v/%v", fn, namespace, pod[0].Name, timeSinceStart, JobFailureRetryTimeout)
mountFailed = false
}
}
Expand Down Expand Up @@ -1238,21 +1239,23 @@ func UpdateJobFailureTimeOut(jobConfigMap, jobConfigMapNs string) {
fn := "UpdateJobFailureTimeOut"
timeOut := GetConfigValue(jobConfigMap, jobConfigMapNs, PxbJobFailureRetryTimeoutKey)
if timeOut == "" {
logrus.Debugf("%v: %s value not found in ConfigMap. Setting to default failure timeout value", fn, PxbJobFailureRetryTimeoutKey)
logrus.Debugf("%v: %s value not found in ConfigMap. Setting to default failure timeout value %v", fn, PxbJobFailureRetryTimeoutKey, PxbDefaultJobFailureRetryTimeout)
timeOut = PxbDefaultJobFailureRetryTimeout
} else {
// we could fail here if the value set is invalid or has some junk character
duration, err := time.ParseDuration(timeOut + "s")
if err != nil || duration <= 0 {
logrus.Debugf("%v:invalid %v value set. Should be numberic value > 0. Setting to default failure timeout value", fn, PxbJobFailureRetryTimeoutKey)
logrus.Debugf("%v:invalid %v value set. Should be numberic value > 0. Setting to default failure timeout value %v", fn, PxbJobFailureRetryTimeoutKey, PxbDefaultJobFailureRetryTimeout)
timeOut = PxbDefaultJobFailureRetryTimeout
}
}
JobFailureRetryTimeout, err := time.ParseDuration(timeOut + "s")
duration, err := time.ParseDuration(timeOut + "s")
if err != nil {
// we should never reach here.
logrus.Debugf("%v: failed to parse the failure timeout set %v: %v", fn, JobFailureRetryTimeout, err)
logrus.Debugf("%v: error parsing %v value. Retaining current setting %v: %v", fn, PxbJobFailureRetryTimeoutKey, JobFailureRetryTimeout, err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we need to initialize duration to some value here? otherwise if this is hit JobFailureRetryTimeout might be set to 0 in next line

}
JobFailureRetryTimeout = duration
logrus.Debugf("%v: %v value set to %v", fn, PxbJobFailureRetryTimeoutKey, JobFailureRetryTimeout)
}

func GetProvisionerNameFromPvc(pvcName, pvcNamespace string) (string, error) {
Expand Down
Loading