Skip to content

Commit 093aaf2

Browse files
author
lamai93
committed
Forward priorities to the pod.
1 parent a1904cd commit 093aaf2

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

pkg/apis/deployment/v1alpha/server_group_spec.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ type ServerGroupSpec struct {
5858
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
5959
// Probes specifies additional behaviour for probes
6060
Probes *ServerGroupProbesSpec `json:"probes,omitempty"`
61+
// PriorityClassName specifies a priority class name
62+
PriorityClassName string `json:"priorityClassName,omitempty"`
63+
// Priority specifies the pod priority
64+
Priority *int32 `json:"priority,omitempty"`
6165
}
6266

6367
// ServerGroupProbesSpec contains specification for probes for pods of the server group

pkg/deployment/resources/pod_creator.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ func (r *Resources) createPodForMember(spec api.DeploymentSpec, memberID string,
607607
finalizers := r.createPodFinalizers(group)
608608
if err := k8sutil.CreateArangodPod(kubecli, spec.IsDevelopment(), apiObject, role, m.ID, m.PodName, m.PersistentVolumeClaimName, imageInfo.ImageID, lifecycleImage, alpineImage, spec.GetImagePullPolicy(),
609609
engine, requireUUID, terminationGracePeriod, args, env, finalizers, livenessProbe, readinessProbe, tolerations, serviceAccountName, tlsKeyfileSecretName, rocksdbEncryptionSecretName,
610-
clusterJWTSecretName, groupSpec.GetNodeSelector()); err != nil {
610+
clusterJWTSecretName, groupSpec.GetNodeSelector(), groupSpec.PriorityClassName, groupSpec.Priority); err != nil {
611611
return maskAny(err)
612612
}
613613
log.Debug().Str("pod-name", m.PodName).Msg("Created pod")
@@ -689,7 +689,8 @@ func (r *Resources) createPodForMember(spec api.DeploymentSpec, memberID string,
689689
affinityWithRole = api.ServerGroupDBServers.AsRole()
690690
}
691691
if err := k8sutil.CreateArangoSyncPod(kubecli, spec.IsDevelopment(), apiObject, role, m.ID, m.PodName, imageID, lifecycleImage, spec.GetImagePullPolicy(), terminationGracePeriod, args, env,
692-
livenessProbe, tolerations, serviceAccountName, tlsKeyfileSecretName, clientAuthCASecretName, masterJWTSecretName, clusterJWTSecretName, affinityWithRole, groupSpec.GetNodeSelector()); err != nil {
692+
livenessProbe, tolerations, serviceAccountName, tlsKeyfileSecretName, clientAuthCASecretName, masterJWTSecretName, clusterJWTSecretName, affinityWithRole, groupSpec.GetNodeSelector(),
693+
groupSpec.PriorityClassName, groupSpec.Priority); err != nil {
693694
return maskAny(err)
694695
}
695696
log.Debug().Str("pod-name", m.PodName).Msg("Created pod")

pkg/util/k8sutil/pods.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,8 @@ func CreateArangodPod(kubecli kubernetes.Interface, developmentMode bool, deploy
434434
engine string, requireUUID bool, terminationGracePeriod time.Duration,
435435
args []string, env map[string]EnvValue, finalizers []string,
436436
livenessProbe *HTTPProbeConfig, readinessProbe *HTTPProbeConfig, tolerations []v1.Toleration, serviceAccountName string,
437-
tlsKeyfileSecretName, rocksdbEncryptionSecretName string, clusterJWTSecretName string, nodeSelector map[string]string) error {
437+
tlsKeyfileSecretName, rocksdbEncryptionSecretName string, clusterJWTSecretName string, nodeSelector map[string]string,
438+
podPriorityClassName string, podPriority *int32) error {
438439
// Prepare basic pod
439440
p := newPod(deployment.GetName(), deployment.GetNamespace(), role, id, podName, finalizers, tolerations, serviceAccountName, nodeSelector)
440441
terminationGracePeriodSeconds := int64(math.Ceil(terminationGracePeriod.Seconds()))
@@ -469,6 +470,10 @@ func CreateArangodPod(kubecli kubernetes.Interface, developmentMode bool, deploy
469470
}
470471
p.Spec.Containers = append(p.Spec.Containers, c)
471472

473+
// Add priority and priorityClassName
474+
p.Spec.Priority = podPriority
475+
p.Spec.PriorityClassName = podPriorityClassName
476+
472477
// Add UUID init container
473478
if alpineImage != "" {
474479
p.Spec.InitContainers = append(p.Spec.InitContainers, arangodInitContainer("uuid", id, engine, alpineImage, requireUUID))
@@ -553,7 +558,8 @@ func CreateArangodPod(kubecli kubernetes.Interface, developmentMode bool, deploy
553558
// If another error occurs, that error is returned.
554559
func CreateArangoSyncPod(kubecli kubernetes.Interface, developmentMode bool, deployment APIObject, role, id, podName, image, lifecycleImage string, imagePullPolicy v1.PullPolicy,
555560
terminationGracePeriod time.Duration, args []string, env map[string]EnvValue, livenessProbe *HTTPProbeConfig, tolerations []v1.Toleration, serviceAccountName string,
556-
tlsKeyfileSecretName, clientAuthCASecretName, masterJWTSecretName, clusterJWTSecretName, affinityWithRole string, nodeSelector map[string]string) error {
561+
tlsKeyfileSecretName, clientAuthCASecretName, masterJWTSecretName, clusterJWTSecretName, affinityWithRole string, nodeSelector map[string]string,
562+
podPriorityClassName string, podPriority *int32) error {
557563
// Prepare basic pod
558564
p := newPod(deployment.GetName(), deployment.GetNamespace(), role, id, podName, nil, tolerations, serviceAccountName, nodeSelector)
559565
terminationGracePeriodSeconds := int64(math.Ceil(terminationGracePeriod.Seconds()))
@@ -594,6 +600,10 @@ func CreateArangoSyncPod(kubecli kubernetes.Interface, developmentMode bool, dep
594600
}
595601
p.Spec.Containers = append(p.Spec.Containers, c)
596602

603+
// Add priority and priorityClassName
604+
p.Spec.Priority = podPriority
605+
p.Spec.PriorityClassName = podPriorityClassName
606+
597607
// TLS keyfile secret mount (if any)
598608
if tlsKeyfileSecretName != "" {
599609
vol := v1.Volume{

0 commit comments

Comments
 (0)