Skip to content

Commit

Permalink
Merge pull request #1016 from evrardjp/fix_small_memleak
Browse files Browse the repository at this point in the history
  • Loading branch information
evrardjp authored Nov 7, 2024
2 parents 659e9fd + e370b0b commit 3adeb5a
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions cmd/kured/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,13 @@ func main() {
log.Fatal(err)
}

var blockCheckers []blockers.RebootBlocker
if prometheusURL != "" {
blockCheckers = append(blockCheckers, blockers.NewPrometheusBlockingChecker(papi.Config{Address: prometheusURL}, alertFilter.Regexp, alertFiringOnly, alertFilterMatchOnly))
}
if podSelectors != nil {
blockCheckers = append(blockCheckers, blockers.NewKubernetesBlockingChecker(client, nodeID, podSelectors))
}
log.Infof("Lock Annotation: %s/%s:%s", dsNamespace, dsName, lockAnnotation)
if lockTTL > 0 {
log.Infof("Lock TTL set, lock will expire after: %v", lockTTL)
Expand All @@ -275,7 +282,7 @@ func main() {
}
lock := daemonsetlock.New(client, nodeID, dsNamespace, dsName, lockAnnotation, lockTTL, concurrency, lockReleaseDelay)

go rebootAsRequired(nodeID, rebooter, rebootChecker, window, lock, client)
go rebootAsRequired(nodeID, rebooter, rebootChecker, blockCheckers, window, lock, client)
go maintainRebootRequiredMetric(nodeID, rebootChecker)

http.Handle("/metrics", promhttp.Handler())
Expand Down Expand Up @@ -546,7 +553,7 @@ func updateNodeLabels(client *kubernetes.Clientset, node *v1.Node, labels []stri
}
}

func rebootAsRequired(nodeID string, rebooter reboot.Rebooter, checker checkers.Checker, window *timewindow.TimeWindow, lock daemonsetlock.Lock, client *kubernetes.Clientset) {
func rebootAsRequired(nodeID string, rebooter reboot.Rebooter, checker checkers.Checker, blockCheckers []blockers.RebootBlocker, window *timewindow.TimeWindow, lock daemonsetlock.Lock, client *kubernetes.Clientset) {

source := rand.NewSource(time.Now().UnixNano())
tick := delaytick.New(source, 1*time.Minute)
Expand Down Expand Up @@ -645,14 +652,6 @@ func rebootAsRequired(nodeID string, rebooter reboot.Rebooter, checker checkers.
}
}

var blockCheckers []blockers.RebootBlocker
if prometheusURL != "" {
blockCheckers = append(blockCheckers, blockers.NewPrometheusBlockingChecker(papi.Config{Address: prometheusURL}, alertFilter.Regexp, alertFiringOnly, alertFilterMatchOnly))
}
if podSelectors != nil {
blockCheckers = append(blockCheckers, blockers.NewKubernetesBlockingChecker(client, nodeID, podSelectors))
}

var rebootRequiredBlockCondition string
if blockers.RebootBlocked(blockCheckers...) {
rebootRequiredBlockCondition = ", but blocked at this time"
Expand Down

0 comments on commit 3adeb5a

Please sign in to comment.