Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavlo Strokov <pstrokov@gitlab.com>2021-09-07 12:54:41 +0300
committerPavlo Strokov <pstrokov@gitlab.com>2021-09-13 13:17:17 +0300
commitcd233499f2b544cd4fbc10069ded5d9a199781f6 (patch)
tree700a1806cb54c2daca437344373341fafb4868ab
parent543ff0753916df40499284d3c24dcdd295d4b497 (diff)
config: validateCgroups refactored
The validateCgroups refactored to point to the exact configuration settings that are not valid in the error message. The tests were extended with 'name' where it was not set.
-rw-r--r--internal/gitaly/config/config.go8
-rw-r--r--internal/gitaly/config/config_test.go15
2 files changed, 14 insertions, 9 deletions
diff --git a/internal/gitaly/config/config.go b/internal/gitaly/config/config.go
index dd4671ffa..e81e6c99e 100644
--- a/internal/gitaly/config/config.go
+++ b/internal/gitaly/config/config.go
@@ -557,19 +557,19 @@ func (cfg *Cfg) validateCgroups() error {
}
if cg.Mountpoint == "" {
- return fmt.Errorf("cgroups mountpoint cannot be empty")
+ return fmt.Errorf("cgroups.mountpoint: cannot be empty")
}
if cg.HierarchyRoot == "" {
- return fmt.Errorf("cgroups hierarchy root cannot be empty")
+ return fmt.Errorf("cgroups.hierarchy_root: cannot be empty")
}
if cg.CPU.Enabled && cg.CPU.Shares == 0 {
- return fmt.Errorf("cgroups CPU shares has to be greater than zero")
+ return fmt.Errorf("cgroups.cpu.shares: has to be greater than zero")
}
if cg.Memory.Enabled && (cg.Memory.Limit == 0 || cg.Memory.Limit < -1) {
- return fmt.Errorf("cgroups memory limit has to be greater than zero or equal to -1")
+ return fmt.Errorf("cgroups.memory.limit: has to be greater than zero or equal to -1")
}
return nil
diff --git a/internal/gitaly/config/config_test.go b/internal/gitaly/config/config_test.go
index bee2662c0..754a1a97f 100644
--- a/internal/gitaly/config/config_test.go
+++ b/internal/gitaly/config/config_test.go
@@ -993,6 +993,7 @@ func TestValidateCgroups(t *testing.T) {
},
},
{
+ name: "empty mount point",
rawCfg: `[cgroups]
count = 10
mountpoint = ""`,
@@ -1000,9 +1001,10 @@ func TestValidateCgroups(t *testing.T) {
Count: 10,
Mountpoint: "",
},
- validateErr: errors.New("cgroups mountpoint cannot be empty"),
+ validateErr: errors.New("cgroups.mountpoint: cannot be empty"),
},
{
+ name: "empty hierarchy_root",
rawCfg: `[cgroups]
count = 10
mountpoint = "/sys/fs/cgroup"
@@ -1012,9 +1014,10 @@ func TestValidateCgroups(t *testing.T) {
Mountpoint: "/sys/fs/cgroup",
HierarchyRoot: "",
},
- validateErr: errors.New("cgroups hierarchy root cannot be empty"),
+ validateErr: errors.New("cgroups.hierarchy_root: cannot be empty"),
},
{
+ name: "invalid cpu shares",
rawCfg: `[cgroups]
count = 10
mountpoint = "/sys/fs/cgroup"
@@ -1031,9 +1034,10 @@ func TestValidateCgroups(t *testing.T) {
Shares: 0,
},
},
- validateErr: errors.New("cgroups CPU shares has to be greater than zero"),
+ validateErr: errors.New("cgroups.cpu.shares: has to be greater than zero"),
},
{
+ name: "invalid memory limit - zero",
rawCfg: `[cgroups]
count = 10
mountpoint = "/sys/fs/cgroup"
@@ -1050,9 +1054,10 @@ func TestValidateCgroups(t *testing.T) {
Limit: 0,
},
},
- validateErr: errors.New("cgroups memory limit has to be greater than zero or equal to -1"),
+ validateErr: errors.New("cgroups.memory.limit: has to be greater than zero or equal to -1"),
},
{
+ name: "invalid memory limit - negative",
rawCfg: `[cgroups]
count = 10
mountpoint = "/sys/fs/cgroup"
@@ -1069,7 +1074,7 @@ func TestValidateCgroups(t *testing.T) {
Limit: -5,
},
},
- validateErr: errors.New("cgroups memory limit has to be greater than zero or equal to -1"),
+ validateErr: errors.New("cgroups.memory.limit: has to be greater than zero or equal to -1"),
},
} {
t.Run(tt.name, func(t *testing.T) {