Fix vet errors
Signed-off-by: Alexandr Morozov <lk4d4@docker.com>
This commit is contained in:
parent
ee6f15aabc
commit
7da5ab8130
|
@ -57,7 +57,7 @@ func TestGetCgroupParamsInt(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
} else if value != 0 {
|
||||
t.Fatalf("Expected %d to equal %f", value, 0)
|
||||
t.Fatalf("Expected %d to equal %d", value, 0)
|
||||
}
|
||||
|
||||
// Success with negative values lesser than min int64
|
||||
|
@ -70,7 +70,7 @@ func TestGetCgroupParamsInt(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
} else if value != 0 {
|
||||
t.Fatalf("Expected %d to equal %f", value, 0)
|
||||
t.Fatalf("Expected %d to equal %d", value, 0)
|
||||
}
|
||||
|
||||
// Not a float.
|
||||
|
|
|
@ -43,6 +43,13 @@ var (
|
|||
}
|
||||
)
|
||||
|
||||
func newProp(name string, units interface{}) systemd.Property {
|
||||
return systemd.Property{
|
||||
Name: name,
|
||||
Value: dbus.MakeVariant(units),
|
||||
}
|
||||
}
|
||||
|
||||
func UseSystemd() bool {
|
||||
s, err := os.Stat("/run/systemd/system")
|
||||
if err != nil || !s.IsDir() {
|
||||
|
@ -99,27 +106,27 @@ func Apply(c *cgroups.Cgroup, pid int) (cgroups.ActiveCgroup, error) {
|
|||
}
|
||||
|
||||
properties = append(properties,
|
||||
systemd.Property{"Slice", dbus.MakeVariant(slice)},
|
||||
systemd.Property{"Description", dbus.MakeVariant("docker container " + c.Name)},
|
||||
systemd.Property{"PIDs", dbus.MakeVariant([]uint32{uint32(pid)})},
|
||||
systemd.PropSlice(slice),
|
||||
systemd.PropDescription("docker container "+c.Name),
|
||||
newProp("PIDs", []uint32{uint32(pid)}),
|
||||
)
|
||||
|
||||
// Always enable accounting, this gets us the same behaviour as the fs implementation,
|
||||
// plus the kernel has some problems with joining the memory cgroup at a later time.
|
||||
properties = append(properties,
|
||||
systemd.Property{"MemoryAccounting", dbus.MakeVariant(true)},
|
||||
systemd.Property{"CPUAccounting", dbus.MakeVariant(true)},
|
||||
systemd.Property{"BlockIOAccounting", dbus.MakeVariant(true)})
|
||||
newProp("MemoryAccounting", true),
|
||||
newProp("CPUAccounting", true),
|
||||
newProp("BlockIOAccounting", true))
|
||||
|
||||
if c.Memory != 0 {
|
||||
properties = append(properties,
|
||||
systemd.Property{"MemoryLimit", dbus.MakeVariant(uint64(c.Memory))})
|
||||
newProp("MemoryLimit", uint64(c.Memory)))
|
||||
}
|
||||
// TODO: MemoryReservation and MemorySwap not available in systemd
|
||||
|
||||
if c.CpuShares != 0 {
|
||||
properties = append(properties,
|
||||
systemd.Property{"CPUShares", dbus.MakeVariant(uint64(c.CpuShares))})
|
||||
newProp("CPUShares", uint64(c.CpuShares)))
|
||||
}
|
||||
|
||||
if _, err := theConn.StartTransientUnit(unitName, "replace", properties...); err != nil {
|
||||
|
|
|
@ -116,7 +116,7 @@ func TestNetworkSetMacAddress(t *testing.T) {
|
|||
ifcBeforeSet := readLink(t, tl.name)
|
||||
|
||||
if err := NetworkSetMacAddress(ifcBeforeSet, macaddr); err != nil {
|
||||
t.Fatalf("Could not set %s MAC address on %#v interface: err", macaddr, tl, err)
|
||||
t.Fatalf("Could not set %s MAC address on %#v interface: %s", macaddr, tl, err)
|
||||
}
|
||||
|
||||
ifcAfterSet := readLink(t, tl.name)
|
||||
|
@ -140,7 +140,7 @@ func TestNetworkSetMTU(t *testing.T) {
|
|||
ifcBeforeSet := readLink(t, tl.name)
|
||||
|
||||
if err := NetworkSetMTU(ifcBeforeSet, mtu); err != nil {
|
||||
t.Fatalf("Could not set %d MTU on %#v interface: err", mtu, tl, err)
|
||||
t.Fatalf("Could not set %d MTU on %#v interface: %s", mtu, tl, err)
|
||||
}
|
||||
|
||||
ifcAfterSet := readLink(t, tl.name)
|
||||
|
|
|
@ -42,7 +42,7 @@ func TestSELinux(t *testing.T) {
|
|||
t.Log("getenforce ", selinux.SelinuxGetEnforce())
|
||||
t.Log("getenforcemode ", selinux.SelinuxGetEnforceMode())
|
||||
pid := os.Getpid()
|
||||
t.Log("PID:%d MCS:%s\n", pid, selinux.IntToMcs(pid, 1023))
|
||||
t.Logf("PID:%d MCS:%s\n", pid, selinux.IntToMcs(pid, 1023))
|
||||
err = selinux.Setfscreatecon("unconfined_u:unconfined_r:unconfined_t:s0")
|
||||
if err == nil {
|
||||
t.Log(selinux.Getfscreatecon())
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// +build linux,amd64
|
||||
|
||||
package system
|
||||
|
||||
import (
|
||||
|
|
Loading…
Reference in New Issue