Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cgroup logging with slog #203

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open

cgroup logging with slog #203

wants to merge 13 commits into from

Conversation

ikengn
Copy link

@ikengn ikengn commented Nov 8, 2023

No description provided.

@ikengn ikengn closed this Nov 15, 2023
@ikengn ikengn reopened this Nov 15, 2023
@ikengn ikengn marked this pull request as ready for review November 15, 2023 03:47
@tylerharter tylerharter changed the title First test cgroup logging with slog Nov 15, 2023
Copy link
Member

@tylerharter tylerharter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great first pass!

src/worker/helpers.go Outdated Show resolved Hide resolved
src/common/config.go Outdated Show resolved Hide resolved
src/common/config.go Outdated Show resolved Hide resolved
src/common/config.go Outdated Show resolved Hide resolved
src/worker/helpers.go Outdated Show resolved Hide resolved
src/worker/sandbox/cgroups/cgroup.go Outdated Show resolved Hide resolved
src/worker/sandbox/cgroups/cgroup.go Outdated Show resolved Hide resolved
src/worker/sandbox/cgroups/cgroup.go Outdated Show resolved Hide resolved
src/worker/sandbox/cgroups/cgroup.go Outdated Show resolved Hide resolved
src/worker/server/server.go Outdated Show resolved Hide resolved
@ikengn ikengn closed this Dec 6, 2023
@ikengn ikengn reopened this Dec 6, 2023
src/common/config.go Outdated Show resolved Hide resolved
src/common/config.go Outdated Show resolved Hide resolved
src/common/config.go Outdated Show resolved Hide resolved
src/common/config.go Outdated Show resolved Hide resolved
src/common/config.go Outdated Show resolved Hide resolved
src/worker/sandbox/cgroups/pool.go Outdated Show resolved Hide resolved
src/worker/sandbox/cgroups/pool.go Outdated Show resolved Hide resolved
src/worker/sandbox/cgroups/pool.go Outdated Show resolved Hide resolved
src/worker/sandbox/sock.go Show resolved Hide resolved
src/worker/server/server.go Outdated Show resolved Hide resolved
src/common/config.go Outdated Show resolved Hide resolved
Copy link
Member

@tylerharter tylerharter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good progress!

src/common/logger.go Outdated Show resolved Hide resolved
func LoadLoggers() error {
if Conf.Trace.Enable_JSON == true {
level := new(slog.LevelVar)
if Conf.Trace.Cgroups == "INFO" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please create a level string parsing function. It should not be case sensitive.

"" and "off" should mean it's off. Level is just an int, so we can use LevelError+1 for off, since no logs will be high enough threshold.

msg := fmt.Sprintf(format, args...)
log.Printf("%s [CGROUP %s: %s]", strings.TrimRight(msg, "\n"), cg.pool.Name, cg.name)
}
logger slog.Logger
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll be typing this a lot, so lets just have "log" instead of "logger"

src/worker/sandbox/cgroups/pool.go Outdated Show resolved Hide resolved
pool := &CgroupPool{
Name: path.Base(path.Dir(common.Conf.Worker_dir)) + "-" + name,
ready: make(chan *CgroupImpl, CGROUP_RESERVE),
recycled: make(chan *CgroupImpl, CGROUP_RESERVE),
quit: make(chan chan bool),
nextID: 0,
logger: common.CgTopLogger,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not just set it to what you want instead of immediately updating it after creating the struct?

}
cg.logger = *cg.logger.With("cgroup pool", cg.pool.Name, "cgroup", cg.name)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't you create if from the pools logger so you don't need to specify the pool name again?

"sync/atomic"
"net/http"
"os"
"os/exec"
"path/filepath"
"strconv"
"strings"
//"strings"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just delete, don't comment stuff out

src/worker/sandbox/sock.go Show resolved Hide resolved
src/common/logger.go Outdated Show resolved Hide resolved
@ikengn
Copy link
Author

ikengn commented Jan 9, 2024

I left a few comments in logger.go right next to the code to make it more clear. Could you take a look at them and let me know your decision for those parts, please? Also, I am currently working on the CGroup subsystem only. Other subsystems such as Sock are not being dealt with yet for now. As soon as you approve all the changes, I will go ahead and apply them to the rest of the OLs, which can then wrap up the project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants