Skip to content

Commit

Permalink
Rename variables to have correct capitalization
Browse files Browse the repository at this point in the history
    libcontainer/user/lookup_unix.go:31:6: var-naming: func LookupUid should be LookupUID (revive)
    libcontainer/user/user.go:30:2: var-naming: struct field Uid should be UID (revive)
    libcontainer/user/user.go:214:2: var-naming: struct field Uid should be UID (revive)
    libcontainer/devices/device.go:23:2: var-naming: struct field Uid should be UID (revive)
    libcontainer/configs/cgroup_linux.go:60:2: var-naming: struct field CpuShares should be CPUShares (revive)
    libcontainer/configs/cgroup_linux.go:63:2: var-naming: struct field CpuQuota should be CPUQuota (revive)
    libcontainer/configs/cgroup_linux.go:66:2: var-naming: struct field CpuPeriod should be CPUPeriod (revive)
    libcontainer/configs/cgroup_linux.go:69:2: var-naming: struct field CpuRtRuntime should be CPURtRuntime (revive)
    libcontainer/configs/cgroup_linux.go:72:2: var-naming: struct field CpuRtPeriod should be CPURtPeriod (revive)
    libcontainer/configs/cgroup_linux.go:125:2: var-naming: struct field CpuWeight should be CPUWeight (revive)
    libcontainer/configs/config.go:159:2: var-naming: struct field UidMappings should be UIDMappings (revive)
    libcontainer/cgroups/stats.go:16:6: var-naming: type CpuUsage should be CPUUsage (revive)
    libcontainer/cgroups/stats.go:37:6: var-naming: type CpuStats should be CPUStats (revive)
    libcontainer/cgroups/stats.go:38:2: var-naming: struct field CpuUsage should be CPUUsage (revive)
    libcontainer/cgroups/stats.go:150:2: var-naming: struct field CpuStats should be CPUStats (revive)
    types/events.go:60:6: var-naming: type CpuUsage should be CPUUsage (revive)
    types/events.go:70:6: var-naming: type Cpu should be CPU (revive)
    libcontainer/cgroups/fs/cpu.go:16:6: var-naming: type CpuGroup should be CPUGroup (revive)
    libcontainer/error.go:12:2: var-naming: const IdInUse should be IDInUse (revive)
    libcontainer/error.go:13:2: var-naming: const InvalidIdFormat should be InvalidIDFormat (revive)
    libcontainer/criu_opts_linux.go:20:2: var-naming: struct field TcpEstablished should be TCPEstablished (revive)
    libcontainer/init_linux.go:65:2: var-naming: struct field ContainerId should be ContainerID (revive)

Signed-off-by: Sebastiaan van Stijn <[email protected]>
  • Loading branch information
thaJeztah committed Jul 5, 2021
1 parent 3d153b6 commit 55e210f
Show file tree
Hide file tree
Showing 53 changed files with 437 additions and 437 deletions.
8 changes: 4 additions & 4 deletions checkpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func prepareImagePaths(context *cli.Context) (string, string, error) {
return imagePath, parentPath, nil
}

func setPageServer(context *cli.Context, options *libcontainer.CriuOpts) {
func setPageServer(context *cli.Context, options *libcontainer.CRIUOpts) {
// xxx following criu opts are optional
// The dump image can be sent to a criu page server
if psOpt := context.String("page-server"); psOpt != "" {
Expand All @@ -124,14 +124,14 @@ func setPageServer(context *cli.Context, options *libcontainer.CriuOpts) {
if err != nil {
fatal(errors.New("Invalid port number"))
}
options.PageServer = libcontainer.CriuPageServerInfo{
options.PageServer = libcontainer.CRIUPageServerInfo{
Address: address,
Port: int32(portInt),
}
}
}

func setManageCgroupsMode(context *cli.Context, options *libcontainer.CriuOpts) {
func setManageCgroupsMode(context *cli.Context, options *libcontainer.CRIUOpts) {
if cgOpt := context.String("manage-cgroups-mode"); cgOpt != "" {
switch cgOpt {
case "soft":
Expand All @@ -150,7 +150,7 @@ var namespaceMapping = map[specs.LinuxNamespaceType]int{
specs.NetworkNamespace: unix.CLONE_NEWNET,
}

func setEmptyNsMask(context *cli.Context, options *libcontainer.CriuOpts) error {
func setEmptyNsMask(context *cli.Context, options *libcontainer.CRIUOpts) error {
/* Runc doesn't manage network devices and their configuration */
nsmask := unix.CLONE_NEWNET

Expand Down
24 changes: 12 additions & 12 deletions events.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,18 +119,18 @@ func convertLibcontainerStats(ls *libcontainer.Stats) *types.Stats {
return nil
}
var s types.Stats
s.Pids.Current = cg.PidsStats.Current
s.Pids.Limit = cg.PidsStats.Limit

s.CPU.Usage.Kernel = cg.CpuStats.CpuUsage.UsageInKernelmode
s.CPU.Usage.User = cg.CpuStats.CpuUsage.UsageInUsermode
s.CPU.Usage.Total = cg.CpuStats.CpuUsage.TotalUsage
s.CPU.Usage.Percpu = cg.CpuStats.CpuUsage.PercpuUsage
s.CPU.Usage.PercpuKernel = cg.CpuStats.CpuUsage.PercpuUsageInKernelmode
s.CPU.Usage.PercpuUser = cg.CpuStats.CpuUsage.PercpuUsageInUsermode
s.CPU.Throttling.Periods = cg.CpuStats.ThrottlingData.Periods
s.CPU.Throttling.ThrottledPeriods = cg.CpuStats.ThrottlingData.ThrottledPeriods
s.CPU.Throttling.ThrottledTime = cg.CpuStats.ThrottlingData.ThrottledTime
s.Pids.Current = cg.PIDsStats.Current
s.Pids.Limit = cg.PIDsStats.Limit

s.CPU.Usage.Kernel = cg.CPUStats.CPUUsage.UsageInKernelmode
s.CPU.Usage.User = cg.CPUStats.CPUUsage.UsageInUsermode
s.CPU.Usage.Total = cg.CPUStats.CPUUsage.TotalUsage
s.CPU.Usage.PerCPU = cg.CPUStats.CPUUsage.PerCPUUsage
s.CPU.Usage.PerCPUKernel = cg.CPUStats.CPUUsage.PerCPUUsageInKernelmode
s.CPU.Usage.PerCPUUser = cg.CPUStats.CPUUsage.PerCPUUsageInUsermode
s.CPU.Throttling.Periods = cg.CPUStats.ThrottlingData.Periods
s.CPU.Throttling.ThrottledPeriods = cg.CPUStats.ThrottlingData.ThrottledPeriods
s.CPU.Throttling.ThrottledTime = cg.CPUStats.ThrottlingData.ThrottledTime

s.CPUSet = types.CPUSet(cg.CPUSetStats)

Expand Down
38 changes: 19 additions & 19 deletions libcontainer/cgroups/fs/cpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ import (
"github.com/opencontainers/runc/libcontainer/configs"
)

type CpuGroup struct{}
type CPUGroup struct{}

func (s *CpuGroup) Name() string {
func (s *CPUGroup) Name() string {
return "cpu"
}

func (s *CpuGroup) Apply(path string, d *cgroupData) error {
func (s *CPUGroup) Apply(path string, d *cgroupData) error {
// This might happen if we have no cpu cgroup mounted.
// Just do nothing and don't fail.
if path == "" {
Expand All @@ -39,23 +39,23 @@ func (s *CpuGroup) Apply(path string, d *cgroupData) error {
return cgroups.WriteCgroupProc(path, d.pid)
}

func (s *CpuGroup) SetRtSched(path string, r *configs.Resources) error {
if r.CpuRtPeriod != 0 {
if err := cgroups.WriteFile(path, "cpu.rt_period_us", strconv.FormatUint(r.CpuRtPeriod, 10)); err != nil {
func (s *CPUGroup) SetRtSched(path string, r *configs.Resources) error {
if r.CPURtPeriod != 0 {
if err := cgroups.WriteFile(path, "cpu.rt_period_us", strconv.FormatUint(r.CPURtPeriod, 10)); err != nil {
return err
}
}
if r.CpuRtRuntime != 0 {
if err := cgroups.WriteFile(path, "cpu.rt_runtime_us", strconv.FormatInt(r.CpuRtRuntime, 10)); err != nil {
if r.CPURtRuntime != 0 {
if err := cgroups.WriteFile(path, "cpu.rt_runtime_us", strconv.FormatInt(r.CPURtRuntime, 10)); err != nil {
return err
}
}
return nil
}

func (s *CpuGroup) Set(path string, r *configs.Resources) error {
if r.CpuShares != 0 {
shares := r.CpuShares
func (s *CPUGroup) Set(path string, r *configs.Resources) error {
if r.CPUShares != 0 {
shares := r.CPUShares
if err := cgroups.WriteFile(path, "cpu.shares", strconv.FormatUint(shares, 10)); err != nil {
return err
}
Expand All @@ -71,20 +71,20 @@ func (s *CpuGroup) Set(path string, r *configs.Resources) error {
return fmt.Errorf("the minimum allowed cpu-shares is %d", sharesRead)
}
}
if r.CpuPeriod != 0 {
if err := cgroups.WriteFile(path, "cpu.cfs_period_us", strconv.FormatUint(r.CpuPeriod, 10)); err != nil {
if r.CPUPeriod != 0 {
if err := cgroups.WriteFile(path, "cpu.cfs_period_us", strconv.FormatUint(r.CPUPeriod, 10)); err != nil {
return err
}
}
if r.CpuQuota != 0 {
if err := cgroups.WriteFile(path, "cpu.cfs_quota_us", strconv.FormatInt(r.CpuQuota, 10)); err != nil {
if r.CPUQuota != 0 {
if err := cgroups.WriteFile(path, "cpu.cfs_quota_us", strconv.FormatInt(r.CPUQuota, 10)); err != nil {
return err
}
}
return s.SetRtSched(path, r)
}

func (s *CpuGroup) GetStats(path string, stats *cgroups.Stats) error {
func (s *CPUGroup) GetStats(path string, stats *cgroups.Stats) error {
const file = "cpu.stat"
f, err := cgroups.OpenFile(path, file, os.O_RDONLY)
if err != nil {
Expand All @@ -103,13 +103,13 @@ func (s *CpuGroup) GetStats(path string, stats *cgroups.Stats) error {
}
switch t {
case "nr_periods":
stats.CpuStats.ThrottlingData.Periods = v
stats.CPUStats.ThrottlingData.Periods = v

case "nr_throttled":
stats.CpuStats.ThrottlingData.ThrottledPeriods = v
stats.CPUStats.ThrottlingData.ThrottledPeriods = v

case "throttled_time":
stats.CpuStats.ThrottlingData.ThrottledTime = v
stats.CPUStats.ThrottlingData.ThrottledTime = v
}
}
return nil
Expand Down
28 changes: 14 additions & 14 deletions libcontainer/cgroups/fs/cpu_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ func TestCpuSetShares(t *testing.T) {
"cpu.shares": strconv.Itoa(sharesBefore),
})

helper.CgroupData.config.Resources.CpuShares = sharesAfter
cpu := &CpuGroup{}
helper.CgroupData.config.Resources.CPUShares = sharesAfter
cpu := &CPUGroup{}
if err := cpu.Set(helper.CgroupPath, helper.CgroupData.config.Resources); err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -61,11 +61,11 @@ func TestCpuSetBandWidth(t *testing.T) {
"cpu.rt_period_us": strconv.Itoa(rtPeriodBefore),
})

helper.CgroupData.config.Resources.CpuQuota = quotaAfter
helper.CgroupData.config.Resources.CpuPeriod = periodAfter
helper.CgroupData.config.Resources.CpuRtRuntime = rtRuntimeAfter
helper.CgroupData.config.Resources.CpuRtPeriod = rtPeriodAfter
cpu := &CpuGroup{}
helper.CgroupData.config.Resources.CPUQuota = quotaAfter
helper.CgroupData.config.Resources.CPUPeriod = periodAfter
helper.CgroupData.config.Resources.CPURtRuntime = rtRuntimeAfter
helper.CgroupData.config.Resources.CPURtPeriod = rtPeriodAfter
cpu := &CPUGroup{}
if err := cpu.Set(helper.CgroupPath, helper.CgroupData.config.Resources); err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -119,7 +119,7 @@ func TestCpuStats(t *testing.T) {
"cpu.stat": cpuStatContent,
})

cpu := &CpuGroup{}
cpu := &CPUGroup{}
actualStats := *cgroups.NewStats()
err := cpu.GetStats(helper.CgroupPath, &actualStats)
if err != nil {
Expand All @@ -132,14 +132,14 @@ func TestCpuStats(t *testing.T) {
ThrottledTime: throttledTime,
}

expectThrottlingDataEquals(t, expectedStats, actualStats.CpuStats.ThrottlingData)
expectThrottlingDataEquals(t, expectedStats, actualStats.CPUStats.ThrottlingData)
}

func TestNoCpuStatFile(t *testing.T) {
helper := newCgroupTestUtil("cpu", t)
defer helper.cleanup()

cpu := &CpuGroup{}
cpu := &CPUGroup{}
actualStats := *cgroups.NewStats()
err := cpu.GetStats(helper.CgroupPath, &actualStats)
if err != nil {
Expand All @@ -157,7 +157,7 @@ func TestInvalidCpuStat(t *testing.T) {
"cpu.stat": cpuStatContent,
})

cpu := &CpuGroup{}
cpu := &CPUGroup{}
actualStats := *cgroups.NewStats()
err := cpu.GetStats(helper.CgroupPath, &actualStats)
if err == nil {
Expand All @@ -181,9 +181,9 @@ func TestCpuSetRtSchedAtApply(t *testing.T) {
"cpu.rt_period_us": strconv.Itoa(rtPeriodBefore),
})

helper.CgroupData.config.Resources.CpuRtRuntime = rtRuntimeAfter
helper.CgroupData.config.Resources.CpuRtPeriod = rtPeriodAfter
cpu := &CpuGroup{}
helper.CgroupData.config.Resources.CPURtRuntime = rtRuntimeAfter
helper.CgroupData.config.Resources.CPURtPeriod = rtPeriodAfter
cpu := &CPUGroup{}

helper.CgroupData.pid = 1234
if err := cpu.Apply(helper.CgroupPath, helper.CgroupData); err != nil {
Expand Down
12 changes: 6 additions & 6 deletions libcontainer/cgroups/fs/cpuacct.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ func (s *CpuacctGroup) GetStats(path string, stats *cgroups.Stats) error {
return err
}

stats.CpuStats.CpuUsage.TotalUsage = totalUsage
stats.CpuStats.CpuUsage.PercpuUsage = percpuUsage
stats.CpuStats.CpuUsage.PercpuUsageInKernelmode = percpuUsageInKernelmode
stats.CpuStats.CpuUsage.PercpuUsageInUsermode = percpuUsageInUsermode
stats.CpuStats.CpuUsage.UsageInUsermode = userModeUsage
stats.CpuStats.CpuUsage.UsageInKernelmode = kernelModeUsage
stats.CPUStats.CPUUsage.TotalUsage = totalUsage
stats.CPUStats.CPUUsage.PerCPUUsage = percpuUsage
stats.CPUStats.CPUUsage.PerCPUUsageInKernelmode = percpuUsageInKernelmode
stats.CPUStats.CPUUsage.PerCPUUsageInUsermode = percpuUsageInUsermode
stats.CPUStats.CPUUsage.UsageInUsermode = userModeUsage
stats.CPUStats.CPUUsage.UsageInKernelmode = kernelModeUsage
return nil
}

Expand Down
24 changes: 12 additions & 12 deletions libcontainer/cgroups/fs/cpuacct_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,27 +42,27 @@ func TestCpuacctStats(t *testing.T) {
t.Fatal(err)
}

expectedStats := cgroups.CpuUsage{
expectedStats := cgroups.CPUUsage{
TotalUsage: uint64(12262454190222160),
PercpuUsage: []uint64{
PerCPUUsage: []uint64{
1564936537989058, 1583937096487821, 1604195415465681, 1596445226820187,
1481069084155629, 1478735613864327, 1477610593414743, 1476362015778086,
},
PercpuUsageInKernelmode: []uint64{
PerCPUUsageInKernelmode: []uint64{
637727786389114, 638197595421064, 638956774598358, 637985531181620,
638837766495476, 638763309884944, 640081778921247, 638716766259495,
},
PercpuUsageInUsermode: []uint64{
PerCPUUsageInUsermode: []uint64{
962250696038415, 981956408513304, 1002658817529022, 994937703492523,
874843781648690, 872544369885276, 870104915696359, 870202363887496,
},
UsageInKernelmode: (uint64(291429664) * nanosecondsInSecond) / clockTicks,
UsageInUsermode: (uint64(452278264) * nanosecondsInSecond) / clockTicks,
}

if !reflect.DeepEqual(expectedStats, actualStats.CpuStats.CpuUsage) {
if !reflect.DeepEqual(expectedStats, actualStats.CPUStats.CPUUsage) {
t.Errorf("Expected CPU usage %#v but found %#v\n",
expectedStats, actualStats.CpuStats.CpuUsage)
expectedStats, actualStats.CPUStats.CPUUsage)
}
}

Expand All @@ -82,20 +82,20 @@ func TestCpuacctStatsWithoutUsageAll(t *testing.T) {
t.Fatal(err)
}

expectedStats := cgroups.CpuUsage{
expectedStats := cgroups.CPUUsage{
TotalUsage: uint64(12262454190222160),
PercpuUsage: []uint64{
PerCPUUsage: []uint64{
1564936537989058, 1583937096487821, 1604195415465681, 1596445226820187,
1481069084155629, 1478735613864327, 1477610593414743, 1476362015778086,
},
PercpuUsageInKernelmode: []uint64{},
PercpuUsageInUsermode: []uint64{},
PerCPUUsageInKernelmode: []uint64{},
PerCPUUsageInUsermode: []uint64{},
UsageInKernelmode: (uint64(291429664) * nanosecondsInSecond) / clockTicks,
UsageInUsermode: (uint64(452278264) * nanosecondsInSecond) / clockTicks,
}

if !reflect.DeepEqual(expectedStats, actualStats.CpuStats.CpuUsage) {
if !reflect.DeepEqual(expectedStats, actualStats.CPUStats.CPUUsage) {
t.Errorf("Expected CPU usage %#v but found %#v\n",
expectedStats, actualStats.CpuStats.CpuUsage)
expectedStats, actualStats.CPUStats.CPUUsage)
}
}
8 changes: 4 additions & 4 deletions libcontainer/cgroups/fs/cpuset.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ func (s *CpusetGroup) Apply(path string, d *cgroupData) error {
}

func (s *CpusetGroup) Set(path string, r *configs.Resources) error {
if r.CpusetCpus != "" {
if err := cgroups.WriteFile(path, "cpuset.cpus", r.CpusetCpus); err != nil {
if r.CPUSetCPUs != "" {
if err := cgroups.WriteFile(path, "cpuset.cpus", r.CPUSetCPUs); err != nil {
return err
}
}
if r.CpusetMems != "" {
if err := cgroups.WriteFile(path, "cpuset.mems", r.CpusetMems); err != nil {
if r.CPUSetMems != "" {
if err := cgroups.WriteFile(path, "cpuset.mems", r.CPUSetMems); err != nil {
return err
}
}
Expand Down
4 changes: 2 additions & 2 deletions libcontainer/cgroups/fs/cpuset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func TestCPUSetSetCpus(t *testing.T) {
"cpuset.cpus": cpusBefore,
})

helper.CgroupData.config.Resources.CpusetCpus = cpusAfter
helper.CgroupData.config.Resources.CPUSetCPUs = cpusAfter
cpuset := &CpusetGroup{}
if err := cpuset.Set(helper.CgroupPath, helper.CgroupData.config.Resources); err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -79,7 +79,7 @@ func TestCPUSetSetMems(t *testing.T) {
"cpuset.mems": memsBefore,
})

helper.CgroupData.config.Resources.CpusetMems = memsAfter
helper.CgroupData.config.Resources.CPUSetMems = memsAfter
cpuset := &CpusetGroup{}
if err := cpuset.Set(helper.CgroupPath, helper.CgroupData.config.Resources); err != nil {
t.Fatal(err)
Expand Down
2 changes: 1 addition & 1 deletion libcontainer/cgroups/fs/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var (
&CpusetGroup{},
&DevicesGroup{},
&MemoryGroup{},
&CpuGroup{},
&CPUGroup{},
&CpuacctGroup{},
&PidsGroup{},
&BlkioGroup{},
Expand Down
2 changes: 1 addition & 1 deletion libcontainer/cgroups/fs/fs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func BenchmarkGetStats(b *testing.B) {
b.Fatal(err)
}
}
if st.CpuStats.CpuUsage.TotalUsage != 0 {
if st.CPUStats.CPUUsage.TotalUsage != 0 {
b.Fatalf("stats: %+v", st)
}
}
2 changes: 1 addition & 1 deletion libcontainer/cgroups/fs/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (s *MemoryGroup) Set(path string, r *configs.Resources) error {
}
}

if r.OomKillDisable {
if r.OOMKillDisable {
if err := cgroups.WriteFile(path, "memory.oom_control", "1"); err != nil {
return err
}
Expand Down
Loading

0 comments on commit 55e210f

Please sign in to comment.