fix single snapshot
This commit is contained in:
parent
db7687dbce
commit
5090baafda
|
|
@ -318,6 +318,12 @@ func (s *stageBuilder) build() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
initSnapshotTaken := false
|
initSnapshotTaken := false
|
||||||
|
if s.opts.SingleSnapshot {
|
||||||
|
if err := s.initSnapshotWithTimings(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
initSnapshotTaken = true
|
||||||
|
}
|
||||||
|
|
||||||
cacheGroup := errgroup.Group{}
|
cacheGroup := errgroup.Group{}
|
||||||
for index, command := range s.cmds {
|
for index, command := range s.cmds {
|
||||||
|
|
@ -348,14 +354,12 @@ func (s *stageBuilder) build() error {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
if !initSnapshotTaken && !command.ProvidesFilesToSnapshot() {
|
if !initSnapshotTaken && !isCacheCommand && !command.ProvidesFilesToSnapshot() {
|
||||||
// Take initial snapshot if command does not expect to return
|
// Take initial snapshot if command does not expect to return
|
||||||
// a list of files.
|
// a list of files.
|
||||||
t := timing.Start("Initial FS snapshot")
|
if err := s.initSnapshotWithTimings(); err != nil {
|
||||||
if err := s.snapshotter.Init(); err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
timing.DefaultRun.Stop(t)
|
|
||||||
initSnapshotTaken = true
|
initSnapshotTaken = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -423,20 +427,13 @@ func (s *stageBuilder) takeSnapshot(files []string) (string, error) {
|
||||||
return snapshot, err
|
return snapshot, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *stageBuilder) singleSnapshot(index int) bool {
|
func (s *stageBuilder) shouldTakeSnapshot(index int, files []string, provideFiles bool) bool {
|
||||||
isLastCommand := index == len(s.stage.Commands)-1
|
isLastCommand := index == len(s.stage.Commands)-1
|
||||||
|
|
||||||
// We only snapshot the very end with single snapshot mode on.
|
// We only snapshot the very end with single snapshot mode on.
|
||||||
if s.opts.SingleSnapshot {
|
if s.opts.SingleSnapshot {
|
||||||
return isLastCommand
|
return isLastCommand
|
||||||
}
|
}
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *stageBuilder) shouldTakeSnapshot(index int, files []string, provideFiles bool) bool {
|
|
||||||
if s.singleSnapshot(index){
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
// Always take snapshots if we're using the cache.
|
// Always take snapshots if we're using the cache.
|
||||||
if s.opts.Cache {
|
if s.opts.Cache {
|
||||||
|
|
@ -846,3 +843,12 @@ func ResolveCrossStageInstructions(stages []instructions.Stage) map[string]strin
|
||||||
logrus.Debugf("Built stage name to index map: %v", nameToIndex)
|
logrus.Debugf("Built stage name to index map: %v", nameToIndex)
|
||||||
return nameToIndex
|
return nameToIndex
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s stageBuilder) initSnapshotWithTimings() error {
|
||||||
|
t := timing.Start("Initial FS snapshot")
|
||||||
|
if err := s.snapshotter.Init(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
timing.DefaultRun.Stop(t)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue