-
Notifications
You must be signed in to change notification settings - Fork 3
Operational logs over API: hypeman.log, vmm.log #34
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
Merged
Merged
Changes from 11 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
ac6bd97
Operational logs over API: hypeman.log, vmm.log
sjmiller609 713620e
Fix test
sjmiller609 f2525b7
Review instance log handler
sjmiller609 5c32875
Use log not found error
sjmiller609 3dd1f9d
Don't delete taps when instance state is unknown
sjmiller609 e826b23
Review fixes
sjmiller609 6af82cc
add logs
sjmiller609 c92b545
Fix which id
sjmiller609 db6c89f
Reivew fixes
sjmiller609 390d6c6
run cleanup when no vm
sjmiller609 92b2854
Merge branch 'main' into fix-stop-prematurely
sjmiller609 b6c7c37
Move resource id, partial id, name resolution to middleware
sjmiller609 dada46d
Merge remote-tracking branch 'origin/fix-stop-prematurely' into fix-s…
sjmiller609 dfddd92
Fix response code
sjmiller609 0382d44
Extra careful checks
sjmiller609 228f6b1
resource_id instead of id, fix target in ingress to use instance name
sjmiller609 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,14 +12,29 @@ import ( | |
| "github.com/onkernel/hypeman/lib/logger" | ||
| ) | ||
|
|
||
| // LogSource represents a log source type | ||
| type LogSource string | ||
|
|
||
| const ( | ||
| // LogSourceApp is the guest application log (serial console) | ||
| LogSourceApp LogSource = "app" | ||
| // LogSourceVMM is the Cloud Hypervisor VMM log | ||
| LogSourceVMM LogSource = "vmm" | ||
| // LogSourceHypeman is the hypeman operations log | ||
| LogSourceHypeman LogSource = "hypeman" | ||
| ) | ||
|
|
||
| // ErrTailNotFound is returned when the tail command is not available | ||
| var ErrTailNotFound = fmt.Errorf("tail command not found: required for log streaming") | ||
|
|
||
| // StreamInstanceLogs streams instance console logs | ||
| // ErrLogNotFound is returned when the requested log file doesn't exist | ||
| var ErrLogNotFound = fmt.Errorf("log file not found") | ||
sjmiller609 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // streamInstanceLogs streams instance logs from the specified source | ||
| // Returns last N lines, then continues following if follow=true | ||
| func (m *manager) streamInstanceLogs(ctx context.Context, id string, tail int, follow bool) (<-chan string, error) { | ||
| func (m *manager) streamInstanceLogs(ctx context.Context, id string, tail int, follow bool, source LogSource) (<-chan string, error) { | ||
| log := logger.FromContext(ctx) | ||
| log.DebugContext(ctx, "starting log stream", "id", id, "tail", tail, "follow", follow) | ||
| log.DebugContext(ctx, "starting log stream", "id", id, "tail", tail, "follow", follow, "source", source) | ||
|
|
||
| // Verify tail command is available | ||
| if _, err := exec.LookPath("tail"); err != nil { | ||
|
|
@@ -30,7 +45,24 @@ func (m *manager) streamInstanceLogs(ctx context.Context, id string, tail int, f | |
| return nil, err | ||
| } | ||
|
|
||
| logPath := m.paths.InstanceConsoleLog(id) | ||
| // Determine log path based on source | ||
| var logPath string | ||
| switch source { | ||
| case LogSourceApp: | ||
| logPath = m.paths.InstanceAppLog(id) | ||
| case LogSourceVMM: | ||
| logPath = m.paths.InstanceVMMLog(id) | ||
| case LogSourceHypeman: | ||
| logPath = m.paths.InstanceHypemanLog(id) | ||
| default: | ||
| // Default to app log for backwards compatibility | ||
| logPath = m.paths.InstanceAppLog(id) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. enjoy the freedom of not having to care about backwards compatability right now! :) |
||
| } | ||
|
|
||
| // Check if log file exists before starting tail | ||
| if _, err := os.Stat(logPath); os.IsNotExist(err) { | ||
| return nil, ErrLogNotFound | ||
| } | ||
|
|
||
| // Build tail command | ||
| args := []string{"-n", strconv.Itoa(tail)} | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is the fix for stopping a possibly running instance, the rest of the change is VMM and Hypeman logs feature, which was inspired by how this problem was debugged (find issue in CH logs)