Skip to content

Commit 1fa3eb5

Browse files
author
Lars Maier
authored
Sidecar Issues 2 (#434)
* Moved status update to pod creation. Used deepEquals for pointers. * Simplified code. * Deleted comment nobody needs.
1 parent 62bf156 commit 1fa3eb5

File tree

4 files changed

+8
-75
lines changed

4 files changed

+8
-75
lines changed

pkg/apis/deployment/v1alpha/member_status.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ type MemberStatus struct {
5656
// CleanoutJobID holds the ID of the agency job for cleaning out this server
5757
CleanoutJobID string `json:"cleanout-job-id,omitempty"`
5858
// SideCarSpecs contains list of specifications specified for side cars
59-
SideCarSpecs map[string]v1.Container
59+
SideCarSpecs map[string]v1.Container `json:"sidecars-specs,omitempty"`
6060
// ArangoVersion holds the ArangoDB version in member
6161
ArangoVersion driver.Version `json:"arango-version,omitempty"`
6262
//ImageId holds the members ArangoDB image ID

pkg/deployment/reconcile/action_rotate_member.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626
"context"
2727
"time"
2828

29-
"k8s.io/api/core/v1"
3029
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha"
3130
"github.com/rs/zerolog"
3231
)
@@ -119,15 +118,6 @@ func (a *actionRotateMember) CheckProgress(ctx context.Context) (bool, bool, err
119118
m.Phase = api.MemberPhaseNone
120119
m.RecentTerminations = nil // Since we're rotating, we do not care about old terminations.
121120
m.CleanoutJobID = ""
122-
123-
group := a.action.Group
124-
var groupSpec = a.actionCtx.GetSpec().GetServerGroupSpec(group)
125-
// Check for missing side cars in
126-
m.SideCarSpecs = make(map[string]v1.Container)
127-
for _, specSidecar := range groupSpec.GetSidecars() {
128-
m.SideCarSpecs[specSidecar.Name] = *specSidecar.DeepCopy()
129-
}
130-
131121
if err := a.actionCtx.UpdateMember(m); err != nil {
132122
return false, false, maskAny(err)
133123
}

pkg/deployment/reconcile/plan_builder.go

Lines changed: 1 addition & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -429,70 +429,7 @@ func podNeedsRotation(log zerolog.Logger, p v1.Pod, apiObject metav1.Object, spe
429429

430430
// sideCarRequireRotation checks if side car requires rotation including default parameters
431431
func sideCarRequireRotation(wanted, given *v1.Container) bool {
432-
if !reflect.DeepEqual(wanted.Args, given.Args) {
433-
return true
434-
}
435-
if !reflect.DeepEqual(wanted.Command, given.Command) {
436-
return true
437-
}
438-
if !reflect.DeepEqual(wanted.Env, given.Env) {
439-
return true
440-
}
441-
if !reflect.DeepEqual(wanted.EnvFrom, given.EnvFrom) {
442-
return true
443-
}
444-
if wanted.Image != given.Image {
445-
return true
446-
}
447-
if wanted.ImagePullPolicy != given.ImagePullPolicy {
448-
if wanted.ImagePullPolicy != "Always" || !strings.HasSuffix(given.Image, ":latest") {
449-
return true
450-
}
451-
}
452-
if wanted.Lifecycle != given.Lifecycle {
453-
return true
454-
}
455-
if wanted.LivenessProbe != given.LivenessProbe {
456-
return true
457-
}
458-
if !reflect.DeepEqual(wanted.Ports, given.Ports) {
459-
return true
460-
}
461-
if wanted.ReadinessProbe != given.ReadinessProbe {
462-
return true
463-
}
464-
if !reflect.DeepEqual(wanted.Resources, given.Resources) {
465-
return true
466-
}
467-
if wanted.SecurityContext != given.SecurityContext {
468-
return true
469-
}
470-
if wanted.Stdin != given.Stdin {
471-
return true
472-
}
473-
if wanted.StdinOnce != given.StdinOnce {
474-
return true
475-
}
476-
if wanted.TerminationMessagePath != given.TerminationMessagePath {
477-
return true
478-
}
479-
if wanted.TerminationMessagePolicy != given.TerminationMessagePolicy {
480-
return true
481-
}
482-
if wanted.TTY != given.TTY {
483-
return true
484-
}
485-
if !reflect.DeepEqual(wanted.VolumeDevices, given.VolumeDevices) {
486-
return true
487-
}
488-
if !reflect.DeepEqual(wanted.VolumeMounts, given.VolumeMounts) {
489-
return true
490-
}
491-
if wanted.WorkingDir != given.WorkingDir {
492-
return true
493-
}
494-
495-
return false
432+
return !reflect.DeepEqual(wanted, given)
496433
}
497434

498435
// resourcesRequireRotation returns true if the resource requirements have changed such that a rotation is required

pkg/deployment/resources/pod_creator.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,12 @@ func (r *Resources) createPodForMember(spec api.DeploymentSpec, memberID string,
671671
m.ArangoVersion = status.CurrentImage.ArangoDBVersion
672672
m.ImageID = status.CurrentImage.ImageID
673673

674+
// Check for missing side cars in
675+
m.SideCarSpecs = make(map[string]v1.Container)
676+
for _, specSidecar := range groupSpec.GetSidecars() {
677+
m.SideCarSpecs[specSidecar.Name] = *specSidecar.DeepCopy()
678+
}
679+
674680
log.Debug().Str("pod-name", m.PodName).Msg("Created pod")
675681
} else if group.IsArangosync() {
676682
// Check image

0 commit comments

Comments
 (0)