Skip to content

Commit ccada69

Browse files
committed
add support for priority classes
Signed-off-by: Utkarsh Srivastava <srivastavautkarsh8097@gmail.com> address coderabbit comments Signed-off-by: Utkarsh Srivastava <srivastavautkarsh8097@gmail.com>
1 parent 8f65785 commit ccada69

9 files changed

Lines changed: 76 additions & 3 deletions

File tree

deploy/crds/noobaa.io_backingstores.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,10 @@ spec:
190190
numVolumes:
191191
description: NumVolumes is the number of volumes to allocate
192192
type: integer
193+
priorityClassName:
194+
description: PriorityClassName (optional) overrides the priority
195+
class for the pv-pool agent pods
196+
type: string
193197
resources:
194198
description: VolumeResources represents the minimum resources
195199
each volume should have.

deploy/crds/noobaa.io_noobaas.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,6 +1076,10 @@ spec:
10761076
cleanup confirmation
10771077
type: string
10781078
type: object
1079+
corePriorityClassName:
1080+
description: CorePriorityClassName (optional) overrides the priority
1081+
class for the core pod
1082+
type: string
10791083
coreResources:
10801084
description: CoreResources (optional) overrides the default resource
10811085
requirements for the server container
@@ -1144,6 +1148,10 @@ spec:
11441148
description: DBImage (optional) overrides the default image for the
11451149
db container
11461150
type: string
1151+
dbPriorityClassName:
1152+
description: DBPriorityClassName (optional) overrides the priority
1153+
class for the db pod
1154+
type: string
11471155
dbResources:
11481156
description: DBResources (optional) overrides the default resource
11491157
requirements for the db container
@@ -1544,6 +1552,10 @@ spec:
15441552
numVolumes:
15451553
description: NumVolumes is the number of volumes to allocate
15461554
type: integer
1555+
priorityClassName:
1556+
description: PriorityClassName (optional) overrides the priority
1557+
class for the pv-pool agent pods
1558+
type: string
15471559
resources:
15481560
description: VolumeResources represents the minimum resources
15491561
each volume should have.
@@ -1648,6 +1660,10 @@ spec:
16481660
of openshift route resources in the cluster
16491661
nullable: true
16501662
type: boolean
1663+
endpointPriorityClassName:
1664+
description: EndpointPriorityClassName (optional) overrides the priority
1665+
class for the endpoint pods
1666+
type: string
16511667
endpoints:
16521668
description: |-
16531669
Endpoints (optional) sets configuration info for the noobaa endpoint

pkg/apis/noobaa/v1alpha1/backingstore_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,10 @@ type PVPoolSpec struct {
251251
// VolumeResources represents the minimum resources each volume should have.
252252
VolumeResources *corev1.VolumeResourceRequirements `json:"resources,omitempty"`
253253

254+
// PriorityClassName (optional) overrides the priority class for the pv-pool agent pods
255+
// +optional
256+
PriorityClassName string `json:"priorityClassName,omitempty"`
257+
254258
// Secret refers to a secret that provides the agent configuration
255259
// The secret should define AGENT_CONFIG containing agent_configuration from noobaa-core.
256260
// +optional

pkg/apis/noobaa/v1alpha1/noobaa_types.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ type NooBaaSpec struct {
100100
// +optional
101101
CoreResources *corev1.ResourceRequirements `json:"coreResources,omitempty"`
102102

103+
// CorePriorityClassName (optional) overrides the priority class for the core pod
104+
// +optional
105+
CorePriorityClassName string `json:"corePriorityClassName,omitempty"`
106+
103107
// LogResources (optional) overrides the default resource requirements for the noobaa-log-processor container
104108
// +optional
105109
LogResources *corev1.ResourceRequirements `json:"logResources,omitempty"`
@@ -108,6 +112,10 @@ type NooBaaSpec struct {
108112
// +optional
109113
DBResources *corev1.ResourceRequirements `json:"dbResources,omitempty"`
110114

115+
// DBPriorityClassName (optional) overrides the priority class for the db pod
116+
// +optional
117+
DBPriorityClassName string `json:"dbPriorityClassName,omitempty"`
118+
111119
// DBVolumeResources (optional) overrides the default PVC resource requirements for the database volume.
112120
// For the time being this field is immutable and can only be set on system creation.
113121
// This is because volume size updates are only supported for increasing the size,
@@ -169,6 +177,10 @@ type NooBaaSpec struct {
169177
// +optional
170178
Region *string `json:"region,omitempty"`
171179

180+
// EndpointPriorityClassName (optional) overrides the priority class for the endpoint pods
181+
// +optional
182+
EndpointPriorityClassName string `json:"endpointPriorityClassName,omitempty"`
183+
172184
// Endpoints (optional) sets configuration info for the noobaa endpoint
173185
// deployment.
174186
// +optional

pkg/backingstore/reconciler.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,6 +1265,15 @@ func (r *Reconciler) needUpdate(pod *corev1.Pod) bool {
12651265
}
12661266
}
12671267

1268+
desiredPriorityClassName := ""
1269+
if r.BackingStore.Spec.PVPool != nil {
1270+
desiredPriorityClassName = r.BackingStore.Spec.PVPool.PriorityClassName
1271+
}
1272+
if pod.Spec.PriorityClassName != desiredPriorityClassName {
1273+
r.Logger.Warnf("Change in PriorityClassName detected")
1274+
return true
1275+
}
1276+
12681277
return false
12691278
}
12701279

@@ -1335,6 +1344,9 @@ func (r *Reconciler) updatePodTemplate() error {
13351344
PodAntiAffinity: r.NooBaa.Spec.Affinity.PodAntiAffinity,
13361345
}
13371346
}
1347+
if r.BackingStore.Spec.PVPool != nil {
1348+
r.PodAgentTemplate.Spec.PriorityClassName = r.BackingStore.Spec.PVPool.PriorityClassName
1349+
}
13381350

13391351
if !util.HasNodeInclusionPolicyInPodTopologySpread() {
13401352
log.Info("TopologySpreadConstraints cannot be set because feature gate NodeInclusionPolicyInPodTopologySpread is not supported on this cluster version")

pkg/bundle/deploy.go

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ spec:
298298
299299
`
300300

301-
const Sha256_deploy_crds_noobaa_io_backingstores_yaml = "2cc6f739e53dfd80ddefe7c0bccd684f3e6a97ade1205a472308c07ae1460736"
301+
const Sha256_deploy_crds_noobaa_io_backingstores_yaml = "e6b5ca2577838c95674c0e36b673bde5816c8bf80d7edb240da7e6918cb346ab"
302302

303303
const File_deploy_crds_noobaa_io_backingstores_yaml = `---
304304
apiVersion: apiextensions.k8s.io/v1
@@ -492,6 +492,10 @@ spec:
492492
numVolumes:
493493
description: NumVolumes is the number of volumes to allocate
494494
type: integer
495+
priorityClassName:
496+
description: PriorityClassName (optional) overrides the priority
497+
class for the pv-pool agent pods
498+
type: string
495499
resources:
496500
description: VolumeResources represents the minimum resources
497501
each volume should have.
@@ -1488,7 +1492,7 @@ spec:
14881492
status: {}
14891493
`
14901494

1491-
const Sha256_deploy_crds_noobaa_io_noobaas_yaml = "623db090807771aa74ee98dd27627e2133c2c489dd28b2d81c209b05bbc81718"
1495+
const Sha256_deploy_crds_noobaa_io_noobaas_yaml = "db6cdcd254d4d85270c2ee1cf656c8b99d2fa0d5662ebcce849cb5fa60ebdd86"
14921496

14931497
const File_deploy_crds_noobaa_io_noobaas_yaml = `---
14941498
apiVersion: apiextensions.k8s.io/v1
@@ -2568,6 +2572,10 @@ spec:
25682572
cleanup confirmation
25692573
type: string
25702574
type: object
2575+
corePriorityClassName:
2576+
description: CorePriorityClassName (optional) overrides the priority
2577+
class for the core pod
2578+
type: string
25712579
coreResources:
25722580
description: CoreResources (optional) overrides the default resource
25732581
requirements for the server container
@@ -2636,6 +2644,10 @@ spec:
26362644
description: DBImage (optional) overrides the default image for the
26372645
db container
26382646
type: string
2647+
dbPriorityClassName:
2648+
description: DBPriorityClassName (optional) overrides the priority
2649+
class for the db pod
2650+
type: string
26392651
dbResources:
26402652
description: DBResources (optional) overrides the default resource
26412653
requirements for the db container
@@ -3036,6 +3048,10 @@ spec:
30363048
numVolumes:
30373049
description: NumVolumes is the number of volumes to allocate
30383050
type: integer
3051+
priorityClassName:
3052+
description: PriorityClassName (optional) overrides the priority
3053+
class for the pv-pool agent pods
3054+
type: string
30393055
resources:
30403056
description: VolumeResources represents the minimum resources
30413057
each volume should have.
@@ -3140,6 +3156,10 @@ spec:
31403156
of openshift route resources in the cluster
31413157
nullable: true
31423158
type: boolean
3159+
endpointPriorityClassName:
3160+
description: EndpointPriorityClassName (optional) overrides the priority
3161+
class for the endpoint pods
3162+
type: string
31433163
endpoints:
31443164
description: |-
31453165
Endpoints (optional) sets configuration info for the noobaa endpoint

pkg/system/db_reconciler.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ func (r *Reconciler) reconcileClusterSpec(dbSpec *nbv1.NooBaaDBSpec) error {
287287
if r.NooBaa.Spec.Tolerations != nil {
288288
r.CNPGCluster.Spec.Affinity.Tolerations = r.NooBaa.Spec.Tolerations
289289
}
290+
r.CNPGCluster.Spec.PriorityClassName = r.NooBaa.Spec.DBPriorityClassName
290291

291292
// by default enable monitoring of the DB instances. if the annotation is "true", disable monitoring
292293
disableMonStr := r.NooBaa.Annotations[nbv1.DisableDBDefaultMonitoring]
@@ -743,5 +744,6 @@ func (r *Reconciler) wasClusterSpecChanged(existingClusterSpec *cnpgv1.ClusterSp
743744
!reflect.DeepEqual(existingClusterSpec.StorageConfiguration.PersistentVolumeClaimTemplate, r.CNPGCluster.Spec.StorageConfiguration.PersistentVolumeClaimTemplate) ||
744745
!reflect.DeepEqual(existingClusterSpec.Monitoring, r.CNPGCluster.Spec.Monitoring) ||
745746
!reflect.DeepEqual(existingClusterSpec.PostgresConfiguration.Parameters, r.CNPGCluster.Spec.PostgresConfiguration.Parameters) ||
746-
!reflect.DeepEqual(existingClusterSpec.Backup, r.CNPGCluster.Spec.Backup)
747+
!reflect.DeepEqual(existingClusterSpec.Backup, r.CNPGCluster.Spec.Backup) ||
748+
existingClusterSpec.PriorityClassName != r.CNPGCluster.Spec.PriorityClassName
747749
}

pkg/system/phase2_creating.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,7 @@ func (r *Reconciler) SetDesiredNooBaaDB() error {
383383
}
384384
podSpec.Tolerations = r.NooBaa.Spec.Tolerations
385385
podSpec.Affinity = r.GetAffinity()
386+
podSpec.PriorityClassName = r.NooBaa.Spec.DBPriorityClassName
386387

387388
if NooBaaDB.UID == "" {
388389
for i := range NooBaaDB.Spec.VolumeClaimTemplates {
@@ -781,6 +782,7 @@ func (r *Reconciler) SetDesiredCoreApp() error {
781782
}
782783
podSpec.Tolerations = r.NooBaa.Spec.Tolerations
783784
podSpec.Affinity = r.GetAffinity()
785+
podSpec.PriorityClassName = r.NooBaa.Spec.CorePriorityClassName
784786

785787
if r.CoreApp.UID == "" {
786788
// generate info event for the first creation of noobaa

pkg/system/phase4_configuring.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ func (r *Reconciler) SetDesiredDeploymentEndpoint() error {
287287
podSpec := &r.DeploymentEndpoint.Spec.Template.Spec
288288
podSpec.Tolerations = r.NooBaa.Spec.Tolerations
289289
podSpec.Affinity = r.GetAffinity()
290+
podSpec.PriorityClassName = r.NooBaa.Spec.EndpointPriorityClassName
290291
if r.NooBaa.Spec.ImagePullSecret == nil {
291292
podSpec.ImagePullSecrets =
292293
[]corev1.LocalObjectReference{}

0 commit comments

Comments
 (0)