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

feat(NodeController): made node polling interval configurable #256

Merged
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ func main() {
"--wbps-per-gb=\"vg1-prefix:100,vg2-prefix:200\"",
)

cmd.PersistentFlags().IntVar(
&config.NodeControllerPollingInterval, "node-polling-interval", 60, "The interval, in seconds, between node polling.",
)

err := cmd.Execute()
if err != nil {
_, _ = fmt.Fprintf(os.Stderr, "%s", err.Error())
Expand Down
2 changes: 1 addition & 1 deletion pkg/driver/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func NewNode(d *CSIDriver) csi.NodeServer {

// start the lvm node resource watcher
go func() {
err := lvmnode.Start(&ControllerMutex, stopCh)
err := lvmnode.Start(&ControllerMutex, stopCh, d.config.NodeControllerPollingInterval)
if err != nil {
klog.Fatalf("Failed to start LVM node controller: %s", err.Error())
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/driver/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ type Config struct {

// KubeAPIBurst is the burst to allow while talking with Kubernetes API server.
KubeAPIBurst int

// NodeControllerPollingInterval is the interval, in seconds, between node polling.
NodeControllerPollingInterval int
}

// Default returns a new instance of config
Expand Down
5 changes: 3 additions & 2 deletions pkg/mgmt/lvmnode/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ type NodeController struct {

// This function returns controller object with all required keys set to watch over lvmnode object
func newNodeController(kubeClient kubernetes.Interface, client dynamic.Interface,
dynInformer dynamicinformer.DynamicSharedInformerFactory, ownerRef metav1.OwnerReference) (*NodeController, error) {
dynInformer dynamicinformer.DynamicSharedInformerFactory, ownerRef metav1.OwnerReference,
pollInterval int) (*NodeController, error) {
//Creating informer for lvm node resource
nodeInformer := dynInformer.ForResource(noderesource).Informer()
eventBroadcaster := record.NewBroadcaster()
Expand All @@ -102,7 +103,7 @@ func newNodeController(kubeClient kubernetes.Interface, client dynamic.Interface
Name: "Node",
}),
recorder: recorder,
pollInterval: 60 * time.Second,
pollInterval: time.Duration(pollInterval) * time.Second,
ownerRef: ownerRef,
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/mgmt/lvmnode/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import (
)

// Start starts the lvmnode controller.
func Start(controllerMtx *sync.RWMutex, stopCh <-chan struct{}) error {
func Start(controllerMtx *sync.RWMutex, stopCh <-chan struct{}, pollInterval int) error {

// Get in cluster config
cfg, err := k8sapi.Config().Get()
Expand Down Expand Up @@ -84,7 +84,7 @@ func Start(controllerMtx *sync.RWMutex, stopCh <-chan struct{}) error {
// This lock is used to serialize the AddToScheme call of all controllers.
controllerMtx.Lock()

controller, err := newNodeController(kubeClient, openebsClientNew, nodeInformerFactory, ownerRef)
controller, err := newNodeController(kubeClient, openebsClientNew, nodeInformerFactory, ownerRef, pollInterval)
if err != nil {
return errors.Wrap(err, "failed to create new lvm node controller")
}
Expand Down
Loading