-
Notifications
You must be signed in to change notification settings - Fork 126
/
config_pod_lifecycle.go
38 lines (30 loc) · 1.4 KB
/
config_pod_lifecycle.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package evergreen
import (
"context"
"github.com/mongodb/anser/bsonutil"
"github.com/mongodb/grip"
"github.com/pkg/errors"
"go.mongodb.org/mongo-driver/bson"
)
var podLifecycleConfigKey = bsonutil.MustHaveTag(Settings{}, "PodLifecycle") //nolint:unused
// PodLifecycleConfig holds logging settings for the pod init process.
type PodLifecycleConfig struct {
MaxParallelPodRequests int `bson:"max_parallel_pod_requests" json:"max_parallel_pod_requests" yaml:"max_parallel_pod_requests"`
MaxPodDefinitionCleanupRate int `bson:"max_pod_definition_cleanup_rate" json:"max_pod_definition_cleanup_rate" yam:"max_pod_definition_cleanup_rate"`
MaxSecretCleanupRate int `bson:"max_secret_cleanup_rate" json:"max_secret_cleanup_rate" yaml:"max_secret_cleanup_rate"`
}
func (c *PodLifecycleConfig) SectionId() string { return "pod_lifecycle" }
func (c *PodLifecycleConfig) Get(ctx context.Context) error {
return getConfigSection(ctx, c)
}
func (c *PodLifecycleConfig) Set(ctx context.Context) error {
return errors.Wrapf(setConfigSection(ctx, c.SectionId(), bson.M{"$set": c}), "updating config section '%s'", c.SectionId())
}
func (c *PodLifecycleConfig) ValidateAndDefault() error {
catcher := grip.NewSimpleCatcher()
if c.MaxParallelPodRequests == 0 {
c.MaxParallelPodRequests = 2000
}
catcher.NewWhen(c.MaxParallelPodRequests < 0, "max parallel pod requests cannot be negative")
return catcher.Resolve()
}