-
Notifications
You must be signed in to change notification settings - Fork 522
CLOUDP-58090: Create StatefulSet that starts agent image #12
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
CLOUDP-58090: Create StatefulSet that starts agent image #12
Conversation
LouisPlisso
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did you test this with the sample agent image?
|
|
||
| // New returns a new corev1.ResourceRequirements with the specified arguments, and an error | ||
| // which indicates if there was a problem parsing the input | ||
| func New(limitsCpu, limitsMemory, requestsCpu, requestsMemory string) (corev1.ResourceRequirements, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or maybe a builder (again) that comes with default values and you can call .setLimitsCpu(xxx) and so on
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm on a little bit on the fence about this one. When we're not doing much (just 4 values). I like the simplicity of a single factory-style function. It might make sense to introduce a builder when we need to start . configuring non-defaults here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as discuss, un-export New for now, and we'll see later if we need a builder
| "github.com/mongodb/mongodb-kubernetes-operator/pkg/controller" | ||
| "go.uber.org/zap" | ||
| "os" | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rodrigovalin is working on it now I believe!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am, doing it right now
rodrigovalin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's one important point we have to discuss here: the AGENT_IMAGE is passed as an env variable to the operator... meaning that every MongoDB resource will use the same agent?
I understand that given our current requirements this implementation is enough, but imagine the process of updating this image (for any reason), that would require a reconfiguration of the operator, which will require a restart of all of the Sts it manages.
I actually prefer the image name being hardcoded in the Sts definition, so we know this is a known defect of the implementation, but not a non-evident defect of the design.
|
|
||
| // Default returns the default resource requirements for a container | ||
| func Default() (corev1.ResourceRequirements, error) { | ||
| return New("1.0", "500M", "0.5", "400M") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discard the returning errors of this function, Default should not fail as the values are known
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly add a unit test that checks that Default() return these values so there's not way we introduce errors in the Default impl.
I mention this because I see a few lines up there checking the resulting value of the Default function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point about removing the error in this case 👍
rodrigovalin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My concerns on my previous review were:
AGENT_VERSIONshould not be an operator configuration
We agreed on leaving this for now:
- Because we won't have a new agent image in a while
- It will make it easier to "test" custom images if we had to, specially when starting the project.
The strategy will be revisited later.


This PR configures the stateful set to use an agent image specified by the
AGENT_IMAGEenvironment variable.The stateful set is configured with default resource requirements. Sample StatefulSet configuration
spec: podManagementPolicy: OrderedReady replicas: 3 revisionHistoryLimit: 10 selector: matchLabels: dummy: label serviceName: "" template: metadata: creationTimestamp: null labels: dummy: label spec: containers: - command: - agent/mongodb-agent - -cluster=/var/lib/automation/config/automation-config.json image: <agent-image> imagePullPolicy: Always name: mongodb-agent resources: limits: cpu: "1" memory: 500M requests: cpu: 500m memory: 400M