Skip to content
This repository has been archived by the owner on Feb 7, 2024. It is now read-only.

Commit

Permalink
builder: try own copy of tar if the one on the path fails
Browse files Browse the repository at this point in the history
Enables dgr to work on hosts that don't have any tar. (See also #217.)
  • Loading branch information
mark-kubacki committed Mar 13, 2017
1 parent 215f498 commit 74813d0
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions aci-builder/bin-run/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,22 @@ func (b *Builder) tarAci() error {

logs.WithF(b.fields).Debug("Calling tar to collect all files")
if err := common.ExecCmd("tar", params...); err != nil {
logs.WithFields(b.fields).WithField("params", params).Error("Parameters to 'tar' within the builder")
return errs.WithEF(err, b.fields, "Failed to tar aci")
// In case the host's tar is too old, try the builder's if it exists.
stage1Tar := rktcommon.Stage1RootfsPath(b.pod.Root)
var buildersTar string
for _, t := range []string{"/dgr/usr/bin/tar", "/bin/tar", "/usr/bin/tar"} {
buildersTar = filepath.Join(stage1Tar, t)
if _, err := os.Stat(buildersTar); err == nil {
break
}
}

if err2 := common.ExecCmd(buildersTar, params...); err2 != nil {
// If that failed, output the original error nevertheless.
logs.WithFields(b.fields).WithField("params", params).Error("Parameters to 'tar' within the builder")
return errs.WithEF(err, b.fields, "Failed to tar aci")
}
logs.WithF(b.fields).Debug("Had to resort to 'tar' from the builder to create the aci file")
}
// common.ExecCmd sometimes silently fails, hence the redundant check.
if _, err := os.Stat(destination); os.IsNotExist(err) {
Expand Down

0 comments on commit 74813d0

Please sign in to comment.