From 8025bd36b6b4b997e89c8e79fcdea95b1c188e09 Mon Sep 17 00:00:00 2001 From: criyle Date: Sat, 3 Feb 2024 15:19:49 +0000 Subject: [PATCH] docs: fix typos --- README.md | 6 +++--- cmd/go-judge-shell/shell.go | 2 +- cmd/go-judge/config/config.go | 4 ++-- cmd/go-judge/main.go | 21 +++------------------ cmd/go-judge/metrics.go | 10 +++++----- env/linuxcontainer/environment_linux.go | 4 ++-- env/macsandbox/profile_darwin.go | 2 +- env/winc/process_windows.go | 4 ++-- envexec/cmd.go | 2 +- envexec/group.go | 2 +- filestore/timeout.go | 4 ++-- 11 files changed, 23 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index 563722f..865e3b0 100644 --- a/README.md +++ b/README.md @@ -306,7 +306,7 @@ Output: -Plese use PostMan or similar tools to send request to `http://localhost:5050/run` +Please use PostMan or similar tools to send request to `http://localhost:5050/run`
Single (this example require `apt install g++` inside the container) @@ -613,7 +613,7 @@ Sandbox: - for example, by default container 0 will run with 10001 uid & gid and container 1 will run with 10002 uid & gid... - `-enable-cpu-rate` enabled `cpu` cgroup to control cpu rate using cfs_quota & cfs_period control (Linux only) - `-cpu-cfs-period` specifies cfs_period if cpu rate is enabled (default 100ms) (valid value: \[1ms, 1s\]) -- `-seccomp-conf` specifies `seecomp` filter setting to load when running program (need build tag `seccomp`) (Linux only) +- `-seccomp-conf` specifies `seccomp` filter setting to load when running program (need build tag `seccomp`) (Linux only) - for example, by `strace -c prog` to get all `syscall` needed and restrict to that sub set - however, the `syscall` count in one platform(e.g. x86_64) is not suitable for all platform, so this option is not recommended - the program killed by seccomp filter will have status `Dangerous Syscall` @@ -707,7 +707,7 @@ If a bind mount is specifying a target within the previous mounted one, please e #### Windows Security - Resources are limited by [JobObject](https://docs.microsoft.com/en-us/windows/win32/procthread/job-objects) -- Privillege are limited by [Restricted Low Mandatory Level Token](https://docs.microsoft.com/en-us/windows/win32/secauthz/access-tokens) +- Privilege are limited by [Restricted Low Mandatory Level Token](https://docs.microsoft.com/en-us/windows/win32/secauthz/access-tokens) - Low Mandatory Level directory is created for read / write ### MacOS Support diff --git a/cmd/go-judge-shell/shell.go b/cmd/go-judge-shell/shell.go index 4df09e3..d599d6f 100644 --- a/cmd/go-judge-shell/shell.go +++ b/cmd/go-judge-shell/shell.go @@ -18,7 +18,7 @@ import ( ) var ( - srvAddr = flag.String("srvaddr", "localhost:5051", "GRPC server addr") + srvAddr = flag.String("srv-addr", "localhost:5051", "GRPC server addr") ) const ( diff --git a/cmd/go-judge/config/config.go b/cmd/go-judge/config/config.go index 88663d5..4068254 100644 --- a/cmd/go-judge/config/config.go +++ b/cmd/go-judge/config/config.go @@ -32,7 +32,7 @@ type Config struct { OutputLimit *envexec.Size `flagUsage:"specifies POSIX rlimit for output for each command" default:"256m"` CopyOutLimit *envexec.Size `flagUsage:"specifies default file copy out max" default:"256m"` OpenFileLimit int `flagUsage:"specifies max open file count" default:"256"` - Cpuset string `flagUsage:"control the usage of cpuset for all containerd process"` + Cpuset string `flagUsage:"control the usage of cpuset for all container process"` EnableCPURate bool `flagUsage:"enable cpu cgroup rate control"` CPUCfsPeriod time.Duration `flagUsage:"set cpu.cfs_period" default:"100ms"` FileTimeout time.Duration `flagUsage:"specified timeout for filestore files"` @@ -44,7 +44,7 @@ type Config struct { MonitorAddr string `flagUsage:"specifies the metrics binding address"` AuthToken string `flagUsage:"bearer token auth for REST / gRPC"` EnableDebug bool `flagUsage:"enable debug endpoint"` - EnableMetrics bool `flagUsage:"enable promethus metrics endpoint"` + EnableMetrics bool `flagUsage:"enable prometheus metrics endpoint"` // logger config Release bool `flagUsage:"release level of logs"` diff --git a/cmd/go-judge/main.go b/cmd/go-judge/main.go index 5f47b02..f45691b 100644 --- a/cmd/go-judge/main.go +++ b/cmd/go-judge/main.go @@ -4,13 +4,10 @@ package main import ( "context" - crypto_rand "crypto/rand" - "encoding/binary" "errors" "flag" "fmt" "log" - math_rand "math/rand" "net/http" "net/http/pprof" "os" @@ -53,13 +50,12 @@ var logger *zap.Logger func main() { conf := loadConf() if conf.Version { - fmt.Print(version.Version) + fmt.Println(version.Version) return } initLogger(conf) defer logger.Sync() logger.Sugar().Infof("config loaded: %+v", conf) - initRand() warnIfNotLinux() // Init environment pool @@ -69,7 +65,7 @@ func main() { prefork(envPool, conf.PreFork) work := newWorker(conf, envPool, fs) work.Start() - logger.Sugar().Infof("Started worker with parallelism=%d, workdir=%s, timeLimitCheckInterval=%v", + logger.Sugar().Infof("Started worker with parallelism=%d, workDir=%s, timeLimitCheckInterval=%v", conf.Parallelism, conf.Dir, conf.TimeLimitCheckerInterval) servers := []initFunc{ @@ -272,17 +268,6 @@ func initLogger(conf *config.Config) { } } -func initRand() { - var b [8]byte - _, err := crypto_rand.Read(b[:]) - if err != nil { - logger.Fatal("random generator init failed ", zap.Error(err)) - } - sd := int64(binary.LittleEndian.Uint64(b[:])) - logger.Sugar().Infof("random seed: %d", sd) - math_rand.Seed(sd) -} - func prefork(envPool worker.EnvironmentPool, prefork int) { if prefork <= 0 { return @@ -469,7 +454,7 @@ func newEnvBuilder(conf *config.Config) (pool.EnvBuilder, map[string]any) { logger.Sugar().Fatal("create environment builder failed ", err) } if conf.EnableMetrics { - b = &metriceEnvBuilder{b} + b = &metricsEnvBuilder{b} } return b, param } diff --git a/cmd/go-judge/metrics.go b/cmd/go-judge/metrics.go index 616fd58..f84b72c 100644 --- a/cmd/go-judge/metrics.go +++ b/cmd/go-judge/metrics.go @@ -49,7 +49,7 @@ var ( Namespace: metricsNamespace, Subsystem: execSubsystem, Name: "memory_bytes", - Help: "Histgram for the command execution max memory", + Help: "Histogram for the command execution max memory", Buckets: memoryBucket, }, []string{"status"}) @@ -57,7 +57,7 @@ var ( Namespace: metricsNamespace, Subsystem: filestoreSubsystem, Name: "size_bytes", - Help: "Histgram for the file size created in the file store", + Help: "Histogram for the file size created in the file store", Buckets: fileSizeBucket, }) @@ -171,13 +171,13 @@ func (m *metricsFileStore) Remove(id string) bool { return success } -var _ pool.EnvBuilder = &metriceEnvBuilder{} +var _ pool.EnvBuilder = &metricsEnvBuilder{} -type metriceEnvBuilder struct { +type metricsEnvBuilder struct { pool.EnvBuilder } -func (b *metriceEnvBuilder) Build() (pool.Environment, error) { +func (b *metricsEnvBuilder) Build() (pool.Environment, error) { e, err := b.EnvBuilder.Build() if err != nil { return nil, err diff --git a/env/linuxcontainer/environment_linux.go b/env/linuxcontainer/environment_linux.go index 0c745fc..3bffe56 100644 --- a/env/linuxcontainer/environment_linux.go +++ b/env/linuxcontainer/environment_linux.go @@ -30,7 +30,7 @@ type environ struct { cpuRate bool } -// Destroy destories the environment +// Destroy destroys the environment func (c *environ) Destroy() error { return c.Environment.Destroy() } @@ -131,7 +131,7 @@ func (c *environ) Open(path string, flags int, perm os.FileMode) (*os.File, erro return f, nil } -// MkdirAll equivelent to os.MkdirAll but in container +// MkdirAll equivalent to os.MkdirAll but in container func (c *environ) MkdirAll(path string, perm os.FileMode) error { if path == "" || path == "." { return nil diff --git a/env/macsandbox/profile_darwin.go b/env/macsandbox/profile_darwin.go index 1b4b77b..6f2dc06 100644 --- a/env/macsandbox/profile_darwin.go +++ b/env/macsandbox/profile_darwin.go @@ -52,7 +52,7 @@ type Profile struct { Network bool } -// DefaultProfile defines the minimun default profile to run programs +// DefaultProfile defines the minimum default profile to run programs var DefaultProfile = Profile{ ReadableDir: []string{"/usr/lib"}, } diff --git a/env/winc/process_windows.go b/env/winc/process_windows.go index 65a7d53..df56fe7 100644 --- a/env/winc/process_windows.go +++ b/env/winc/process_windows.go @@ -27,14 +27,14 @@ func (p *process) Result() envexec.RunnerResult { } func (p *process) Usage() envexec.Usage { - t, m, _ := getJobOjbectUsage(p.hJob) + t, m, _ := getJobObjectUsage(p.hJob) return envexec.Usage{ Time: t, Memory: m, } } -func getJobOjbectUsage(hJob windows.Handle) (time.Duration, envexec.Size, error) { +func getJobObjectUsage(hJob windows.Handle) (time.Duration, envexec.Size, error) { basicInfo := new(JOBOBJECT_BASIC_ACCOUNTING_INFORMATION) if _, err := QueryInformationJobObject(hJob, JobObjectBasicAccountingInformation, uintptr(unsafe.Pointer(basicInfo)), uint32(unsafe.Sizeof(*basicInfo)), nil); err != nil { diff --git a/envexec/cmd.go b/envexec/cmd.go index 6484634..35a0f28 100644 --- a/envexec/cmd.go +++ b/envexec/cmd.go @@ -53,7 +53,7 @@ type Cmd struct { CopyOut []CmdCopyOutFile CopyOutMax Size // file size limit - // CopyOutDir specifies a dir to dump all /w contnet + // CopyOutDir specifies a dir to dump all /w content CopyOutDir string // additional memory option diff --git a/envexec/group.go b/envexec/group.go index d695364..18c84a5 100644 --- a/envexec/group.go +++ b/envexec/group.go @@ -34,7 +34,7 @@ type Pipe struct { // Name defines copy out entry name if it is not empty and proxy is enabled Name string - // Limit defines maximun bytes copy out from proxy and proxy will still + // Limit defines maximum bytes copy out from proxy and proxy will still // copy data after limit exceeded Limit Size diff --git a/filestore/timeout.go b/filestore/timeout.go index fafed05..c88dda8 100644 --- a/filestore/timeout.go +++ b/filestore/timeout.go @@ -14,7 +14,7 @@ var ( _ heap.Interface = &Timeout{} ) -// Timeout is a file system with a maximun TTL +// Timeout is a file system with a maximum TTL type Timeout struct { mu sync.Mutex FileStore @@ -28,7 +28,7 @@ type timeoutFile struct { time time.Time } -// NewTimeout creates a timeout file system with maximun TTL for a file +// NewTimeout creates a timeout file system with maximum TTL for a file func NewTimeout(fs FileStore, timeout time.Duration, checkInterval time.Duration) FileStore { t := &Timeout{ FileStore: fs,