Skip to content

Commit

Permalink
fix: check network mode when choosing resolv.conf
Browse files Browse the repository at this point in the history
Host networking can use the host's resolv.conf as-is.
  • Loading branch information
Ka0o0 committed Aug 1, 2024
1 parent bc92b63 commit 6888dc0
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
4 changes: 2 additions & 2 deletions executor/oci/resolvconf.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func GetResolvConf(ctx context.Context, stateDir string, idmap *idtools.Identity
generate = true
}
if !generate {
fiMain, err := os.Stat(resolvconfPath())
fiMain, err := os.Stat(resolvconfPath(netMode))
if err != nil {
if !errors.Is(err, os.ErrNotExist) {
return struct{}{}, err
Expand All @@ -63,7 +63,7 @@ func GetResolvConf(ctx context.Context, stateDir string, idmap *idtools.Identity
return struct{}{}, nil
}

dt, err := os.ReadFile(resolvconfPath())
dt, err := os.ReadFile(resolvconfPath(netMode))
if err != nil && !errors.Is(err, os.ErrNotExist) {
return struct{}{}, err
}
Expand Down
2 changes: 1 addition & 1 deletion executor/oci/resolvconf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func TestResolvConf(t *testing.T) {
t.Cleanup(func() {
resolvconfPath = oldResolvconfPath
})
resolvconfPath = func() string {
resolvconfPath = func(netMode pb.NetMode) string {
if tt.dt == nil {
return "no-such-file"
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6888dc0

Please sign in to comment.