Skip to content

Commit

Permalink
- updating nfsd.sh to ignore unbound value error
Browse files Browse the repository at this point in the history
- updating provisioner-nfs to use default 90s for grace/lease time

Signed-off-by: mayank <[email protected]>
  • Loading branch information
mayank authored and kmova committed Jun 14, 2021
1 parent fe5a311 commit 489da0d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
6 changes: 4 additions & 2 deletions nfs-server-container/nfsd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ get_nfs_args() {
declare -n args=$1

args=(--debug 8 --no-udp --no-nfs-version 2 --no-nfs-version 3)
if [ ! -z ${NFS_GRACE_TIME} ]; then

# here we are checking if variable exist and its value is not null
if [ ! -z ${NFS_GRACE_TIME:+x} ]; then
args+=( --grace-time ${NFS_GRACE_TIME})
fi

if [ ! -z ${NFS_LEASE_TIME} ]; then
if [ ! -z ${NFS_LEASE_TIME:+x} ]; then
args+=( --lease-time ${NFS_LEASE_TIME})
fi
}
Expand Down
30 changes: 24 additions & 6 deletions provisioner/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,13 @@ const (

// LeaseTime defines the renewl period(in seconds) for client state
// if not set then default value(90s) will be used
LeaseTime = "LeaseTime"
LeaseTime = "LeaseTime"
DefaultLeaseTime = 90

// GraceTime defines the recovery period(in seconds) to reclaim locks
// If it is not set then default value(90s) will be used
GraceTime = "GraceTime"
GraceTime = "GraceTime"
DefaultGraceTime = 90
)

const (
Expand Down Expand Up @@ -144,17 +146,33 @@ func (c *VolumeConfig) GetCustomNFSServerConfig() string {
func (c *VolumeConfig) GetNFSServerLeaseTime() (int, error) {
leaseTime := c.getValue(LeaseTime)
if len(strings.TrimSpace(leaseTime)) == 0 {
return 0, nil
return DefaultLeaseTime, nil
}
return strconv.Atoi(leaseTime)
leaseTimeVal, err := strconv.Atoi(leaseTime)
if err != nil {
return 0, err
}
if leaseTimeVal == 0 {
leaseTimeVal = DefaultLeaseTime
}

return leaseTimeVal, nil
}

func (c *VolumeConfig) GetNFServerGraceTime() (int, error) {
graceTime := c.getValue(GraceTime)
if len(strings.TrimSpace(graceTime)) == 0 {
return 0, nil
return DefaultGraceTime, nil
}
graceTimeVal, err := strconv.Atoi(graceTime)
if err != nil {
return 0, err
}

if graceTimeVal == 0 {
graceTimeVal = DefaultGraceTime
}
return strconv.Atoi(graceTime)
return graceTimeVal, nil
}

//getValue is a utility function to extract the value
Expand Down

0 comments on commit 489da0d

Please sign in to comment.