intoduce delay

This commit is contained in:
Tejal Desai 2020-06-06 20:52:58 -07:00
parent 07cdfcf091
commit 98a2ee2e34
3 changed files with 6 additions and 6 deletions

View File

@ -20,6 +20,7 @@ import (
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"os" "os"
"time"
"github.com/GoogleContainerTools/kaniko/pkg/dockerfile" "github.com/GoogleContainerTools/kaniko/pkg/dockerfile"
"github.com/GoogleContainerTools/kaniko/pkg/util" "github.com/GoogleContainerTools/kaniko/pkg/util"
@ -48,6 +49,8 @@ func (r *RunMarkerCommand) ExecuteCommand(config *v1.Config, buildArgs *dockerfi
if err != nil { if err != nil {
return fmt.Errorf("could not place a marker file") 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 { if err := runCommandInExec(config, buildArgs, r.cmd); err != nil {
return err return err
} }

View File

@ -372,7 +372,7 @@ func (s *stageBuilder) build() error {
files = command.FilesToSnapshot() files = command.FilesToSnapshot()
timing.DefaultRun.Stop(t) timing.DefaultRun.Stop(t)
if !s.shouldTakeSnapshot(index, files, command.MetadataOnly()) { if !s.shouldTakeSnapshot(index, command.MetadataOnly()) {
continue continue
} }
if isCacheCommand { if isCacheCommand {
@ -432,7 +432,7 @@ func (s *stageBuilder) takeSnapshot(files []string, shdDelete bool) (string, err
return snapshot, 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 isLastCommand := index == len(s.cmds)-1
// We only snapshot the very end with single snapshot mode on. // We only snapshot the very end with single snapshot mode on.

View File

@ -104,7 +104,6 @@ func Test_stageBuilder_shouldTakeSnapshot(t *testing.T) {
} }
type args struct { type args struct {
index int index int
files []string
metadataOnly bool metadataOnly bool
} }
tests := []struct { tests := []struct {
@ -159,7 +158,6 @@ func Test_stageBuilder_shouldTakeSnapshot(t *testing.T) {
}, },
args: args{ args: args{
index: 0, index: 0,
files: []string{},
metadataOnly: true, metadataOnly: true,
}, },
want: false, want: false,
@ -173,7 +171,6 @@ func Test_stageBuilder_shouldTakeSnapshot(t *testing.T) {
}, },
args: args{ args: args{
index: 0, index: 0,
files: nil,
metadataOnly: false, metadataOnly: false,
}, },
want: true, want: true,
@ -204,7 +201,7 @@ func Test_stageBuilder_shouldTakeSnapshot(t *testing.T) {
opts: tt.fields.opts, opts: tt.fields.opts,
cmds: tt.fields.cmds, 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) t.Errorf("stageBuilder.shouldTakeSnapshot() = %v, want %v", got, tt.want)
} }
}) })