Skip to content

Commit

Permalink
Improve timeout behavior. (#169)
Browse files Browse the repository at this point in the history
Instead of putting one timeout of 2 sec at the beginning of the check for
the loop devices, use the already existing timeout implementation
inside the loop and just increase the maximum timeout to 60 sec.
This improves the overall behavior, because as soon as the loop
devices are detected, the loop will be exited, but it also increases
the maximum possible time to wait for the loop devices. This is helpful
when being used on slower systems.
  • Loading branch information
thomasmerx authored May 5, 2024
1 parent 9f1aa45 commit 61676eb
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions pkg/builder/step_map_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ func (s *stepMapImage) Run(_ context.Context, state multistep.StateBag) multiste
loop := strings.Split(path, "/")[2]
prefix := loop + "p"

time.Sleep(2 * time.Second)
// Look for all partitions of created loopback
var partitions []string
cPartitions := make(chan []string)
Expand Down Expand Up @@ -95,7 +94,7 @@ func (s *stepMapImage) Run(_ context.Context, state multistep.StateBag) multiste
n_j, _ := strconv.Atoi(partitions[j][len(partPrefix):])
return n_i < n_j
})
case <-time.After(time.Second):
case <-time.After(60*time.Second):
cancel()
}

Expand Down

0 comments on commit 61676eb

Please sign in to comment.