Skip to content

Introduce higher and lower bounds for the number of instances #178

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

Merged
merged 3 commits into from
Dec 15, 2017

Conversation

alexeyklyukin
Copy link
Contributor

Reduce the number of instances to the min_instances if it is lower and
to the max_instances if it is higher. -1 for either of those means there
is no lower or upper bound.

In addition, terminate the operator when there is a nonsense in the
configuration (i.e. max_instances < min_instances).

Reduce the number of instances to the min_instances if it is lower and
to the max_instances if it is higher. -1 for either of those means there
is no lower or upper bound.

In addition, terminate the operator when there is a nonsense in the
configuration (i.e. max_instances < min_instances).
@Jan-M
Copy link
Member

Jan-M commented Dec 15, 2017

👍

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.07%) to 11.247% when pulling 4829f32 on global-min-max-replicas into 0e255f8 on master.

err = fmt.Errorf("number of works should be higher than 0")
}
return
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing really wrong with this, but I'm curious: why check all errors but only panic on the last one? (not really important as there are just two, but could this grow in the future? it would probably be most helpful to log all of them and then panic)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, didn't care much about that for now (also, there are many other parameters that could be validated), just picked up a low-hanging fruit in the config to validate, since we had no validation before altogether.

@mgomezch
Copy link
Contributor

👍

@@ -464,14 +464,16 @@ func (c *Cluster) generateStatefulSet(spec *spec.PostgresSpec) (*v1beta1.Statefu
return nil, fmt.Errorf("could not generate volume claim template: %v", err)
}

numberOfInstaces := c.getNumberOfInstances(spec)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instaNces ?

@@ -33,6 +34,8 @@ type Resources struct {
PodEnvironmentConfigMap string `name:"pod_environment_configmap" default:""`
NodeEOLLabel map[string]string `name:"node_eol_label" default:"lifecycle-status:pending-decommission"`
NodeReadinessLabel map[string]string `name:"node_readiness_label" default:"lifecycle-status:ready"`
MaxInstances int32 `name:"max_instances" default:"-1"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shall we comment here on the special meaning of -1 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That went to the docs.

err = fmt.Errorf("minimum number of instances %d is set higher than the maximum number %d")
}
if cfg.Workers == 0 {
err = fmt.Errorf("number of works should be higher than 0")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

workERs ?

if cfg.MinInstances > 0 && cfg.MaxInstances > 0 && cfg.MinInstances > cfg.MaxInstances {
err = fmt.Errorf("minimum number of instances %d is set higher than the maximum number %d")
}
if cfg.Workers == 0 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cfg.Workers > 0 ? It may be tempting to supply -1 meaning no limit :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's unit32.

newcur = min
}
if newcur != cur {
c.logger.Infof("adjusted number of instances to %d (min: %d, max: %d)", newcur, min, max)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should the log mention the old value as well ?

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.07%) to 11.245% when pulling e401645 on global-min-max-replicas into 0e255f8 on master.

Fix some typos. Per code review by Jan Mußler and Sergey Dudoladov.
### Limiting the number of instances in clusters with `min_instances` and `max_instances`

As a preventive measure, one can restrict the minimum and the maximum number of instances permitted by each Postgres cluster managed by the operator.
If either `min_instances` or `max_instances` is set to a non-zero value, the operator may adjust the number of instances specified in the cluster manifest to match either the min or the max boundary.
Copy link
Member

@sdudoladov sdudoladov Dec 15, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and min_instances or max_instances goes to the operator configmap, right ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but there is no need to mention that, since that is part of the description of the operator parameters.

@sdudoladov
Copy link
Member

👍

1 similar comment
@alexeyklyukin
Copy link
Contributor Author

👍

@alexeyklyukin alexeyklyukin merged commit bf80f52 into master Dec 15, 2017
@erthalion erthalion deleted the global-min-max-replicas branch September 13, 2018 09:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants