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 70246fb commit f13f3f4
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/daemon/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1231,6 +1231,12 @@ func (c *Controller) getSubnetQosPriority(subnetName string) string {
return priority
}

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 @@ -1241,6 +1247,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, c.htbQosSynced); !ok {
klog.Fatalf("failed to wait for caches to sync")
Expand Down

0 comments on commit f13f3f4

Please sign in to comment.