Skip to content
This repository was archived by the owner on May 12, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ See the

## Architecture overview

See the [architecture overview](https://github.com/kata-containers/documentation/blob/master/architecture.md)
See the [architecture overview](https://github.com/kata-containers/documentation/blob/master/design/architecture.md)
for details on the Kata Containers design.

## Configuration
Expand Down
1 change: 1 addition & 0 deletions cli/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ var initFactoryCommand = cli.Command{
HypervisorConfig: runtimeConfig.HypervisorConfig,
AgentType: runtimeConfig.AgentType,
AgentConfig: runtimeConfig.AgentConfig,
ProxyType: runtimeConfig.ProxyType,
},
}
kataLog.WithField("factory", factoryConfig).Info("create vm factory")
Expand Down
7 changes: 7 additions & 0 deletions cli/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import (
vc "github.com/kata-containers/runtime/virtcontainers"
)

const testDisabledAsNonRoot = "Test disabled as requires root privileges"

func TestFactoryCLIFunctionNoRuntimeConfig(t *testing.T) {
assert := assert.New(t)

Expand Down Expand Up @@ -63,9 +65,14 @@ func TestFactoryCLIFunctionInit(t *testing.T) {
assert.Nil(err)

// With template
if os.Geteuid() != 0 {
t.Skip(testDisabledAsNonRoot)
}

runtimeConfig.FactoryConfig.Template = true
runtimeConfig.HypervisorType = vc.MockHypervisor
runtimeConfig.AgentType = vc.NoopAgentType
runtimeConfig.ProxyType = vc.NoopProxyType
ctx.App.Metadata["runtimeConfig"] = runtimeConfig
fn, ok = initFactoryCommand.Action.(func(context *cli.Context) error)
assert.True(ok)
Expand Down
16 changes: 11 additions & 5 deletions pkg/katautils/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,12 +357,13 @@ func (h hypervisor) getInitrdAndImage() (initrd string, image string, err error)
return
}

func (p proxy) path() string {
if p.Path == "" {
return defaultProxyPath
func (p proxy) path() (string, error) {
path := p.Path
if path == "" {
path = defaultProxyPath
}

return p.Path
return ResolvePath(path)
}

func (p proxy) debug() bool {
Expand Down Expand Up @@ -606,8 +607,13 @@ func updateRuntimeConfigProxy(configPath string, tomlConf tomlConfig, config *oc
config.ProxyType = vc.KataProxyType
}

path, err := proxy.path()
if err != nil {
return err
}

config.ProxyConfig = vc.ProxyConfig{
Path: proxy.path(),
Path: path,
Debug: proxy.debug(),
}
}
Expand Down
38 changes: 34 additions & 4 deletions pkg/katautils/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1122,13 +1122,43 @@ func TestHypervisorDefaultsGuestHookPath(t *testing.T) {
}

func TestProxyDefaults(t *testing.T) {
assert := assert.New(t)

tmpdir, err := ioutil.TempDir(testDir, "")
assert.NoError(err)
defer os.RemoveAll(tmpdir)

testProxyPath := filepath.Join(tmpdir, "proxy")
testProxyLinkPath := filepath.Join(tmpdir, "proxy-link")

err = createEmptyFile(testProxyPath)
assert.NoError(err)

err = syscall.Symlink(testProxyPath, testProxyLinkPath)
assert.NoError(err)

savedProxyPath := defaultProxyPath

defer func() {
defaultProxyPath = savedProxyPath
}()

defaultProxyPath = testProxyPath
p := proxy{}
path, err := p.path()
assert.NoError(err)
assert.Equal(path, defaultProxyPath, "default proxy path wrong")

assert.Equal(t, p.path(), defaultProxyPath, "default proxy path wrong")
// test path resolution
defaultProxyPath = testProxyLinkPath
p = proxy{}
path, err = p.path()
assert.NoError(err)
assert.Equal(path, testProxyPath)

path := "/foo/bar/baz/proxy"
p.Path = path
assert.Equal(t, p.path(), path, "custom proxy path wrong")
assert.False(p.debug())
p.Debug = true
assert.True(p.debug())
}

func TestShimDefaults(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion virtcontainers/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func createSandboxFromConfig(ctx context.Context, sandboxConfig SandboxConfig, f
}
}()

if err := s.getAndStoreGuestDetails(); err != nil {
if err = s.getAndStoreGuestDetails(); err != nil {
return nil, err
}

Expand Down
Loading