Skip to content

Commit

Permalink
Set the nmstate checkpoint timeout (#222)
Browse files Browse the repository at this point in the history
It has to be at least more than defaultGw ping probe time or
checkpoint is not going to be there when we run commit after a
long time pinging default gw until network configuration settles.

Signed-off-by: Quique Llorente <[email protected]>
  • Loading branch information
qinqon authored Oct 15, 2019
1 parent 2a3afc3 commit f1ebd60
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pkg/helper/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"io"
"os"
"os/exec"
"strconv"
"strings"
"time"

Expand All @@ -31,6 +32,7 @@ var (

const nmstateCommand = "nmstatectl"
const vlanFilteringCommand = "vlan-filtering"
const defaultGwProbeTimeout = 120

var (
interfacesFilterGlob glob.Glob
Expand Down Expand Up @@ -102,8 +104,12 @@ func set(state string) (string, error) {
// https://nmstate.atlassian.net/browse/NMSTATE-247
retries := 3
for retries > 0 {
output, err = nmstatectl([]string{"set", "--no-commit"}, state)
// commit timeout doubles the default gw ping probe timeout, to
// ensure the Checkpoint is alive before rolling it back
// https://nmstate.github.io/cli_guide#manual-transaction-control
output, err = nmstatectl([]string{"set", "--no-commit", "--timeout", strconv.Itoa(defaultGwProbeTimeout * 2)}, state)
if err == nil {
log.Info(fmt.Sprintf("nmstatectl set recovered, output: %s", output))
break
}
retries--
Expand Down Expand Up @@ -252,7 +258,7 @@ func ApplyDesiredState(nodeNetworkState *nmstatev1alpha1.NodeNetworkState) (stri
}

// TODO: Make ping timeout configurable with a config map
pingOutput, err := ping(defaultGw, 120*time.Second)
pingOutput, err := ping(defaultGw, defaultGwProbeTimeout*time.Second)
if err != nil {
return pingOutput, rollback(fmt.Errorf("error pinging external address after network reconfiguration -> error: %v, currentState: %s", err, currentState))
}
Expand Down

0 comments on commit f1ebd60

Please sign in to comment.