Skip to content

Commit

Permalink
adding priority-class for esIndexCleaner (#1732)
Browse files Browse the repository at this point in the history
* adding priority-class for esIndexCleaner and fixing lint error

Signed-off-by: Swapnil Potnis <[email protected]>

* reverting back the operator-sdk version and rebasing

Signed-off-by: Swapnil Potnis <[email protected]>

* unit test case for priorityClass

Signed-off-by: Swapnil Potnis <[email protected]>

* api doc changes

Signed-off-by: Swapnil Potnis <[email protected]>

* changes to variable name as per required convention

Signed-off-by: Swapnil Potnis <[email protected]>

* fixing test case failure for priorityClass

Signed-off-by: Swapnil Potnis <[email protected]>

* changes as per review comments

Signed-off-by: Swapnil Potnis <[email protected]>

Co-authored-by: Ruben Vargas <[email protected]>
  • Loading branch information
swapnilpotnis and rubenvp8510 authored Apr 13, 2022
1 parent d60fada commit 2969950
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 4 deletions.
3 changes: 3 additions & 0 deletions apis/v1/jaeger_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,9 @@ type JaegerEsIndexCleanerSpec struct {

// +optional
JaegerCommonSpec `json:",inline,omitempty"`

// +optional
PriorityClassName string `json:"priorityClassName,omitempty"`
}

// JaegerEsRolloverSpec holds the options related to es-rollover
Expand Down
2 changes: 2 additions & 0 deletions bundle/manifests/jaegertracing.io_jaegers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10030,6 +10030,8 @@ spec:
type: object
numberOfDays:
type: integer
priorityClassName:
type: string
resources:
nullable: true
properties:
Expand Down
2 changes: 2 additions & 0 deletions config/crd/bases/jaegertracing.io_jaegers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10027,6 +10027,8 @@ spec:
type: object
numberOfDays:
type: integer
priorityClassName:
type: string
resources:
nullable: true
properties:
Expand Down
7 changes: 7 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -37720,6 +37720,13 @@ Resource Types:
<br/>
</td>
<td>false</td>
</tr><tr>
<td><b>priorityClassName</b></td>
<td>string</td>
<td>
<br/>
</td>
<td>false</td>
</tr><tr>
<td><b><a href="#jaegerspecstorageesindexcleanerresources">resources</a></b></td>
<td>object</td>
Expand Down
6 changes: 6 additions & 0 deletions pkg/cronjob/es_index_cleaner.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ func CreateEsIndexCleaner(jaeger *v1.Jaeger) *batchv1beta1.CronJob {

ca.Update(jaeger, commonSpec)

priorityClassName := ""
if jaeger.Spec.Storage.EsIndexCleaner.PriorityClassName != "" {
priorityClassName = jaeger.Spec.Storage.EsIndexCleaner.PriorityClassName
}

return &batchv1beta1.CronJob{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Expand Down Expand Up @@ -88,6 +93,7 @@ func CreateEsIndexCleaner(jaeger *v1.Jaeger) *batchv1beta1.CronJob {
SecurityContext: commonSpec.SecurityContext,
ServiceAccountName: account.JaegerServiceAccountFor(jaeger, account.EsIndexCleanerComponent),
Volumes: commonSpec.Volumes,
PriorityClassName: priorityClassName,
},
ObjectMeta: metav1.ObjectMeta{
Labels: commonSpec.Labels,
Expand Down
9 changes: 9 additions & 0 deletions pkg/cronjob/es_index_cleaner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,12 @@ func TestCustomEsIndexCleanerImage(t *testing.T) {
assert.Empty(t, jaeger.Spec.Storage.EsIndexCleaner.Image)
assert.Equal(t, "org/custom-es-index-cleaner-image:"+version.Get().Jaeger, cjob.Spec.JobTemplate.Spec.Template.Spec.Containers[0].Image)
}

// Test Case for PriorityClassName
func TestPriorityClassName(t *testing.T) {
jaeger := v1.NewJaeger(types.NamespacedName{Name: "TestPriorityClassName"})

priorityClassNameVal := ""

assert.Equal(t, priorityClassNameVal, jaeger.Spec.Storage.EsIndexCleaner.PriorityClassName)
}
5 changes: 1 addition & 4 deletions pkg/deployment/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,7 @@ func (q *Query) Get() *appsv1.Deployment {
// see https://github.com/jaegertracing/jaeger-operator/issues/334
sort.Strings(options)

priorityClassName := ""
if q.jaeger.Spec.Query.PriorityClassName != "" {
priorityClassName = q.jaeger.Spec.Query.PriorityClassName
}
priorityClassName := q.jaeger.Spec.Query.PriorityClassName

strategy := appsv1.DeploymentStrategy{
Type: appsv1.RecreateDeploymentStrategyType,
Expand Down

0 comments on commit 2969950

Please sign in to comment.