Skip to content

Commit

Permalink
Sidecar Issues 2 (#434)
Browse files Browse the repository at this point in the history
* Moved status update to pod creation. Used deepEquals for pointers.
* Simplified code.
* Deleted comment nobody needs.
  • Loading branch information
Lars Maier authored Aug 6, 2019
1 parent 62bf156 commit 1fa3eb5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 75 deletions.
2 changes: 1 addition & 1 deletion pkg/apis/deployment/v1alpha/member_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ type MemberStatus struct {
// CleanoutJobID holds the ID of the agency job for cleaning out this server
CleanoutJobID string `json:"cleanout-job-id,omitempty"`
// SideCarSpecs contains list of specifications specified for side cars
SideCarSpecs map[string]v1.Container
SideCarSpecs map[string]v1.Container `json:"sidecars-specs,omitempty"`
// ArangoVersion holds the ArangoDB version in member
ArangoVersion driver.Version `json:"arango-version,omitempty"`
//ImageId holds the members ArangoDB image ID
Expand Down
10 changes: 0 additions & 10 deletions pkg/deployment/reconcile/action_rotate_member.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"context"
"time"

"k8s.io/api/core/v1"
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha"
"github.com/rs/zerolog"
)
Expand Down Expand Up @@ -119,15 +118,6 @@ func (a *actionRotateMember) CheckProgress(ctx context.Context) (bool, bool, err
m.Phase = api.MemberPhaseNone
m.RecentTerminations = nil // Since we're rotating, we do not care about old terminations.
m.CleanoutJobID = ""

group := a.action.Group
var groupSpec = a.actionCtx.GetSpec().GetServerGroupSpec(group)
// Check for missing side cars in
m.SideCarSpecs = make(map[string]v1.Container)
for _, specSidecar := range groupSpec.GetSidecars() {
m.SideCarSpecs[specSidecar.Name] = *specSidecar.DeepCopy()
}

if err := a.actionCtx.UpdateMember(m); err != nil {
return false, false, maskAny(err)
}
Expand Down
65 changes: 1 addition & 64 deletions pkg/deployment/reconcile/plan_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,70 +429,7 @@ func podNeedsRotation(log zerolog.Logger, p v1.Pod, apiObject metav1.Object, spe

// sideCarRequireRotation checks if side car requires rotation including default parameters
func sideCarRequireRotation(wanted, given *v1.Container) bool {
if !reflect.DeepEqual(wanted.Args, given.Args) {
return true
}
if !reflect.DeepEqual(wanted.Command, given.Command) {
return true
}
if !reflect.DeepEqual(wanted.Env, given.Env) {
return true
}
if !reflect.DeepEqual(wanted.EnvFrom, given.EnvFrom) {
return true
}
if wanted.Image != given.Image {
return true
}
if wanted.ImagePullPolicy != given.ImagePullPolicy {
if wanted.ImagePullPolicy != "Always" || !strings.HasSuffix(given.Image, ":latest") {
return true
}
}
if wanted.Lifecycle != given.Lifecycle {
return true
}
if wanted.LivenessProbe != given.LivenessProbe {
return true
}
if !reflect.DeepEqual(wanted.Ports, given.Ports) {
return true
}
if wanted.ReadinessProbe != given.ReadinessProbe {
return true
}
if !reflect.DeepEqual(wanted.Resources, given.Resources) {
return true
}
if wanted.SecurityContext != given.SecurityContext {
return true
}
if wanted.Stdin != given.Stdin {
return true
}
if wanted.StdinOnce != given.StdinOnce {
return true
}
if wanted.TerminationMessagePath != given.TerminationMessagePath {
return true
}
if wanted.TerminationMessagePolicy != given.TerminationMessagePolicy {
return true
}
if wanted.TTY != given.TTY {
return true
}
if !reflect.DeepEqual(wanted.VolumeDevices, given.VolumeDevices) {
return true
}
if !reflect.DeepEqual(wanted.VolumeMounts, given.VolumeMounts) {
return true
}
if wanted.WorkingDir != given.WorkingDir {
return true
}

return false
return !reflect.DeepEqual(wanted, given)
}

// resourcesRequireRotation returns true if the resource requirements have changed such that a rotation is required
Expand Down
6 changes: 6 additions & 0 deletions pkg/deployment/resources/pod_creator.go
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,12 @@ func (r *Resources) createPodForMember(spec api.DeploymentSpec, memberID string,
m.ArangoVersion = status.CurrentImage.ArangoDBVersion
m.ImageID = status.CurrentImage.ImageID

// Check for missing side cars in
m.SideCarSpecs = make(map[string]v1.Container)
for _, specSidecar := range groupSpec.GetSidecars() {
m.SideCarSpecs[specSidecar.Name] = *specSidecar.DeepCopy()
}

log.Debug().Str("pod-name", m.PodName).Msg("Created pod")
} else if group.IsArangosync() {
// Check image
Expand Down

0 comments on commit 1fa3eb5

Please sign in to comment.