Skip to content

Commit

Permalink
Configurable timeout values
Browse files Browse the repository at this point in the history
Signed-off-by: Patryk Strusiewicz-Surmacki <[email protected]>
  • Loading branch information
p-strusiewiczsurmacki-mobica committed Sep 30, 2024
1 parent 7155b2e commit 6ed1c53
Show file tree
Hide file tree
Showing 7 changed files with 160 additions and 181 deletions.
30 changes: 22 additions & 8 deletions cmd/operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,18 @@ func init() {

func main() {
var configFile string
var timeout string
var apiTimeout string
var configTimeout string
var preconfigTimeout string
var maxUpdating int
flag.StringVar(&configFile, "config", "",
"The controller will load its initial configuration from this file. "+
"Omit this flag to use the default configuration values. "+
"Command-line flags override configuration from this file.")
flag.StringVar(&timeout, "timeout", reconciler.DefaultTimeout,
flag.StringVar(&apiTimeout, "api-timeout", reconciler.DefaultTimeout,
"Timeout for Kubernetes API connections (default: 60s).")
flag.StringVar(&preconfigTimeout, "preconfig-timeout", reconciler.DefaultPreconfigTimout, "Timoeut for NodeConfig reconciliation process, when agent DID NOT picked the work yet")
flag.StringVar(&configTimeout, "config-timeout", reconciler.DefaultConfigTimeout, "Timoeut for NodeConfig reconciliation process, when agent picked the work")
flag.IntVar(&maxUpdating, "max-updating", 1, "Configures how many nodes can be updated simultaneously when rolling update is performed.")
opts := zap.Options{
Development: true,
Expand All @@ -86,7 +90,7 @@ func main() {
os.Exit(1)
}

err = setupReconcilers(mgr, timeout, maxUpdating)
err = setupReconcilers(mgr, apiTimeout, configTimeout, preconfigTimeout, maxUpdating)
if err != nil {
setupLog.Error(err, "unable to setup reconcilers")
os.Exit(1)
Expand All @@ -99,18 +103,28 @@ func main() {
}
}

func setupReconcilers(mgr manager.Manager, timeout string, maxUpdating int) error {
timoutVal, err := time.ParseDuration(timeout)
func setupReconcilers(mgr manager.Manager, apiTimeout, configTimeout, preconfigTimeout string, maxUpdating int) error {
apiTimoutVal, err := time.ParseDuration(apiTimeout)
if err != nil {
return fmt.Errorf("error parsing timeout value %s: %w", timeout, err)
return fmt.Errorf("error parsing API timeout value %s: %w", apiTimeout, err)
}

cr, err := reconciler.NewConfigReconciler(mgr.GetClient(), mgr.GetLogger().WithName("ConfigReconciler"), timoutVal)
configTimeoutVal, err := time.ParseDuration(configTimeout)
if err != nil {
return fmt.Errorf("error parsing config timeout value %s: %w", configTimeout, err)
}

preconfigTimeoutVal, err := time.ParseDuration(preconfigTimeout)
if err != nil {
return fmt.Errorf("error parsing preconfig timeout value %s: %w", preconfigTimeout, err)
}

cr, err := reconciler.NewConfigReconciler(mgr.GetClient(), mgr.GetLogger().WithName("ConfigReconciler"), apiTimoutVal)
if err != nil {
return fmt.Errorf("unable to create config reconciler reconciler: %w", err)
}

ncr, err := reconciler.NewNodeConfigReconciler(mgr.GetClient(), mgr.GetLogger().WithName("NodeConfigReconciler"), timoutVal, mgr.GetScheme(), maxUpdating)
ncr, err := reconciler.NewNodeConfigReconciler(mgr.GetClient(), mgr.GetLogger().WithName("NodeConfigReconciler"), apiTimoutVal, configTimeoutVal, preconfigTimeoutVal, mgr.GetScheme(), maxUpdating)
if err != nil {
return fmt.Errorf("unable to create node reconciler: %w", err)
}
Expand Down
63 changes: 32 additions & 31 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,43 @@ go 1.21
require (
github.com/cilium/ebpf v0.9.1
github.com/coreos/go-iptables v0.6.0
github.com/coreos/go-systemd/v22 v22.4.0
github.com/go-logr/logr v1.2.4
github.com/onsi/ginkgo v1.16.4
github.com/onsi/gomega v1.27.10
github.com/prometheus/client_golang v1.15.1
github.com/coreos/go-systemd/v22 v22.5.0
github.com/go-logr/logr v1.3.0
github.com/onsi/ginkgo v1.16.5
github.com/onsi/gomega v1.30.0
github.com/prometheus/client_golang v1.16.0
github.com/vishvananda/netlink v1.1.1-0.20211129163951-9ada19101fc5
go.uber.org/mock v0.2.0
golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb
golang.org/x/sys v0.11.0
golang.org/x/sys v0.15.0
gopkg.in/yaml.v2 v2.4.0
k8s.io/api v0.27.2
k8s.io/apimachinery v0.27.2
k8s.io/client-go v0.27.2
k8s.io/utils v0.0.0-20230209194617-a36077c30491
k8s.io/api v0.29.0
k8s.io/apimachinery v0.29.0
k8s.io/client-go v0.29.0
k8s.io/utils v0.0.0-20230726121419-3b25d923346b
sigs.k8s.io/controller-runtime v0.15.1
)

require github.com/google/go-cmp v0.5.9 // indirect
require github.com/google/go-cmp v0.6.0 // indirect

require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-logr/zapr v1.2.4 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.1 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/godbus/dbus/v5 v5.0.4 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/gnostic v0.5.7-v3refs // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/josharian/intern v1.0.0 // indirect
Expand All @@ -54,29 +54,30 @@ require (
github.com/nxadm/tail v1.4.8 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_model v0.4.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
github.com/prometheus/common v0.44.0 // indirect
github.com/prometheus/procfs v0.10.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/net v0.12.0 // indirect
golang.org/x/oauth2 v0.5.0 // indirect
golang.org/x/term v0.10.0 // indirect
golang.org/x/text v0.11.0 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/oauth2 v0.10.0 // indirect
golang.org/x/term v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.16.1 // indirect
gomodules.xyz/jsonpatch/v2 v2.3.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.30.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.27.2 // indirect
k8s.io/component-base v0.27.2 // indirect
k8s.io/klog/v2 v2.90.1 // indirect
k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f // indirect
k8s.io/apiextensions-apiserver v0.29.0 // indirect
k8s.io/component-base v0.29.0 // indirect
k8s.io/klog/v2 v2.110.1 // indirect
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)
Loading

0 comments on commit 6ed1c53

Please sign in to comment.