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:
authorSteve Azzopardi <sazzopardi@gitlab.com>2022-09-26 18:06:02 +0300
committerSteve Azzopardi <sazzopardi@gitlab.com>2022-09-27 09:36:00 +0300
commitd3cdd6a567c09f748164e3fa873e57de0d20e8bc (patch)
tree401f78d9402f452ca5ffd553c09f28676489a9ee
parent5ee7c55528f5833aec37ba4a6bfb2b4c3f64dc80 (diff)
Ignore files in process directoryfix/cgroup-logging
What --- Instead of returning error of files in process directory, silently ignore the file found. Why --- `PruneOldGitalyProcessDirectories` is used to delete the cgroup directory under the `hierarchy_root` for example `/gitaly`. Inside the cgroup directory there is always files like `cpu.stat` and much more, so it's normal to have files in a cgroup, it's how they are controlled. In production we are seeing logs below which end up being noise and not really useful: ``` {"error":"gitaly process directory contains an unexpected file","level":"error","msg":"could not prune entry","path":"/sys/fs/cgroup/cpu/gitaly/cpuacct.usage_percpu_user","time":"2022-09-22T22:03:57.874Z"} {"error":"gitaly process directory contains an unexpected file","level":"error","msg":"could not prune entry","path":"/sys/fs/cgroup/cpu/gitaly/cpuacct.usage_sys","time":"2022-09-22T22:03:57.874Z"} {"error":"gitaly process directory contains an unexpected file","level":"error","msg":"could not prune entry","path":"/sys/fs/cgroup/cpu/gitaly/cpuacct.usage_user","time":"2022-09-22T22:03:57.874Z"} {"error":"gitaly process directory contains an unexpected file","level":"error","msg":"could not prune entry","path":"/sys/fs/cgroup/cpu/gitaly/notify_on_release","time":"2022-09-22T22:03:57.874Z"} {"error":"gitaly process directory contains an unexpected file","level":"error","msg":"could not prune entry","path":"/sys/fs/cgroup/cpu/gitaly/tasks","time":"2022-09-22T22:03:57.874Z"} ``` Reference: https://gitlab.com/gitlab-com/gl-infra/reliability/-/issues/16270 Signed-off-by: Steve Azzopardi <sazzopardi@gitlab.com>
-rw-r--r--internal/gitaly/config/temp_dir.go3
-rw-r--r--internal/gitaly/config/temp_dir_test.go8
2 files changed, 4 insertions, 7 deletions
diff --git a/internal/gitaly/config/temp_dir.go b/internal/gitaly/config/temp_dir.go
index d27100edf..96f5eb41f 100644
--- a/internal/gitaly/config/temp_dir.go
+++ b/internal/gitaly/config/temp_dir.go
@@ -26,8 +26,7 @@ func PruneOldGitalyProcessDirectories(log log.FieldLogger, directory string) err
log := log.WithField("path", filepath.Join(directory, entry.Name()))
if err := func() error {
if !entry.IsDir() {
- // There should be no files, only the gitaly process directories.
- return errors.New("gitaly process directory contains an unexpected file")
+ return nil
}
components := strings.Split(entry.Name(), "-")
diff --git a/internal/gitaly/config/temp_dir_test.go b/internal/gitaly/config/temp_dir_test.go
index 9961278ce..2d7076139 100644
--- a/internal/gitaly/config/temp_dir_test.go
+++ b/internal/gitaly/config/temp_dir_test.go
@@ -62,10 +62,8 @@ func TestPruneOldGitalyProcessDirectories(t *testing.T) {
prunableDirs = append(prunableDirs, rootRuntimeDir)
// Create an unexpected file in the runtime directory
- unexpectedFilePath := filepath.Join(baseDir, "unexpected-file")
- require.NoError(t, os.WriteFile(unexpectedFilePath, []byte(""), os.ModePerm))
- expectedLogs[unexpectedFilePath] = "could not prune entry"
- expectedErrs[unexpectedFilePath] = errors.New("gitaly process directory contains an unexpected file")
+ file := filepath.Join(baseDir, "file")
+ require.NoError(t, os.WriteFile(file, []byte(""), os.ModePerm))
nonPrunableDirs := []string{ownRuntimeDir}
@@ -100,7 +98,7 @@ func TestPruneOldGitalyProcessDirectories(t *testing.T) {
require.Equal(t, expectedLogs, actualLogs)
require.Equal(t, expectedErrs, actualErrs)
- require.FileExists(t, unexpectedFilePath)
+ require.FileExists(t, file)
for _, nonPrunableEntry := range nonPrunableDirs {
require.DirExists(t, nonPrunableEntry, nonPrunableEntry)