Repository: m3db/m3db-operator
Pull request #230 (2020-08-12 21:23:24)

[api] Default Parallel pod management


Patch:
diff --git a/docs/api.md b/docs/api.md
index 7b255f0..934322d 100644
--- a/docs/api.md
+++ b/docs/api.md
@@ -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 |
 
diff --git a/pkg/apis/m3dboperator/v1alpha1/cluster.go b/pkg/apis/m3dboperator/v1alpha1/cluster.go
index d10d360..1b7565d 100644
--- a/pkg/apis/m3dboperator/v1alpha1/cluster.go
+++ b/pkg/apis/m3dboperator/v1alpha1/cluster.go
@@ -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
diff --git a/pkg/apis/m3dboperator/v1alpha1/openapi_generated.go b/pkg/apis/m3dboperator/v1alpha1/openapi_generated.go
index 78e2f05..3644778 100644
--- a/pkg/apis/m3dboperator/v1alpha1/openapi_generated.go
+++ b/pkg/apis/m3dboperator/v1alpha1/openapi_generated.go
@@ -605,7 +605,7 @@ func schema_pkg_apis_m3dboperator_v1alpha1_ClusterSpec(ref common.ReferenceCallb
 					},
 					"parallelPodManagement": {
 						SchemaProps: spec.SchemaProps{
-							Description: "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.",
+							Description: "ParallelPodManagement sets StatefulSets created by the operator to have Parallel pod management instead of OrderedReady. If nil, this will default to true.",
 							Type:        []string{"boolean"},
 							Format:      "",
 						},
diff --git a/pkg/apis/m3dboperator/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/m3dboperator/v1alpha1/zz_generated.deepcopy.go
index b2d1608..ad9ca55 100644
--- a/pkg/apis/m3dboperator/v1alpha1/zz_generated.deepcopy.go
+++ b/pkg/apis/m3dboperator/v1alpha1/zz_generated.deepcopy.go
@@ -151,6 +151,11 @@ func (in *ClusterSpec) DeepCopyInto(out *ClusterSpec) {
 		}
 	}
 	in.PodMetadata.DeepCopyInto(&out.PodMetadata)
+	if in.ParallelPodManagement != nil {
+		in, out := &in.ParallelPodManagement, &out.ParallelPodManagement
+		*out = new(bool)
+		**out = **in
+	}
 	return
 }
 
diff --git a/pkg/k8sops/m3db/statefulset.go b/pkg/k8sops/m3db/statefulset.go
index 8a2c5b3..3d14317 100644
--- a/pkg/k8sops/m3db/statefulset.go
+++ b/pkg/k8sops/m3db/statefulset.go
@@ -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
 	}
 


Test patch:
diff --git a/pkg/k8sops/m3db/generators_test.go b/pkg/k8sops/m3db/generators_test.go
index 06f598f..4adfcf1 100644
--- a/pkg/k8sops/m3db/generators_test.go
+++ b/pkg/k8sops/m3db/generators_test.go
@@ -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,
@@ -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)
 	}
 }