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

minikube logs not outputing to file when using --last-start-only #19931

Open
mattisafur opened this issue Nov 10, 2024 · 4 comments · May be fixed by #20138
Open

minikube logs not outputing to file when using --last-start-only #19931

mattisafur opened this issue Nov 10, 2024 · 4 comments · May be fixed by #20138

Comments

@mattisafur
Copy link

What Happened?

When running minikube logs --file log.txt --last-start-only output is printer to the terminal and an empty file is created.

output of minikube logs --file log.txt --last-start-only --alsologtostderr:

I1110 17:39:34.383805   16647 out.go:345] Setting OutFile to fd 1 ...
I1110 17:39:34.383994   16647 out.go:358] Setting ErrFile to fd 2...
I1110 17:39:34.384149   16647 root.go:338] Updating PATH: /home/<username>/.minikube/bin
I1110 17:39:34.392920   16647 out.go:177]

I1110 17:39:34.400630   16647 out.go:177] ==> Last Start <==
==> Last Start <==
I1110 17:39:34.419332   16647 out.go:177] Log file created at: 2024/11/10 17:12:27
Running on machine: <hostname>
Binary: Built with gc go1.22.5 for linux/amd64
Log line format: [IWEF]mmdd hh:mm:ss.uuuuuu threadid file:line] msg
I1110 17:12:27.286943   16010 out.go:345] Setting OutFile to fd 1 ...
I1110 17:12:27.287120   16010 out.go:358] Setting ErrFile to fd 2...
I1110 17:12:27.287271   16010 root.go:338] Updating PATH: /home/<username>/.minikube/bin

Log file created at: 2024/11/10 17:12:27
Running on machine: <hostname>
Binary: Built with gc go1.22.5 for linux/amd64
Log line format: [IWEF]mmdd hh:mm:ss.uuuuuu threadid file:line] msg
I1110 17:12:27.286943   16010 out.go:345] Setting OutFile to fd 1 ...
I1110 17:12:27.287120   16010 out.go:358] Setting ErrFile to fd 2...
I1110 17:12:27.287271   16010 root.go:338] Updating PATH: /home/<username>/.minikube/bin

Tested on Ubuntu running on WSL with docker driver.

output of minikube version:

minikube version: v1.34.0
commit: 210b148df93a80eb872ecbeb7e35281b3c582c61

Attach the log file

Log file is not attached as the file does not contain any information about the logs command.

Operating System

Ubuntu

Driver

Docker

@Ritikaa96
Copy link

In my case the --last-start-only addition end up giving empty file.
with minikube logs -f=log.txt i can see logs being added there.

@mattisafur
Copy link
Author

mattisafur commented Dec 11, 2024

with minikube logs -f=log.txt i can see logs being added there.

couldn't quite get what you mean, -f is a shorthand for --follow. I'm guessing you mean --file=filename? in that case I agree, the issue is only present if --last-start-only is added, though I still haven't checked it with other flags added.

I suspect it's just just an issue with --last-start-only overriding the --file flag and causing the output to still go to stdout instead of a file. I'll have to check the code to verify that, but I don't have the time for it at the moment...

@Ritikaa96
Copy link

Hi @mattisafur Just for reference, this is the implementation of the flag --last-start-only: https://github.com/kubernetes/minikube/blob/master/cmd/minikube/cmd/logs.go#L80
If i find something regarding over-riding the --file flag i'll inform here

@mattisafur
Copy link
Author

mattisafur commented Dec 17, 2024

I looked at the implementation. at the moment it does the following (when --file is set):

flowchart

A{--last-start-only set?} --> |true| B[print start log to stdout]
A --> |false| C
C{--audit set?} --> |true| D[print audit log to stdout]
C --> |false| E[print both audit log and last start log to file]
Loading

It makes more sense to me that will will work based on these rules:

  • if --file <filepath> is specified, output to file instead of stdout
  • if --audit is specified, output only the audit log
  • if --last-start-only is specified, output only the last-start log

(handle a case where both --audit and --last-start-only are specified? maybe just output nothing?)

I'll make a PR for this change.

mattisafur added a commit to mattisafur/minikube that referenced this issue Dec 20, 2024
@mattisafur mattisafur linked a pull request Dec 20, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants