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

Support Deployments and StatefulSet #52

Merged
merged 13 commits into from
Jul 30, 2020

Conversation

AdheipSingh
Copy link
Contributor

Fixes #49 .

Description

  • In the NodeSpec have added a key kind which can take inputs for deployments or statefulsets.
  • This key is a Required param and is validated by the operator.
  • The makeStatefulSet func has been split up so that the underlying podSpec remains common. Hence less code to maintain, plus in case we add more features to the podSpec it remains common to both deployments and statefulsets.
  • Status has been updated to update deployments.
  • Update is same as earlier, incase of rollingDeploy true, we have incremental updates.

This PR has:

  • [x ] been tested on a real K8S cluster to ensure creation of a brand new Druid cluster works.
  • [x ] been tested for backward compatibility on a real K*S cluster by applying the changes introduced here on an existing Druid cluster. If there are any backward incompatible changes then they have been noted in the PR description.
  • [x ] added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
  • added documentation for new or modified features or behaviors.

Key changed/added files in this PR
  • types.go
  • handler.go
  • tiny-cluster.yaml

@@ -141,6 +141,9 @@ type DruidNodeSpec struct {
// Required: Port used by Druid Process
DruidPort int32 `json:"druid.port"`

// Required: Define kind for node. Deployment or Statefulsets are supported
Kind string `json:"kind"`
Copy link
Member

Choose a reason for hiding this comment

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

can we make it optional and default to StatefulSet to keep things backward compatible and also to not necessarily having to specify this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, makes sense to have backward compatible. Ill do the changes :)

@AdheipSingh
Copy link
Contributor Author

@himanshug any updates ?

@himanshug
Copy link
Member

@AdheipSingh sorry, I haven't had a chance to look at it till now, will review it this week for sure. I am hoping to get some more time to spend on druid-operator in future :)

@AdheipSingh
Copy link
Contributor Author

@AdheipSingh sorry, I haven't had a chance to look at it till now, will review it this week for sure. I am hoping to get some more time to spend on druid-operator in future :)

no hurries, just wanted to check :)
Thanks

Copy link
Member

@himanshug himanshug left a comment

Choose a reason for hiding this comment

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

Looks good overall, few small comments. Thanks

Comment on lines 211 to 216
// Optional: maxSurge for deployment object
MaxSurge *int32 `json:"maxSurge"`

// Optional: MaxUnavailable for deployment object
MaxUnavailable *int32 `json:"maxUnavailable"`

Copy link
Member

Choose a reason for hiding this comment

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

nit

Suggested change
// Optional: maxSurge for deployment object
MaxSurge *int32 `json:"maxSurge"`
// Optional: MaxUnavailable for deployment object
MaxUnavailable *int32 `json:"maxUnavailable"`
// Optional: maxSurge for deployment object, only applicable if kind=Deployment
MaxSurge *int32 `json:"maxSurge"`
// Optional: MaxUnavailable for deployment object, only applicable if kind=Deployment
MaxUnavailable *int32 `json:"maxUnavailable"`

// Check StatefulSet rolling update status, if in-progress then stop here
done, err := isStsFullyDeployed(sdk, nodeSpecUniqueStr, m)
if !done {
if nodeSpec.Kind == "Deployment" {
Copy link
Member

Choose a reason for hiding this comment

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

two "if" clause above should be combined as ...

if nodeSpec.Kind == "Deployment" {
  // do stuff for Deployment
} else {
  // do stuff for StatefulSet
}

sendEvent(sdk, drd, v1.EventTypeWarning, "GET_FAIL", e.Error())
return false, e
} else {
if deploy.Status.ReadyReplicas != deploy.Status.Replicas {
Copy link
Member

Choose a reason for hiding this comment

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

have you tested same concept works for Deployment resource? what I wrote for StatefulSet in isStsFullyDeployed(..) was only tested for sts.

Copy link
Contributor Author

@AdheipSingh AdheipSingh Jul 22, 2020

Choose a reason for hiding this comment

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

yes, i have been running this in my cluster, this is checking if desired replicas have come back in ready state. Behaves same as sts during upgrades.

@@ -560,31 +617,43 @@ func getServiceName(nameTemplate, nodeSpecUniqueStr string) string {
}
}

func makeStatefulSet(nodeSpec *v1alpha1.DruidNodeSpec, m *v1alpha1.Druid, ls map[string]string, nodeSpecUniqueStr, configMapSHA, serviceName string) (*appsv1.StatefulSet, error) {
templateHolder := []v1.PersistentVolumeClaim{}
func templateHolder(nodeSpec *v1alpha1.DruidNodeSpec, m *v1alpha1.Druid) []v1.PersistentVolumeClaim {
Copy link
Member

Choose a reason for hiding this comment

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

nit: like other similar methods, this could be a getXxx

Suggested change
func templateHolder(nodeSpec *v1alpha1.DruidNodeSpec, m *v1alpha1.Druid) []v1.PersistentVolumeClaim {
func getPersistentVolumeClaims(nodeSpec *v1alpha1.DruidNodeSpec, m *v1alpha1.Druid) []v1.PersistentVolumeClaim {

volumeMountHolder := []v1.VolumeMount{
}

func volumeMountHolder(nodeSpec *v1alpha1.DruidNodeSpec, m *v1alpha1.Druid) []v1.VolumeMount {
Copy link
Member

Choose a reason for hiding this comment

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

nit: like other similar methods, this could be a getXxx

Suggested change
func volumeMountHolder(nodeSpec *v1alpha1.DruidNodeSpec, m *v1alpha1.Druid) []v1.VolumeMount {
func getVolumeMounts(nodeSpec *v1alpha1.DruidNodeSpec, m *v1alpha1.Druid) []v1.VolumeMount {

pkg/apis/druid/v1alpha1/druid_types.go Show resolved Hide resolved
Copy link
Member

@nishantmonu51 nishantmonu51 left a comment

Choose a reason for hiding this comment

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

LGTM, 👍

done, err := isStsFullyDeployed(sdk, nodeSpecUniqueStr, m)
if !done {
// Check Deployment rolling update status, if in-progress then stop here
done, err := isDeployFullyDeployed(sdk, nodeSpecUniqueStr, m)
Copy link
Member

Choose a reason for hiding this comment

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

nit: rename to isDeploymentFullyDeployed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@himanshug himanshug merged commit 33f4d38 into druid-io:master Jul 30, 2020
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.

Support StatefulSet only For Historicals,MM
3 participants