Skip to content
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

[api] Default Parallel pod management #230

Merged
merged 2 commits into from
Oct 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ ClusterSpec defines the desired state for a M3 cluster to be converge to.
| initContainers | Custom setup for db nodes can be done via initContainers Provide the complete spec for the initContainer here If any storage volumes are needed in the initContainer see InitVolumes below | []corev1.Container | false |
| initVolumes | If the InitContainers require any storage volumes Provide the complete specification for the required Volumes here | []corev1.Volume | false |
| podMetadata | PodMetadata is for any Metadata that is unique to the pods, and does not belong on any other objects, such as Prometheus scrape tags | [metav1.ObjectMeta](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.10/#objectmeta-v1-meta) | false |
| parallelPodManagement | ParallelPodManagement sets StatefulSets created by the operator to have Parallel pod management instead of OrderedReady. This is an EXPERIMENTAL flag and subject to deprecation in a future release. This has not been tested in production and users should not depend on it without validating it for their own use case. | bool | true |
| parallelPodManagement | ParallelPodManagement sets StatefulSets created by the operator to have Parallel pod management instead of OrderedReady. If nil, this will default to true. | *bool | true |
| serviceAccountName | To use a non-default service account, specify the name here otherwise the service account \"default\" will be used. This is useful for advanced use-cases such as pod security policies. The service account must exist. This operator will not create it. | string | false |
| frozen | Frozen is used to stop the operator from taking any further actions on a cluster. This is useful when troubleshooting as it guarantees the operator won't make any changes to the cluster. | bool | false |

Expand Down
8 changes: 3 additions & 5 deletions pkg/apis/m3dboperator/v1alpha1/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,9 @@ type ClusterSpec struct {
PodMetadata metav1.ObjectMeta `json:"podMetadata,omitempty"`

// ParallelPodManagement sets StatefulSets created by the operator to have
// Parallel pod management instead of OrderedReady. This is an EXPERIMENTAL
// flag and subject to deprecation in a future release. This has not been
// tested in production and users should not depend on it without validating
// it for their own use case.
ParallelPodManagement bool `json:"parallelPodManagement,omitEmpty"`
// Parallel pod management instead of OrderedReady. If nil, this will default
// to true.
ParallelPodManagement *bool `json:"parallelPodManagement,omitEmpty"`

// To use a non-default service account, specify the name here otherwise the
// service account "default" will be used. This is useful for advanced
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/m3dboperator/v1alpha1/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions pkg/apis/m3dboperator/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions pkg/k8sops/m3db/generators_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ func TestGenerateStatefulSet(t *testing.T) {
Selector: &metav1.LabelSelector{
MatchLabels: labels,
},
Replicas: instanceAmount,
PodManagementPolicy: appsv1.ParallelPodManagement,
Replicas: instanceAmount,
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: labels,
Expand Down Expand Up @@ -492,16 +493,17 @@ func TestGenerateStatefulSet(t *testing.T) {

// Test PodManagement
fixture = getFixture("testM3DBCluster.yaml", t)
fixture.Spec.ParallelPodManagement = true
fixture.Spec.ParallelPodManagement = pointer.BoolPtr(false)

ss = baseSS.DeepCopy()
ss.Spec.PodManagementPolicy = "Parallel"
ss.Spec.PodManagementPolicy = ""
newSS, err = GenerateStatefulSet(fixture, isolationGroup, *instanceAmount)
assert.NoError(t, err)
assert.NotNil(t, newSS)
if !assert.Equal(t, ss, newSS) {
diff, _ := messagediff.PrettyDiff(ss, newSS)
t.Log(diff)
t.Log(fixture.Spec.ParallelPodManagement)
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/k8sops/m3db/statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func NewBaseStatefulSet(ssName, isolationGroup string, cluster *myspec.M3DBClust
},
}

if cluster.Spec.ParallelPodManagement {
if cluster.Spec.ParallelPodManagement == nil || *cluster.Spec.ParallelPodManagement {
stsSpec.PodManagementPolicy = appsv1.ParallelPodManagement
}

Expand Down