Skip to content
This repository was archived by the owner on Aug 14, 2021. It is now read-only.

Commit

Permalink
Handle term-limit timeout for volume provisioning (#53)
Browse files Browse the repository at this point in the history
* Handle term-limit timeout for volume provisioning

This PR will introduce PROVISIONER_LEASE_TIMEOUT env variable to
configure termlimit timout value.

TermLimit is the maximum duration that a leader may remain the leader
to complete the task before it must give up its leadership.
Defaults to 30 seconds.

Signed-off-by: prateekpandey14 <[email protected]>

* Do exit in case of invalid lease timeout

Signed-off-by: prateekpandey14 <[email protected]>
  • Loading branch information
prateekpandey14 authored and Amit Kumar Das committed Aug 9, 2018
1 parent b1d2f03 commit a3f7e63
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions lib/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"fmt"
"net"
"net/http"
"os"
"os/exec"
"strconv"
"strings"
Expand Down Expand Up @@ -419,7 +420,20 @@ func NewProvisionController(
} else {
eventRecorder = broadcaster.NewRecorder(scheme.Scheme, v1.EventSource{Component: fmt.Sprintf("%s %s %s", provisionerName, strings.TrimSpace(string(out)), string(identity))})
}

var CustomTermLimit time.Duration
leaseTimeout, ok := os.LookupEnv("OPENEBS_IO_PROVISIONER_LEASE_TIMEOUT")
if !ok {
// TermLimit is the maximum duration that a leader may remain the leader
// to complete the task before it must give up its leadership.
// Defaults to 30 seconds.
CustomTermLimit = DefaultTermLimit
} else {
CustomTermLimit, err = time.ParseDuration(leaseTimeout)
if err != nil {
glog.Fatalf("lease timeout parsing error :", err)
}
}
glog.Infof("using provisioner termLimit seconds:%s", CustomTermLimit.String())
controller := &ProvisionController{
client: client,
provisionerName: provisionerName,
Expand All @@ -436,7 +450,7 @@ func NewProvisionController(
leaseDuration: DefaultLeaseDuration,
renewDeadline: DefaultRenewDeadline,
retryPeriod: DefaultRetryPeriod,
termLimit: DefaultTermLimit,
termLimit: CustomTermLimit,
metricsPort: DefaultMetricsPort,
metricsAddress: DefaultMetricsAddress,
metricsPath: DefaultMetricsPath,
Expand Down

0 comments on commit a3f7e63

Please sign in to comment.