Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
9dd5592
added side care changes to pod rotation
kvahed Jul 17, 2019
e413ea3
change log
kvahed Jul 17, 2019
611ba0e
only one check is sufficient
kvahed Jul 17, 2019
ad37050
typo
kvahed Jul 18, 2019
7399018
documentation
kvahed Jul 18, 2019
fdaa051
Merge branch 'feature/restart-pods-on-sidecar-changes' of https://git…
kvahed Jul 18, 2019
66a22ba
:beers: going forward :beers:
kvahed Jul 19, 2019
bd10352
working version tests missing
kvahed Jul 22, 2019
01501e9
working version tests missing
kvahed Jul 22, 2019
65bbc91
some cleanup
kvahed Jul 22, 2019
dce9be0
tests
kvahed Jul 23, 2019
27ecedb
tests
kvahed Jul 23, 2019
f34045e
go.sum undone
kvahed Jul 25, 2019
ec34b5e
missing comments
kvahed Jul 25, 2019
20b050d
merge in master
kvahed Jul 25, 2019
7fdae6e
no longer needed
kvahed Jul 25, 2019
d86f05b
assets.go back to master version
kvahed Jul 25, 2019
ab44cac
go fmt
kvahed Jul 25, 2019
438ed7c
Merge branch 'master' of https://github.com/arangodb/kube-arangodb in…
kvahed Jul 26, 2019
9a6a002
default bool checks plain wrong
kvahed Jul 26, 2019
cf8aa9a
side cars effect db servers
kvahed Jul 26, 2019
6114cf9
sidecar tests
kvahed Jul 26, 2019
3e14e51
formatting errors lol
kvahed Jul 26, 2019
b6031f8
almost there
kvahed Jul 30, 2019
abb046a
sidecar test
kvahed Jul 30, 2019
be746e2
master merge
kvahed Jul 30, 2019
b15d50d
tests done-ish
kvahed Jul 30, 2019
398cf61
fixes
kvahed Jul 30, 2019
b02c722
renamed tests
kvahed Jul 30, 2019
3e743f1
this is weird
kvahed Jul 30, 2019
99fb321
correct tests removing trace output
kvahed Jul 30, 2019
3f4117e
merge
kvahed Jul 30, 2019
6353244
clean up
kvahed Jul 30, 2019
68a13b7
clean up
kvahed Jul 30, 2019
9d21ec5
clean up
kvahed Jul 30, 2019
35c10a3
typo
kvahed Jul 30, 2019
e9656ee
typo
kvahed Jul 30, 2019
02ece1d
fair point
kvahed Jul 30, 2019
e42362b
typo
kvahed Jul 31, 2019
9b0c79d
typos
kvahed Jul 31, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Change Log

## [0.3.13]() (XXXX-XX-XX)
- Added side car changed to pod rotation criterium
- Added ArangoDB version and image id to member status

## [0.3.12](https://github.com/arangodb/kube-arangodb/tree/0.3.12) (2019-07-04)
Expand Down
2 changes: 1 addition & 1 deletion docs/Manual/Tutorials/Kubernetes/bare-metal.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ kubectl get all --all-namespaces
- Attach `tiller` to proper role

```
kubectl create clusterrolebinding tiller-cluster-rule \
kubectl create clusterrolebinding tiller-cluster-rule \
--clusterrole=cluster-admin --serviceaccount=kube-system:tiller
```
```
Expand Down
4 changes: 3 additions & 1 deletion pkg/apis/deployment/v1alpha/deployment_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@

package v1alpha

import "github.com/arangodb/kube-arangodb/pkg/util"
import (
"github.com/arangodb/kube-arangodb/pkg/util"
)

// DeploymentStatus contains the status part of a Cluster resource.
type DeploymentStatus struct {
Expand Down
4 changes: 4 additions & 0 deletions pkg/apis/deployment/v1alpha/member_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
package v1alpha

import (
"reflect"
"time"

driver "github.com/arangodb/go-driver"
Expand Down Expand Up @@ -54,6 +55,8 @@ type MemberStatus struct {
IsInitialized bool `json:"initialized"`
// 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
// ArangoVersion holds the ArangoDB version in member
ArangoVersion driver.Version `json:"arango-version,omitempty"`
//ImageId holds the members ArangoDB image ID
Expand All @@ -70,6 +73,7 @@ func (s MemberStatus) Equal(other MemberStatus) bool {
s.Conditions.Equal(other.Conditions) &&
s.IsInitialized == other.IsInitialized &&
s.CleanoutJobID == other.CleanoutJobID &&
reflect.DeepEqual(s.SideCarSpecs, other.SideCarSpecs) &&
s.ArangoVersion == other.ArangoVersion &&
s.ImageID == other.ImageID
}
Expand Down
7 changes: 7 additions & 0 deletions pkg/deployment/reconcile/action_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ type ActionContext interface {
GetDeploymentHealth() (driver.ClusterHealth, error)
// InvalidateSyncStatus resets the sync state to false and triggers an inspection
InvalidateSyncStatus()
// GetSpec returns a copy of the spec
GetSpec() api.DeploymentSpec

}

// newActionContext creates a new ActionContext implementation.
Expand All @@ -109,6 +112,10 @@ func (ac *actionContext) GetMode() api.DeploymentMode {
return ac.context.GetSpec().GetMode()
}

func (ac *actionContext) GetSpec() api.DeploymentSpec {
return ac.context.GetSpec()
}

// GetDeploymentHealth returns a copy of the latest known state of cluster health
func (ac *actionContext) GetDeploymentHealth() (driver.ClusterHealth, error) {
return ac.context.GetDeploymentHealth()
Expand Down
11 changes: 11 additions & 0 deletions pkg/deployment/reconcile/action_rotate_member.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ 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 @@ -89,6 +90,7 @@ func (a *actionRotateMember) Start(ctx context.Context) (bool, error) {
}
// Update status
m.Phase = api.MemberPhaseRotating

if err := a.actionCtx.UpdateMember(m); err != nil {
return false, maskAny(err)
}
Expand Down Expand Up @@ -117,6 +119,15 @@ 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
100 changes: 99 additions & 1 deletion pkg/deployment/reconcile/plan_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,18 @@
package reconcile

import (
"reflect"
"strings"

driver "github.com/arangodb/go-driver"
upgraderules "github.com/arangodb/go-upgrade-rules"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
v1 "k8s.io/api/core/v1"
)

// upgradeDecision is the result of an upgrade check.
Expand Down Expand Up @@ -394,9 +395,106 @@ func podNeedsRotation(log zerolog.Logger, p v1.Pod, apiObject metav1.Object, spe
return true, "Resource Requirements changed"
}

var memberStatus, _, _ = status.Members.MemberStatusByPodName(p.GetName())
if memberStatus.SideCarSpecs == nil {
memberStatus.SideCarSpecs = make(map[string]v1.Container)
}

// Check for missing side cars in
for _, specSidecar := range groupSpec.GetSidecars() {
var stateSidecar v1.Container
if stateSidecar, found = memberStatus.SideCarSpecs[specSidecar.Name]; !found {
return true, "Sidecar " + specSidecar.Name + " not found in running pod " + p.GetName()
}
if sideCarRequireRotation(specSidecar.DeepCopy(), &stateSidecar) {
return true, "Sidecar " + specSidecar.Name + " requires rotation"
}
}

for name := range memberStatus.SideCarSpecs {
var found = false
for _, specSidecar := range groupSpec.GetSidecars() {
if name == specSidecar.Name {
found = true
break
}
}
if !found {
return true, "Sidecar " + name + " no longer in specification"
}
}

return false, ""
}

// 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
}

// resourcesRequireRotation returns true if the resource requirements have changed such that a rotation is required
func resourcesRequireRotation(wanted, given v1.ResourceRequirements) bool {
checkList := func(wanted, given v1.ResourceList) bool {
Expand Down
1 change: 1 addition & 0 deletions pkg/deployment/resources/member_cleanup.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func (r *Resources) cleanupRemovedClusterMembers() error {
r.health.mutex.Unlock()

// Only accept recent cluster health values

healthAge := time.Since(ts)
if healthAge > maxClusterHealthAge {
log.Info().Dur("age", healthAge).Msg("Cleanup longer than max cluster health. Exiting")
Expand Down
4 changes: 2 additions & 2 deletions tests/load_balancer_source_ranges_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func TestLoadBalancingSourceRanges(t *testing.T) {
}
t.Logf("Service %s cannot be found, waiting for some time...", eaServiceName)
time.Sleep(time.Second)
counter += 1
counter++
if counter >= 60 {
t.Fatalf("Could not find service %s within 60 seconds, giving up.", eaServiceName)
}
Expand Down Expand Up @@ -149,7 +149,7 @@ func TestLoadBalancingSourceRanges(t *testing.T) {
}
}
t.Logf("Service %s cannot be found, waiting for some more time...", eaServiceName)
counter += 1
counter++
if counter >= 60 {
t.Fatalf("Could not find changed service %s within 60 seconds, giving up.", eaServiceName)
}
Expand Down
Loading