Skip to content

Commit 6747623

Browse files
author
lamai93
committed
Added some ideas for pod rotation for changing requirements.
1 parent 252f01e commit 6747623

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

pkg/deployment/reconcile/plan_builder.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,13 @@ func podNeedsRotation(log zerolog.Logger, p v1.Pod, apiObject metav1.Object, spe
345345
return true, "ServiceAccountName changed"
346346
}
347347

348+
// Check resource requirements
349+
// Kubernetes will fill in some default values thus this will always rotate the pod.
350+
// One could come up with something more sophisticated to check if a rotation is needed. (check if the requirements are more than requested and limits are less than requested)
351+
/*if !reflect.DeepEqual(spec.GetServerGroupSpec(group).Resources, k8sutil.GetArangoDBContainerFromPod(&p).Resources) {
352+
return true, "Resource Requirements changed"
353+
}*/
354+
348355
return false, ""
349356
}
350357

pkg/util/k8sutil/images.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,17 @@ func GetArangoDBImageIDFromPod(pod *corev1.Pod) string {
5353
}
5454
return ConvertImageID2Image(rawImageID)
5555
}
56+
57+
// GetArangoDBContainerFromPod returns the ArangoDB container from a pod
58+
func GetArangoDBContainerFromPod(pod *corev1.Pod) corev1.Container {
59+
arangoc := pod.Spec.Containers[0]
60+
if len(pod.Status.ContainerStatuses) > 1 {
61+
for _, container := range pod.Spec.Containers {
62+
if strings.Contains(container.Name, "server") {
63+
arangoc = container
64+
}
65+
}
66+
}
67+
68+
return arangoc
69+
}

pkg/util/k8sutil/pods.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ func arangodInitContainer(name, id, engine, alpineImage string, requireUUID bool
263263
return c
264264
}
265265

266+
// filterStorageResourceRequirement filters resource requirements for Storage.
266267
func filterStorageResourceRequirement(resources v1.ResourceRequirements) v1.ResourceRequirements {
267268

268269
filterStorage := func(list v1.ResourceList) v1.ResourceList {
@@ -298,7 +299,7 @@ func arangodContainer(image string, imagePullPolicy v1.PullPolicy, args []string
298299
Protocol: v1.ProtocolTCP,
299300
},
300301
},
301-
Resources: filterStorageResourceRequirement(resources),
302+
Resources: filterStorageResourceRequirement(resources), // Storage is handled via pvcs
302303
VolumeMounts: arangodVolumeMounts(),
303304
}
304305
for k, v := range env {

0 commit comments

Comments
 (0)