Skip to content

Commit

Permalink
add logrotate for kube-ovn log (#1740)
Browse files Browse the repository at this point in the history
  • Loading branch information
hongzhen-ma committed Jul 25, 2022
1 parent ef275cc commit c521298
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/daemon/controller.go
Expand Up @@ -990,6 +990,12 @@ func (c *Controller) markAndCleanInternalPort() error {
return nil
}

func rotateLog() {
if output, err := exec.Command("logrotate", "/etc/logrotate.d/kubeovn").CombinedOutput(); err != nil {
klog.Errorf("failed to rotate kube-ovn log %q", output)
}
}

// Run starts controller
func (c *Controller) Run(stopCh <-chan struct{}) {
defer utilruntime.HandleCrash()
Expand All @@ -1000,6 +1006,7 @@ func (c *Controller) Run(stopCh <-chan struct{}) {

go wait.Until(ovs.CleanLostInterface, time.Minute, stopCh)
go wait.Until(recompute, 10*time.Minute, stopCh)
go wait.Until(rotateLog, 1*time.Hour, stopCh)

if ok := cache.WaitForCacheSync(stopCh, c.providerNetworksSynced, c.subnetsSynced, c.podsSynced, c.nodesSynced); !ok {
klog.Fatalf("failed to wait for caches to sync")
Expand Down

0 comments on commit c521298

Please sign in to comment.