Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pkg/agent/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var Flags AgentCmdFlags
const schemaVersion string = "v2.0.0"

// Run starts the agent process
func Run(cmd *cobra.Command, args []string) error {
func Run(cmd *cobra.Command, args []string) (returnErr error) {
logs.Log.Printf("Preflight agent version: %s (%s)", version.PreflightVersion, version.Commit)
ctx, cancel := context.WithCancel(
klog.NewContext(
Expand Down Expand Up @@ -85,8 +85,8 @@ func Run(cmd *cobra.Command, args []string) error {
defer func() {
cancel()
if groupErr := group.Wait(); groupErr != nil {
err = multierror.Append(
err,
returnErr = multierror.Append(
returnErr,
fmt.Errorf("failed to wait for controller-runtime component to stop: %v", groupErr),
)
}
Expand Down
7 changes: 5 additions & 2 deletions pkg/agent/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,11 @@ func TestRunOneShot(t *testing.T) {
require.NoError(t, err)

logs.Initialize()
Run(c, nil)
klog.Flush()
defer klog.Flush()

runErr := Run(c, nil)
require.NoError(t, runErr, "Run returned an unexpected error")

return
}
t.Log("Running child process")
Expand Down