Skip to content

Commit

Permalink
feat(cspc): add support to pass priority class to the pool pods
Browse files Browse the repository at this point in the history
Signed-off-by: Ashutosh Kumar <[email protected]>
  • Loading branch information
Ashutosh Kumar committed Dec 24, 2019
1 parent 77442f2 commit f61ee99
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cmd/cspc-operator/app/storagepool_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ func (pc *PoolConfig) GetPoolDeploySpec(cspi *apis.CStorPoolInstance) (*appsv1.D
WithPodTemplateSpecBuilder(
pts.NewBuilder().
WithLabelsNew(getPodLabels(cspi)).
WithPriorityClassName(getPriorityClass(cspi)).
WithNodeSelector(cspi.Spec.NodeSelector).
WithAnnotationsNew(getPodAnnotations()).
WithServiceAccountName(OpenEBSServiceAccount).
Expand Down Expand Up @@ -408,3 +409,7 @@ func getPoolPodToleration(cspi *apis.CStorPoolInstance) []corev1.Toleration {
}
return tolerations
}

func getPriorityClass(cspi *apis.CStorPoolInstance) string {
return cspi.Spec.PoolConfig.PriorityClassName
}
4 changes: 4 additions & 0 deletions pkg/algorithm/nodeselect/v1alpha2/build_csp.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ func (ac *Config) GetCSPSpec() (*apis.CStorPoolInstance, error) {
poolSpec.PoolConfig.Tolerations = ac.CSPC.Spec.Tolerations
}

if poolSpec.PoolConfig.PriorityClassName == "" {
poolSpec.PoolConfig.PriorityClassName = ac.CSPC.Spec.DefaultPriorityClassName
}

csplabels := ac.buildLabelsForCSPI(nodeName)
cspObj, err := apiscsp.NewBuilder().
WithName(ac.CSPC.Name + "-" + rand.String(4)).
Expand Down
11 changes: 11 additions & 0 deletions pkg/apis/openebs.io/v1alpha1/cstorpool_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ type CStorPoolClusterSpec struct {
// If tolerations at PoolConfig is empty, this is written to
// CSPI PoolConfig.
Tolerations []v1.Toleration `json:"tolerations"`

// DefaultPriorityClassName if specified applies to all the pool pods
// in the pool spec if the priorityClass at the pool level is
// not specified.
DefaultPriorityClassName string `json:"priorityClassName"`
}

//PoolSpec is the spec for pool on node where it should be created.
Expand Down Expand Up @@ -120,6 +125,12 @@ type PoolConfig struct {

// Tolerations, if specified, the pool pod's tolerations.
Tolerations []v1.Toleration `json:"tolerations"`

// PriorityClassName if specified applies to this pool pod
// If left empty, DefaultPriorityClassName is applied.
// (See CStorPoolClusterSpec.DefaultPriorityClassName)
// If both are empty, not priority class is applied.
PriorityClassName string `json:"priorityClassName"`
}

// RaidGroup contains the details of a raid group for the pool
Expand Down
6 changes: 6 additions & 0 deletions pkg/kubernetes/podtemplatespec/v1alpha1/podtemplatespec.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@ func (b *Builder) WithNodeSelector(nodeselectors map[string]string) *Builder {
return b
}

// WithPriorityClassName sets the PriorityClassName field of podtemplatespec
func (b *Builder) WithPriorityClassName(prorityClassName string) *Builder {
b.podtemplatespec.Object.Spec.PriorityClassName = prorityClassName
return b
}

// WithNodeSelectorNew resets the nodeselector field of podtemplatespec
// with provided arguments
func (b *Builder) WithNodeSelectorNew(nodeselectors map[string]string) *Builder {
Expand Down

0 comments on commit f61ee99

Please sign in to comment.