remote_daemon_options_unix.go 799 B

123456789101112131415161718192021222324252627282930313233343536
  1. // +build linux solaris
  2. package libcontainerd
  3. import "fmt"
  4. // WithOOMScore defines the oom_score_adj to set for the containerd process.
  5. func WithOOMScore(score int) RemoteOption {
  6. return oomScore(score)
  7. }
  8. type oomScore int
  9. func (o oomScore) Apply(r Remote) error {
  10. if remote, ok := r.(*remote); ok {
  11. remote.OOMScore = int(o)
  12. return nil
  13. }
  14. return fmt.Errorf("WithOOMScore option not supported for this remote")
  15. }
  16. // WithSubreaper sets whether containerd should register itself as a
  17. // subreaper
  18. func WithSubreaper(reap bool) RemoteOption {
  19. return subreaper(reap)
  20. }
  21. type subreaper bool
  22. func (s subreaper) Apply(r Remote) error {
  23. if remote, ok := r.(*remote); ok {
  24. remote.Subreaper = bool(s)
  25. return nil
  26. }
  27. return fmt.Errorf("WithSubreaper option not supported for this remote")
  28. }