Merge branch 'fix-log-level' into 'experimental'

Correctly set log-level from config.toml

See merge request nvidia/container-toolkit/container-toolkit!94
This commit is contained in:
Evan Lezar 2022-01-14 12:08:45 +00:00
commit ce2b0dfdf0
5 changed files with 32 additions and 34 deletions

View File

@ -35,10 +35,6 @@ stages:
- build-all
# Define the distribution targets
.dist-amazonlinux1:
variables:
DIST: amazonlinux1
.dist-amazonlinux2:
variables:
DIST: amazonlinux2

View File

@ -103,12 +103,6 @@ unit-tests:
- ${ARTIFACTS_ROOT}
# Define the package build targets
package-amazonlinux1-x86_64:
extends:
- .package-build
- .dist-amazonlinux1
- .arch-x86_64
package-amazonlinux2-aarch64:
extends:
- .package-build
@ -259,7 +253,6 @@ image-packaging:
- .package-artifacts
- .dist-packaging
needs:
- package-amazonlinux1-x86_64
- package-amazonlinux2-aarch64
- package-amazonlinux2-x86_64
- package-centos7-ppc64le

View File

@ -119,7 +119,6 @@ $(TEST_TARGETS): test-%:
test-packaging: DIST = packaging
test-packaging:
@echo "Testing package image contents"
@$(DOCKER) run --rm $(IMAGE) test -d "/artifacts/packages/amazonlinux1/x86_64" || echo "Missing amazonlinux1/x86_64"
@$(DOCKER) run --rm $(IMAGE) test -d "/artifacts/packages/amazonlinux2/aarch64" || echo "Missing amazonlinux2/aarch64"
@$(DOCKER) run --rm $(IMAGE) test -d "/artifacts/packages/amazonlinux2/x86_64" || echo "Missing amazonlinux2/x86_64"
@$(DOCKER) run --rm $(IMAGE) test -d "/artifacts/packages/centos7/ppc64le" || echo "Missing centos7/ppc64le"

View File

@ -117,7 +117,7 @@ func (c tomlConfig) updateFromReader(cfg *Config, reader io.Reader) error {
}
if v, ok := section.GetStringFrom(toml, "log-level"); ok {
cfg.Root = v
cfg.LogLevel = v
}
}
return nil

View File

@ -87,9 +87,18 @@ func TestUpdateFromReader(t *testing.T) {
LogLevel: "info",
},
},
{
description: "log-level is set",
lines: []string{"nvidia-container-runtime.log-level=\"trace\""},
expected: &Config{
DebugFilePath: "/dev/null",
LogLevel: "trace",
},
},
}
for i, tc := range testCases {
for _, tc := range testCases {
t.Run(tc.description, func(t *testing.T) {
cfg := getDefaultConfig()
c := tomlConfig{
@ -108,11 +117,12 @@ func TestUpdateFromReader(t *testing.T) {
err := c.updateFromReader(cfg, reader)
if tc.expectedError {
require.Error(t, err, "%d: %v", i, tc.description)
require.Error(t, err)
} else {
require.NoError(t, err, "%d: %v", i, tc.description)
require.NoError(t, err)
}
require.EqualValues(t, tc.expected, cfg, "%d: %v", i, tc.description)
require.EqualValues(t, tc.expected, cfg)
})
}
}