remote_daemon_options_linux.go 777 B

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