Skip to content

Commit

Permalink
Call container instance's Close() in container isolation's Close() (c…
Browse files Browse the repository at this point in the history
…irruslabs#769)

* Call container instance's Close() in container isolation's Close()

* Fix linter errors
  • Loading branch information
edigaryev authored Aug 14, 2024
1 parent 8ae0752 commit 6faa293
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion internal/commands/internal/test/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ func logDifferenceIfAny(logger *echelon.Logger, where string, a, b string) *Comp
}

logger.Warnf("Detected difference in %s:", where)
logger.Warnf(dmp.DiffPrettyText(diffs))
logger.Warnf("%s", dmp.DiffPrettyText(diffs))

return &Comparison{
FoundDifference: true,
Expand Down
4 changes: 2 additions & 2 deletions internal/evaluator/evaluator.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ func (r *ConfigurationEvaluatorServiceServer) EvaluateFunction(
result, err := lrk.Hook(ctx, request.StarlarkConfig, request.FunctionName, request.Arguments.AsSlice())
if err != nil {
if errors.Is(err, larker.ErrNotFound) {
return nil, status.Errorf(codes.NotFound, err.Error())
return nil, status.Errorf(codes.NotFound, "%s", err.Error())
}

if ee, ok := err.(*larker.ExtendedError); ok {
Expand All @@ -231,7 +231,7 @@ func (r *ConfigurationEvaluatorServiceServer) EvaluateFunction(
}, nil
}

return nil, status.Errorf(codes.Internal, err.Error())
return nil, status.Errorf(codes.Internal, "%s", err.Error())
}

response := &api.EvaluateFunctionResponse{
Expand Down
2 changes: 1 addition & 1 deletion internal/executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ func (e *Executor) runSingleTask(ctx context.Context, task *build.Task) (err err
task.Timeout)
task.SetStatus(taskstatus.TimedOut)
case errors.Is(err, instance.ErrUnsupportedInstance):
taskLogger.Warnf(err.Error())
taskLogger.Warnf("%s", err.Error())
task.SetStatus(taskstatus.Skipped)
default:
cancel(context.Canceled)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ func (cont *Container) WorkingDirectory(projectDir string, dirtyMode bool) strin
return cont.instance.WorkingDirectory(projectDir, dirtyMode)
}

func (cont *Container) Close(context.Context) error {
func (cont *Container) Close(ctx context.Context) error {
if err := cont.instance.Close(ctx); err != nil {
return err
}

return cont.cleanup()
}
2 changes: 1 addition & 1 deletion internal/executor/instance/prebuilt.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ Outer:
case line := <-logChan:
logger.Infof("%s", line)
case err := <-errChan:
if errors.Is(containerbackend.ErrDone, err) {
if errors.Is(err, containerbackend.ErrDone) {
break Outer
}

Expand Down
7 changes: 2 additions & 5 deletions internal/executor/instance/volume/volume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package volume_test

import (
"context"
"errors"
"fmt"
"github.com/cirruslabs/cirrus-cli/internal/executor/instance/containerbackend"
"github.com/cirruslabs/cirrus-cli/internal/executor/instance/volume"
Expand Down Expand Up @@ -80,10 +79,8 @@ func TestCleanupOnFailure(t *testing.T) {
require.Error(t, err)

err = backend.VolumeInspect(context.Background(), agentVolumeName)
require.Error(t, err)
require.True(t, errors.Is(containerbackend.ErrNotFound, err))
require.ErrorIs(t, err, containerbackend.ErrNotFound)

err = backend.VolumeInspect(context.Background(), workingVolumeName)
require.Error(t, err)
require.True(t, errors.Is(containerbackend.ErrNotFound, err))
require.ErrorIs(t, err, containerbackend.ErrNotFound)
}

0 comments on commit 6faa293

Please sign in to comment.