-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NOTE: all these follow-up commits will be squashed after the review is done. What changed in this commit: - refactor the code to make the dial retry logic be the same across platforms. - a number of code duplication fixes and refactors, raised by @jedevc
- Loading branch information
1 parent
414edfa
commit 4cdae01
Showing
13 changed files
with
299 additions
and
292 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package integration | ||
|
||
func RootlessSupported(uid int) bool { | ||
// not supported on Windows | ||
return false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//go:build !windows | ||
// +build !windows | ||
|
||
package integration | ||
|
||
import ( | ||
"fmt" | ||
"os/exec" | ||
|
||
"github.com/moby/buildkit/util/bklog" | ||
) | ||
|
||
func RootlessSupported(uid int) bool { | ||
cmd := exec.Command("sudo", "-u", fmt.Sprintf("#%d", uid), "-i", "--", "exec", "unshare", "-U", "true") //nolint:gosec // test utility | ||
b, err := cmd.CombinedOutput() | ||
if err != nil { | ||
bklog.L.Warnf("rootless mode is not supported on this host: %v (%s)", err, string(b)) | ||
return false | ||
} | ||
return true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,15 @@ | ||
package integration | ||
|
||
import ( | ||
"os/exec" | ||
"strings" | ||
"time" | ||
"net" | ||
|
||
"github.com/Microsoft/go-winio" | ||
"github.com/pkg/errors" | ||
) | ||
|
||
func waitSocket(address string, d time.Duration, cmd *exec.Cmd) error { | ||
address = strings.TrimPrefix(address, "npipe://") | ||
step := 50 * time.Millisecond | ||
i := 0 | ||
var socketScheme = "npipe://" | ||
|
||
for { | ||
if cmd != nil && cmd.ProcessState != nil { | ||
return errors.Errorf("process exited: %s", cmd.String()) | ||
} | ||
|
||
if conn, err := winio.DialPipe(address, nil); err == nil { | ||
conn.Close() | ||
break | ||
} | ||
i++ | ||
if time.Duration(i)*step > d { | ||
return errors.Errorf("failed dialing: %s", address) | ||
} | ||
time.Sleep(step) | ||
} | ||
return nil | ||
// abstracted function to handle pipe dialing on | ||
// Some simplification has been made to discard timeout param | ||
func dialPipe(address string) (net.Conn, error) { | ||
return winio.DialPipe(address, nil) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.