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 - build-all
# Define the distribution targets # Define the distribution targets
.dist-amazonlinux1:
variables:
DIST: amazonlinux1
.dist-amazonlinux2: .dist-amazonlinux2:
variables: variables:
DIST: amazonlinux2 DIST: amazonlinux2

View File

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

View File

@ -119,7 +119,6 @@ $(TEST_TARGETS): test-%:
test-packaging: DIST = packaging test-packaging: DIST = packaging
test-packaging: test-packaging:
@echo "Testing package image contents" @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/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/amazonlinux2/x86_64" || echo "Missing amazonlinux2/x86_64"
@$(DOCKER) run --rm $(IMAGE) test -d "/artifacts/packages/centos7/ppc64le" || echo "Missing centos7/ppc64le" @$(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 { if v, ok := section.GetStringFrom(toml, "log-level"); ok {
cfg.Root = v cfg.LogLevel = v
} }
} }
return nil return nil

View File

@ -87,9 +87,18 @@ func TestUpdateFromReader(t *testing.T) {
LogLevel: "info", 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() cfg := getDefaultConfig()
c := tomlConfig{ c := tomlConfig{
@ -108,11 +117,12 @@ func TestUpdateFromReader(t *testing.T) {
err := c.updateFromReader(cfg, reader) err := c.updateFromReader(cfg, reader)
if tc.expectedError { if tc.expectedError {
require.Error(t, err, "%d: %v", i, tc.description) require.Error(t, err)
} else { } 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)
})
} }
} }