diff --git a/pkg/commands/run_marker.go b/pkg/commands/run_marker.go index a27b520a1..8d67160bf 100644 --- a/pkg/commands/run_marker.go +++ b/pkg/commands/run_marker.go @@ -20,6 +20,7 @@ import ( "fmt" "io/ioutil" "os" + "time" "github.com/GoogleContainerTools/kaniko/pkg/dockerfile" "github.com/GoogleContainerTools/kaniko/pkg/util" @@ -48,6 +49,8 @@ func (r *RunMarkerCommand) ExecuteCommand(config *v1.Config, buildArgs *dockerfi if err != nil { return fmt.Errorf("could not place a marker file") } + // introduce a delay + time.Sleep(time.Second) if err := runCommandInExec(config, buildArgs, r.cmd); err != nil { return err } diff --git a/pkg/executor/build.go b/pkg/executor/build.go index 799b40ee9..38d6471a5 100644 --- a/pkg/executor/build.go +++ b/pkg/executor/build.go @@ -372,7 +372,7 @@ func (s *stageBuilder) build() error { files = command.FilesToSnapshot() timing.DefaultRun.Stop(t) - if !s.shouldTakeSnapshot(index, files, command.MetadataOnly()) { + if !s.shouldTakeSnapshot(index, command.MetadataOnly()) { continue } if isCacheCommand { @@ -432,7 +432,7 @@ func (s *stageBuilder) takeSnapshot(files []string, shdDelete bool) (string, err return snapshot, err } -func (s *stageBuilder) shouldTakeSnapshot(index int, files []string, isMetadatCmd bool) bool { +func (s *stageBuilder) shouldTakeSnapshot(index int, isMetadatCmd bool) bool { isLastCommand := index == len(s.cmds)-1 // We only snapshot the very end with single snapshot mode on. diff --git a/pkg/executor/build_test.go b/pkg/executor/build_test.go index f34d2fcc6..00631ccca 100644 --- a/pkg/executor/build_test.go +++ b/pkg/executor/build_test.go @@ -104,7 +104,6 @@ func Test_stageBuilder_shouldTakeSnapshot(t *testing.T) { } type args struct { index int - files []string metadataOnly bool } tests := []struct { @@ -159,7 +158,6 @@ func Test_stageBuilder_shouldTakeSnapshot(t *testing.T) { }, args: args{ index: 0, - files: []string{}, metadataOnly: true, }, want: false, @@ -173,7 +171,6 @@ func Test_stageBuilder_shouldTakeSnapshot(t *testing.T) { }, args: args{ index: 0, - files: nil, metadataOnly: false, }, want: true, @@ -204,7 +201,7 @@ func Test_stageBuilder_shouldTakeSnapshot(t *testing.T) { opts: tt.fields.opts, cmds: tt.fields.cmds, } - if got := s.shouldTakeSnapshot(tt.args.index, tt.args.files, tt.args.metadataOnly); got != tt.want { + if got := s.shouldTakeSnapshot(tt.args.index, tt.args.metadataOnly); got != tt.want { t.Errorf("stageBuilder.shouldTakeSnapshot() = %v, want %v", got, tt.want) } })