Skip to content

Commit

Permalink
fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
qiutongs committed Oct 11, 2021
1 parent 30e339b commit a0a7f5f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions container/containerd/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func newContainerdContainerHandler(
handler.image = cntr.Image

if includedMetrics.Has(container.DiskUsageMetrics) && cntr.Labels["io.cri-containerd.kind"] != "sandbox" {
err = handler.fillDiskUsageInfo(client, machineInfoFactory, fsInfo, ctx, cntr.Snapshotter, cntr.SnapshotKey, rootfs, status.LogPath)
err = handler.fillDiskUsageInfo(ctx, client, machineInfoFactory, fsInfo, cntr.Snapshotter, cntr.SnapshotKey, rootfs, status.LogPath)
if err != nil {
klog.Errorf("error occured while filling disk usage info for container %s: %s", name, err)
}
Expand All @@ -202,10 +202,10 @@ func newContainerdContainerHandler(
}

func (h *containerdContainerHandler) fillDiskUsageInfo(
ctx context.Context,
client ContainerdClient,
machineInfoFactory info.MachineInfoFactory,
fsInfo fs.FsInfo,
ctx context.Context,
snapshotter, snapshotKey, rootfs, logPath string) error {
mounts, err := client.SnapshotMounts(ctx, snapshotter, snapshotKey)
if err != nil {
Expand Down
38 changes: 19 additions & 19 deletions container/containerd/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ import (
)

const (
testContainerSandboxID = "40af7cdcbe507acad47a5a62025743ad3ddc6ab93b77b21363aa1c1d641047c9"
testContainerSandboxName = "/kubepods/pod068e8fa0-9213-11e7-a01f-507b9d4141fa/40af7cdcbe507acad47a5a62025743ad3ddc6ab93b77b21363aa1c1d641047c9"
testContainerId = "c6a1aa99f14d3e57417e145b897e34961145f6b6f14216a176a34bfabbf79086"
testContainerID = "c6a1aa99f14d3e57417e145b897e34961145f6b6f14216a176a34bfabbf79086"
testContainerName = "/kubepods/pod068e8fa0-9213-11e7-a01f-507b9d4141fa/c6a1aa99f14d3e57417e145b897e34961145f6b6f14216a176a34bfabbf79086"

testLogPath = "/var/log/pods/pod068e8fa0-9213-11e7-a01f-507b9d4141fa"
Expand Down Expand Up @@ -114,11 +115,10 @@ type fsInfoMock struct {
}

func (m *fsInfoMock) GetDirFsDevice(dir string) (*fs.DeviceInfo, error) {
if dir == m.deviceDir {
return m.deviceinfo, nil
} else {
if dir != m.deviceDir {
return nil, fmt.Errorf("cannot get device for dir: %q", dir)
}
return m.deviceinfo, nil
}

func (m *fsInfoMock) GetGlobalFsInfo() ([]fs.Fs, error) {
Expand Down Expand Up @@ -173,21 +173,21 @@ func TestHandler(t *testing.T) {
for _, ts := range []testCase{
{
mockcontainerdClient(nil, nil, nil, nil, nil),
"/kubepods/pod068e8fa0-9213-11e7-a01f-507b9d4141fa/40af7cdcbe507acad47a5a62025743ad3ddc6ab93b77b21363aa1c1d641047c9",
testContainerSandboxName,
nil,
nil,
&containerlibcontainer.CgroupSubsystems{},
false,
nil,
nil,
true,
"unable to find container \"40af7cdcbe507acad47a5a62025743ad3ddc6ab93b77b21363aa1c1d641047c9\"",
"unable to find container \"" + testContainerSandboxID + "\"",
nil,
nil,
},
{
mockcontainerdClient(testContainers, nil, nil, nil, nil),
"/kubepods/pod068e8fa0-9213-11e7-a01f-507b9d4141fa/40af7cdcbe507acad47a5a62025743ad3ddc6ab93b77b21363aa1c1d641047c9",
testContainerSandboxName,
&mockedMachineInfo{},
nil,
&containerlibcontainer.CgroupSubsystems{},
Expand All @@ -197,16 +197,16 @@ func TestHandler(t *testing.T) {
false,
"",
&info.ContainerReference{
Id: "40af7cdcbe507acad47a5a62025743ad3ddc6ab93b77b21363aa1c1d641047c9",
Name: "/kubepods/pod068e8fa0-9213-11e7-a01f-507b9d4141fa/40af7cdcbe507acad47a5a62025743ad3ddc6ab93b77b21363aa1c1d641047c9",
Aliases: []string{"k8s_POD_some-pod_some-ns_some-uid_0", "40af7cdcbe507acad47a5a62025743ad3ddc6ab93b77b21363aa1c1d641047c9", "/kubepods/pod068e8fa0-9213-11e7-a01f-507b9d4141fa/40af7cdcbe507acad47a5a62025743ad3ddc6ab93b77b21363aa1c1d641047c9"},
Id: testContainerSandboxID,
Name: testContainerSandboxName,
Aliases: []string{"k8s_POD_some-pod_some-ns_some-uid_0", testContainerSandboxID, testContainerSandboxName},
Namespace: k8sContainerdNamespace,
},
map[string]string{},
},
{
mockcontainerdClient(testContainers, nil, nil, nil, nil),
"/kubepods/pod068e8fa0-9213-11e7-a01f-507b9d4141fa/40af7cdcbe507acad47a5a62025743ad3ddc6ab93b77b21363aa1c1d641047c9",
testContainerSandboxName,
&mockedMachineInfo{},
nil,
&containerlibcontainer.CgroupSubsystems{},
Expand All @@ -216,9 +216,9 @@ func TestHandler(t *testing.T) {
false,
"",
&info.ContainerReference{
Id: "40af7cdcbe507acad47a5a62025743ad3ddc6ab93b77b21363aa1c1d641047c9",
Name: "/kubepods/pod068e8fa0-9213-11e7-a01f-507b9d4141fa/40af7cdcbe507acad47a5a62025743ad3ddc6ab93b77b21363aa1c1d641047c9",
Aliases: []string{"k8s_POD_some-pod_some-ns_some-uid_0", "40af7cdcbe507acad47a5a62025743ad3ddc6ab93b77b21363aa1c1d641047c9", "/kubepods/pod068e8fa0-9213-11e7-a01f-507b9d4141fa/40af7cdcbe507acad47a5a62025743ad3ddc6ab93b77b21363aa1c1d641047c9"},
Id: testContainerSandboxID,
Name: testContainerSandboxName,
Aliases: []string{"k8s_POD_some-pod_some-ns_some-uid_0", testContainerSandboxID, testContainerSandboxName},
Namespace: k8sContainerdNamespace,
},
map[string]string{"TEST_REGION": "FRA", "TEST_ZONE": "A"},
Expand All @@ -235,9 +235,9 @@ func TestHandler(t *testing.T) {
false,
"",
&info.ContainerReference{
Id: "c6a1aa99f14d3e57417e145b897e34961145f6b6f14216a176a34bfabbf79086",
Name: "/kubepods/pod068e8fa0-9213-11e7-a01f-507b9d4141fa/c6a1aa99f14d3e57417e145b897e34961145f6b6f14216a176a34bfabbf79086",
Aliases: []string{"k8s_some-container_some-pod_some-ns_some-uid_2", "c6a1aa99f14d3e57417e145b897e34961145f6b6f14216a176a34bfabbf79086", "/kubepods/pod068e8fa0-9213-11e7-a01f-507b9d4141fa/c6a1aa99f14d3e57417e145b897e34961145f6b6f14216a176a34bfabbf79086"},
Id: testContainerID,
Name: testContainerName,
Aliases: []string{"k8s_some-container_some-pod_some-ns_some-uid_2", testContainerID, testContainerName},
Namespace: k8sContainerdNamespace,
},
map[string]string{},
Expand Down Expand Up @@ -298,7 +298,7 @@ func TestHandlerDiskUssage(t *testing.T) {
{
Device: "/dev/sda",
Capacity: 100,
Inodes: 10,
Inodes: testInodesTotal,
Type: "fake type",
},
},
Expand Down Expand Up @@ -366,7 +366,7 @@ func TestUsageProvider(t *testing.T) {
} {
up := fsUsageProvider{
ctx: context.Background(),
containerID: testContainerId,
containerID: testContainerID,
client: ts.client,
fsInfo: ts.fsInfo,
logPath: testLogPath,
Expand Down

0 comments on commit a0a7f5f

Please sign in to comment.