Skip to content

Commit f3bbbb1

Browse files
authored
refactor: Remove priority classes from executor CR (#374)
* Remove priority classes from executor CR Signed-off-by: Jason Parraga <sovietaced@gmail.com> * make ... Signed-off-by: Jason Parraga <sovietaced@gmail.com> --------- Signed-off-by: Jason Parraga <sovietaced@gmail.com>
1 parent 0943b0b commit f3bbbb1

File tree

8 files changed

+3
-169
lines changed

8 files changed

+3
-169
lines changed

api/install/v1alpha1/executor_types.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package v1alpha1
1818

1919
import (
2020
corev1 "k8s.io/api/core/v1"
21-
schedulingv1 "k8s.io/api/scheduling/v1"
2221
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2322
)
2423

@@ -56,8 +55,6 @@ type ExecutorSpec struct {
5655
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
5756
// Additional ClusterRoleBindings which will be created
5857
AdditionalClusterRoleBindings []AdditionalClusterRoleBinding `json:"additionalClusterRoleBindings,omitempty"`
59-
// List of PriorityClasses which will be created
60-
PriorityClasses []*schedulingv1.PriorityClass `json:"priorityClasses,omitempty"`
6158
// SecurityContext defines the security options the container should be run with
6259
SecurityContext *corev1.SecurityContext `json:"securityContext,omitempty"`
6360
// PodSecurityContext defines the security options the pod should be run with

api/install/v1alpha1/zz_generated.deepcopy.go

Lines changed: 0 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

charts/armada-operator/crds/executor-crd.yaml

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -2299,62 +2299,6 @@ spec:
22992299
type: string
23002300
type: object
23012301
type: object
2302-
priorityClasses:
2303-
description: List of PriorityClasses which will be created
2304-
items:
2305-
description: |-
2306-
PriorityClass defines mapping from a priority class name to the priority
2307-
integer value. The value can be any valid integer.
2308-
properties:
2309-
apiVersion:
2310-
description: |-
2311-
APIVersion defines the versioned schema of this representation of an object.
2312-
Servers should convert recognized schemas to the latest internal value, and
2313-
may reject unrecognized values.
2314-
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
2315-
type: string
2316-
description:
2317-
description: |-
2318-
description is an arbitrary string that usually provides guidelines on
2319-
when this priority class should be used.
2320-
type: string
2321-
globalDefault:
2322-
description: |-
2323-
globalDefault specifies whether this PriorityClass should be considered as
2324-
the default priority for pods that do not have any priority class.
2325-
Only one PriorityClass can be marked as `globalDefault`. However, if more than
2326-
one PriorityClasses exists with their `globalDefault` field set to true,
2327-
the smallest value of such global default PriorityClasses will be used as the default priority.
2328-
type: boolean
2329-
kind:
2330-
description: |-
2331-
Kind is a string value representing the REST resource this object represents.
2332-
Servers may infer this from the endpoint the client submits requests to.
2333-
Cannot be updated.
2334-
In CamelCase.
2335-
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
2336-
type: string
2337-
metadata:
2338-
description: |-
2339-
Standard object's metadata.
2340-
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
2341-
type: object
2342-
preemptionPolicy:
2343-
description: |-
2344-
preemptionPolicy is the Policy for preempting pods with lower priority.
2345-
One of Never, PreemptLowerPriority.
2346-
Defaults to PreemptLowerPriority if unset.
2347-
type: string
2348-
value:
2349-
description: |-
2350-
value represents the integer value of this priority class. This is the actual priority that pods
2351-
receive when they have the name of this class in their pod spec.
2352-
format: int32
2353-
type: integer
2354-
required:
2355-
- value
2356-
type: object
2357-
type: array
23582302
profilingIngressConfig:
23592303
description: ProfilingIngressConfig defines configuration for the
23602304
profiling Ingress resource

config/crd/bases/install.armadaproject.io_executors.yaml

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -2289,62 +2289,6 @@ spec:
22892289
type: string
22902290
type: object
22912291
type: object
2292-
priorityClasses:
2293-
description: List of PriorityClasses which will be created
2294-
items:
2295-
description: |-
2296-
PriorityClass defines mapping from a priority class name to the priority
2297-
integer value. The value can be any valid integer.
2298-
properties:
2299-
apiVersion:
2300-
description: |-
2301-
APIVersion defines the versioned schema of this representation of an object.
2302-
Servers should convert recognized schemas to the latest internal value, and
2303-
may reject unrecognized values.
2304-
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
2305-
type: string
2306-
description:
2307-
description: |-
2308-
description is an arbitrary string that usually provides guidelines on
2309-
when this priority class should be used.
2310-
type: string
2311-
globalDefault:
2312-
description: |-
2313-
globalDefault specifies whether this PriorityClass should be considered as
2314-
the default priority for pods that do not have any priority class.
2315-
Only one PriorityClass can be marked as `globalDefault`. However, if more than
2316-
one PriorityClasses exists with their `globalDefault` field set to true,
2317-
the smallest value of such global default PriorityClasses will be used as the default priority.
2318-
type: boolean
2319-
kind:
2320-
description: |-
2321-
Kind is a string value representing the REST resource this object represents.
2322-
Servers may infer this from the endpoint the client submits requests to.
2323-
Cannot be updated.
2324-
In CamelCase.
2325-
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
2326-
type: string
2327-
metadata:
2328-
description: |-
2329-
Standard object's metadata.
2330-
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
2331-
type: object
2332-
preemptionPolicy:
2333-
description: |-
2334-
preemptionPolicy is the Policy for preempting pods with lower priority.
2335-
One of Never, PreemptLowerPriority.
2336-
Defaults to PreemptLowerPriority if unset.
2337-
type: string
2338-
value:
2339-
description: |-
2340-
value represents the integer value of this priority class. This is the actual priority that pods
2341-
receive when they have the name of this class in their pod spec.
2342-
format: int32
2343-
type: integer
2344-
required:
2345-
- value
2346-
type: object
2347-
type: array
23482292
profilingIngressConfig:
23492293
description: ProfilingIngressConfig defines configuration for the
23502294
profiling Ingress resource

dev/crd/out.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,6 @@ _Appears in:_
472472
| `replicas` _integer_ | Replicas is the number of replicated instances for Executor | | |
473473
| `nodeSelector` _object (keys:string, values:string)_ | NodeSelector restricts the Executor pod to run on nodes matching the configured selectors | | |
474474
| `additionalClusterRoleBindings` _[AdditionalClusterRoleBinding](#additionalclusterrolebinding) array_ | Additional ClusterRoleBindings which will be created | | |
475-
| `priorityClasses` _[PriorityClass](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.29/#priorityclass-v1-scheduling) array_ | List of PriorityClasses which will be created | | |
476475
| `securityContext` _[SecurityContext](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.29/#securitycontext-v1-core)_ | SecurityContext defines the security options the container should be run with | | |
477476
| `podSecurityContext` _[PodSecurityContext](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.29/#podsecuritycontext-v1-core)_ | PodSecurityContext defines the security options the pod should be run with | | |
478477
| `profilingIngressConfig` _[IngressConfig](#ingressconfig)_ | ProfilingIngressConfig defines configuration for the profiling Ingress resource | | |

internal/controller/install/common_helpers.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ import (
2020

2121
monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
2222

23-
schedulingv1 "k8s.io/api/scheduling/v1"
24-
2523
appsv1 "k8s.io/api/apps/v1"
2624
batchv1 "k8s.io/api/batch/v1"
2725
corev1 "k8s.io/api/core/v1"
@@ -61,7 +59,6 @@ type CommonComponents struct {
6159
Secret *corev1.Secret
6260
ClusterRole *rbacv1.ClusterRole
6361
ClusterRoleBindings []*rbacv1.ClusterRoleBinding
64-
PriorityClasses []*schedulingv1.PriorityClass
6562
PrometheusRule *monitoringv1.PrometheusRule
6663
ServiceMonitor *monitoringv1.ServiceMonitor
6764
PodDisruptionBudget *policyv1.PodDisruptionBudget
@@ -78,10 +75,6 @@ func (cc *CommonComponents) DeepCopy() *CommonComponents {
7875
for _, crb := range cc.ClusterRoleBindings {
7976
clusterRoleBindings = append(clusterRoleBindings, crb.DeepCopy())
8077
}
81-
var priorityClasses []*schedulingv1.PriorityClass
82-
for _, pc := range cc.PriorityClasses {
83-
priorityClasses = append(priorityClasses, pc.DeepCopy())
84-
}
8578
var jobs []*batchv1.Job
8679
for _, job := range cc.Jobs {
8780
jobs = append(jobs, job.DeepCopy())
@@ -95,7 +88,6 @@ func (cc *CommonComponents) DeepCopy() *CommonComponents {
9588
Secret: cc.Secret.DeepCopy(),
9689
ClusterRole: cc.ClusterRole.DeepCopy(),
9790
ClusterRoleBindings: clusterRoleBindings,
98-
PriorityClasses: priorityClasses,
9991
Jobs: jobs,
10092
CronJob: cc.CronJob.DeepCopy(),
10193
ServiceMonitor: cc.ServiceMonitor.DeepCopy(),
@@ -190,14 +182,6 @@ func (cc *CommonComponents) ReconcileComponents(newComponents *CommonComponents)
190182
cc.ClusterRoleBindings[i].Labels = newComponents.ClusterRoleBindings[i].Labels
191183
cc.ClusterRoleBindings[i].Annotations = newComponents.ClusterRoleBindings[i].Annotations
192184
}
193-
for i := range cc.PriorityClasses {
194-
cc.PriorityClasses[i].PreemptionPolicy = newComponents.PriorityClasses[i].PreemptionPolicy
195-
cc.PriorityClasses[i].Value = newComponents.PriorityClasses[i].Value
196-
cc.PriorityClasses[i].Description = newComponents.PriorityClasses[i].Description
197-
cc.PriorityClasses[i].GlobalDefault = newComponents.PriorityClasses[i].GlobalDefault
198-
cc.PriorityClasses[i].Labels = newComponents.PriorityClasses[i].Labels
199-
cc.PriorityClasses[i].Annotations = newComponents.PriorityClasses[i].Annotations
200-
}
201185

202186
if newComponents.CronJob != nil {
203187
cc.CronJob.Spec = newComponents.CronJob.Spec

internal/controller/install/common_helpers_test.go

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import (
2929
appsv1 "k8s.io/api/apps/v1"
3030
batchv1 "k8s.io/api/batch/v1"
3131
corev1 "k8s.io/api/core/v1"
32-
schedulingv1 "k8s.io/api/scheduling/v1"
3332
k8serrors "k8s.io/apimachinery/pkg/api/errors"
3433
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3534
"k8s.io/apimachinery/pkg/runtime"
@@ -650,8 +649,6 @@ func TestDeepCopy(t *testing.T) {
650649
expectations: func(t *testing.T, old, new CommonComponents) {
651650
assert.EqualValues(t, old.Deployment, new.Deployment)
652651
assert.NotSame(t, old.Deployment, new.Deployment)
653-
assert.Equal(t, len(old.PriorityClasses), len(new.PriorityClasses))
654-
assert.NotSame(t, &old.PriorityClasses, &new.PriorityClasses)
655652
assert.Equal(t, old, new)
656653
assert.NotSame(t, &old, &new)
657654
},
@@ -791,18 +788,13 @@ func makeCommonComponents() CommonComponents {
791788
AutomountServiceAccountToken: &automountServiceAccountToken,
792789
}
793790

794-
pc := schedulingv1.PriorityClass{
795-
Value: 1000,
796-
}
797-
798791
secret := corev1.Secret{
799792
StringData: map[string]string{"secretkey": "secretval"},
800793
}
801794
return CommonComponents{
802-
Deployment: &deployment,
803-
ServiceAccount: &serviceAccount,
804-
PriorityClasses: []*schedulingv1.PriorityClass{&pc},
805-
Secret: &secret,
795+
Deployment: &deployment,
796+
ServiceAccount: &serviceAccount,
797+
Secret: &secret,
806798
}
807799
}
808800

internal/controller/install/executor_controller.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,6 @@ func (r *ExecutorReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
142142
return ctrl.Result{}, err
143143
}
144144

145-
for _, pc := range components.PriorityClasses {
146-
if err := upsertObjectIfNeeded(ctx, r.Client, pc, executor.Kind, mutateFn, logger); err != nil {
147-
return ctrl.Result{}, err
148-
}
149-
}
150-
151145
if err := upsertObjectIfNeeded(ctx, r.Client, components.PrometheusRule, executor.Kind, mutateFn, logger); err != nil {
152146
return ctrl.Result{}, err
153147
}
@@ -222,7 +216,6 @@ func (r *ExecutorReconciler) generateExecutorInstallComponents(
222216
ServiceAccount: serviceAccount,
223217
Secret: secret,
224218
ClusterRoleBindings: clusterRoleBindings,
225-
PriorityClasses: executor.Spec.PriorityClasses,
226219
ClusterRole: clusterRole,
227220
ServiceProfiling: profilingService,
228221
IngressProfiling: profilingIngress,
@@ -514,13 +507,6 @@ func (r *ExecutorReconciler) deleteExternalResources(ctx context.Context, compon
514507
logger.Info("Successfully deleted Executor ClusterRoleBinding", "name", crb.Name)
515508
}
516509

517-
for _, pc := range components.PriorityClasses {
518-
if err := r.Delete(ctx, pc); err != nil && !k8serrors.IsNotFound(err) {
519-
return errors.Wrapf(err, "error deleting ClusterRoleBinding %s", pc.Name)
520-
}
521-
logger.Info("Successfully deleted Executor PriorityClass", "name", pc.Name)
522-
}
523-
524510
return nil
525511
}
526512

0 commit comments

Comments
 (0)