Skip to content

Commit

Permalink
Test with extra checks
Browse files Browse the repository at this point in the history
  • Loading branch information
nwneisen committed Aug 9, 2023
1 parent 85bf6c4 commit d79b338
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions core/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,20 @@ func (ds *dockerService) createCRIFormattedContainerLog(containerID string) erro
return fmt.Errorf("failed to get container %q log path: %v", containerID, err)
}

if kubePath == "" {
logrus.Debugf("Container log path for Container ID %s isn't specified, will not create kubepath", containerID)
return nil
}

logrus.Infof("Creating CRI formatted container log at %s", kubePath)

go func() {
_, err = os.Create(kubePath)
if err != nil {
logrus.Infof("Failed to create kube log file %s: %v", kubePath, err)
panic(err)
}

// Open the kube file for output
kubeFile, err := os.OpenFile(kubePath, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0600)
if err != nil {
Expand All @@ -245,12 +256,11 @@ func (ds *dockerService) createCRIFormattedContainerLog(containerID string) erro
defer kubeFile.Close()

// Make sure the docker file exists
dockerFile, err := os.Create(dockerPath)
_, err = os.Create(dockerPath)
if err != nil {
logrus.Infof("Failed to create docker log file %s: %v", dockerPath, err)
panic(err)
}
defer dockerFile.Close()

// Tail the docker file for input
t, err := tail.TailFile(dockerPath, tail.Config{
Expand Down

0 comments on commit d79b338

Please sign in to comment.