diff --git a/cmd/main.go b/cmd/main.go index e52e556304893e5faec231462b59168bb33a00ce..9845df3c99321b781410d59c35490bbf74aae9c7 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -27,6 +27,9 @@ import ( "k8s.io/klog/v2" ) +const LogDir = "/var/log/iluvatarcorex/ix-device-plugin" +const LogPath = "/var/log/iluvatarcorex/ix-device-plugin/ix-device-plugin.log" + func main() { logging := flag.NewFlagSet("logging", flag.ExitOnError) @@ -54,12 +57,18 @@ func main() { } defer klog.Flush() - logging.Set("log_dir", "/var/log/iluvatarcorex/ix-device-plugin") - logging.Set("log_file", "/var/log/iluvatarcorex/ix-device-plugin/ix-device-plugin.log") + + err := os.MkdirAll(LogDir, 0755) + if err != nil { + klog.Errorf("unable to create directory %v: %v", LogDir, err) + } + + logging.Set("log_dir", LogDir) + logging.Set("log_file", LogPath) logging.Set("logtostderr", "false") flag.Parse() - err := c.Run(os.Args) + err = c.Run(os.Args) if err != nil { klog.Error(err) klog.Flush() diff --git a/ix-device-plugin.yaml b/ix-device-plugin.yaml index 5ef48c9bb880e8dfbd52fb44fed494e36bf13c9a..8a6a68957787c198312412f6b3b2ed2ea5ea7e84 100644 --- a/ix-device-plugin.yaml +++ b/ix-device-plugin.yaml @@ -84,7 +84,7 @@ spec: - name: ixc mountPath: /ixconfig - name: ix-device-plugin-log - mountPath: /var/log/iluvatarcorex/ix-device-plugin + mountPath: /var/log/iluvatarcorex/ volumes: - hostPath: path: /var/lib/kubelet/device-plugins @@ -106,5 +106,5 @@ spec: name: ix-config - name: ix-device-plugin-log hostPath: - path: /var/log/iluvatarcorex/ix-device-plugin + path: /var/log/iluvatarcorex type: Directory