Skip to content

Commit

Permalink
executor: Expose guest kernel args to log
Browse files Browse the repository at this point in the history
It makes sense to log the guest's kernel args for debugging purposes.

Signed-off-by: Ram Lavi <[email protected]>
  • Loading branch information
RamLavi committed Jan 9, 2024
1 parent ea27364 commit 8bae30c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ build:
-v $(PWD)/_go-cache:/root/.cache/go-build:Z \
--workdir $(PROJECT_WORKING_DIR) \
$(GO_IMAGE_NAME):$(GO_IMAGE_TAG) \
go build -v -o ./bin/kubevirt-realtime-checkup ./cmd/
go build -v -buildvcs=false -o ./bin/kubevirt-realtime-checkup ./cmd/

$(CONTAINER_ENGINE) build . -t $(CHECKUP_IMAGE_NAME):$(CHECKUP_IMAGE_TAG)
.PHONY: build
Expand Down
11 changes: 11 additions & 0 deletions pkg/internal/checkup/executor/console/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,17 @@ func RetValue(retcode string) string {
return "\n" + retcode + CRLF + ".*" + PromptExpression
}

func (e Expecter) GetGuestKernelArgs() (string, error) {
const cmdLineCmd = "cat /proc/cmdline\n"
batch := []expect.Batcher{
&expect.BSnd{S: cmdLineCmd},
&expect.BExp{R: PromptExpression},
}
const printKernelArgsTimeout = 30 * time.Second
resp, err := e.SafeExpectBatchWithResponse(batch, printKernelArgsTimeout)
return resp[0].Output, err
}

// SafeExpectBatchWithResponse runs the batch from `expected`, connecting to a VMI's console and
// waiting for the batch to return with a response until timeout.
// It validates that the commands arrive to the console.
Expand Down
3 changes: 3 additions & 0 deletions pkg/internal/checkup/executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ func (e Executor) Execute(ctx context.Context, vmiUnderTestName string) (status.
return status.Results{}, fmt.Errorf("failed to login to VMI \"%s/%s\": %w", e.namespace, vmiUnderTestName, err)
}

kernelArgs, _ := vmiUnderTestConsoleExpecter.GetGuestKernelArgs()
log.Printf("VMI under test guest kernel Args: %s", kernelArgs)

oslatClient := oslat.NewClient(vmiUnderTestConsoleExpecter, e.OslatDuration)
log.Printf("Running Oslat test on VMI under test for %s...", e.OslatDuration.String())
maxLatency, err := oslatClient.Run(ctx)
Expand Down

0 comments on commit 8bae30c

Please sign in to comment.