Skip to content

Commit

Permalink
fix regression on checking edac folder introduced by wrapping a nil e…
Browse files Browse the repository at this point in the history
…rror
  • Loading branch information
iwilltry42 committed Aug 31, 2021
1 parent 6f76f8c commit 7873805
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pkg/client/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ func ClusterDelete(ctx context.Context, runtime k3drt.Runtime, cluster *k3d.Clus
l.Log().Infof("Deleting cluster '%s'", cluster.Name)
cluster, err := ClusterGet(ctx, runtime, cluster)
if err != nil {
return fmt.Errorf("failed to get cluster %s: %w", cluster.Name, err)
return fmt.Errorf("failed to get cluster: %w", err)
}
l.Log().Debugf("Cluster Details: %+v", cluster)

Expand Down
8 changes: 4 additions & 4 deletions pkg/client/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -465,24 +465,24 @@ func NodeCreate(ctx context.Context, runtime runtimes.Runtime, node *k3d.Node, c
} else {
memory, err := dockerunits.RAMInBytes(node.Memory)
if err != nil {
return fmt.Errorf("Invalid memory limit format: %+v", err)
return fmt.Errorf("invalid memory limit format: %w", err)
}
// mount fake meminfo as readonly
fakemempath, err := util.MakeFakeMeminfo(memory, node.Name)
if err != nil {
return fmt.Errorf("Failed to create fake meminfo: %+v", err)
return fmt.Errorf("failed to create fake meminfo: %w", err)
}
node.Volumes = append(node.Volumes, fmt.Sprintf("%s:%s:ro", fakemempath, util.MemInfoPath))
// mount empty edac folder, but only if it exists
exists, err := docker.CheckIfDirectoryExists(ctx, node.Image, util.EdacFolderPath)
if err != nil {
return fmt.Errorf("Failed to check for the existence of edac folder: %+v", err)
return fmt.Errorf("failed to check for the existence of edac folder: %w", err)
}
if exists {
l.Log().Debugln("Found edac folder")
fakeedacpath, err := util.MakeFakeEdac(node.Name)
if err != nil {
return fmt.Errorf("Failed to create fake edac: %+v", err)
return fmt.Errorf("failed to create fake edac: %w", err)
}
node.Volumes = append(node.Volumes, fmt.Sprintf("%s:%s:ro", fakeedacpath, util.EdacFolderPath))
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/runtimes/docker/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,6 @@ func CheckIfDirectoryExists(ctx context.Context, image string, dir string) (bool
shellCmd := fmt.Sprintf("[ -d \"%s\" ] && exit 0 || exit 1", dir)
cmd := []string{"sh", "-c", shellCmd}
exitCode, err := executeCheckInContainer(ctx, image, cmd)
l.Log().Tracef("check dir container returned %d exist code", exitCode)
return exitCode == 0, fmt.Errorf("error executing check command '%s' in container with image '%s': %w", cmd, image, err)
l.Log().Tracef("check dir container returned %d exit code", exitCode)
return exitCode == 0, err
}

0 comments on commit 7873805

Please sign in to comment.