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

feat(cspc): add support to pass priority class to the pool pods #1566

Merged
merged 1 commit into from
Dec 26, 2019
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
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"`
Copy link
Contributor

@mynktl mynktl Dec 24, 2019

Choose a reason for hiding this comment

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

Not relevant to this PR. We are using Tolerations from poolConfig. This can be misleading. Can you verify the same?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks good.


// 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