Skip to content

Commit

Permalink
Merged in master
Browse files Browse the repository at this point in the history
  • Loading branch information
ewoutp committed Apr 3, 2018
2 parents 90e6ea1 + add81b7 commit 1daca01
Show file tree
Hide file tree
Showing 39 changed files with 1,264 additions and 225 deletions.
103 changes: 103 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Change Log

## [Unreleased](https://github.com/arangodb/kube-arangodb/tree/HEAD)

[Full Changelog](https://github.com/arangodb/kube-arangodb/compare/0.0.1...HEAD)

**Closed issues:**

- make sure scripts terminate to avoid hanging CI [\#63](https://github.com/arangodb/kube-arangodb/issues/63)
- prefix environment variables [\#62](https://github.com/arangodb/kube-arangodb/issues/62)
- warning when passing string literal "None" as spec.tls.caSecretName [\#60](https://github.com/arangodb/kube-arangodb/issues/60)

**Merged pull requests:**

- Added helper to prepull arangodb \(enterprise\) image. This allows the normal tests to have decent timeouts while prevent a timeout caused by a long during image pull. [\#94](https://github.com/arangodb/kube-arangodb/pull/94)
- Tracking recent pod terminations [\#91](https://github.com/arangodb/kube-arangodb/pull/91)
- Enable LONG on kube-arangodb-long test [\#90](https://github.com/arangodb/kube-arangodb/pull/90)
- Tests/modes [\#88](https://github.com/arangodb/kube-arangodb/pull/88)
- increase timeout for long running tests [\#87](https://github.com/arangodb/kube-arangodb/pull/87)
- fix rocksdb\_encryption\_test [\#86](https://github.com/arangodb/kube-arangodb/pull/86)
- fix - /api/version will answer on all servers \(not leader only\) [\#85](https://github.com/arangodb/kube-arangodb/pull/85)
- fixes required after merge [\#84](https://github.com/arangodb/kube-arangodb/pull/84)
- Deployment state -\> phase [\#83](https://github.com/arangodb/kube-arangodb/pull/83)
- Added detection on unschedulable pods [\#82](https://github.com/arangodb/kube-arangodb/pull/82)
- AsOwner no longer things the owner refers to a controller. It refers to the ArangoDeployment [\#81](https://github.com/arangodb/kube-arangodb/pull/81)
- Store & compare hash of secrets. [\#80](https://github.com/arangodb/kube-arangodb/pull/80)
- Control jenkins from git commit log. [\#79](https://github.com/arangodb/kube-arangodb/pull/79)
- Fix scale-up [\#78](https://github.com/arangodb/kube-arangodb/pull/78)
- Added terminated-pod cleanup to speed up re-creation of pods. [\#77](https://github.com/arangodb/kube-arangodb/pull/77)
- add upgrade tests [\#76](https://github.com/arangodb/kube-arangodb/pull/76)
- check result of api version call [\#75](https://github.com/arangodb/kube-arangodb/pull/75)
- Also watch changes in PVCs and Services [\#74](https://github.com/arangodb/kube-arangodb/pull/74)
- Feature/test individual pod deletion [\#72](https://github.com/arangodb/kube-arangodb/pull/72)
- Moved low level resource \(pod,pvc,secret,service\) creation & inspection to resources sub-package. [\#71](https://github.com/arangodb/kube-arangodb/pull/71)
- Moved reconciliation code to separate package [\#70](https://github.com/arangodb/kube-arangodb/pull/70)
- Test/different deployments resilient [\#69](https://github.com/arangodb/kube-arangodb/pull/69)
- Store accepted spec [\#68](https://github.com/arangodb/kube-arangodb/pull/68)
- Fixed behavior for scaling UI integration wrt startup of the cluster [\#67](https://github.com/arangodb/kube-arangodb/pull/67)
- Fixed immitable `mode` field. [\#66](https://github.com/arangodb/kube-arangodb/pull/66)
- Integrate with scaling web-UI [\#65](https://github.com/arangodb/kube-arangodb/pull/65)
- add test for different deployments [\#64](https://github.com/arangodb/kube-arangodb/pull/64)
- Fixed validation of tls.caSecretName=None [\#61](https://github.com/arangodb/kube-arangodb/pull/61)
- Feature/add tests for immutable cluster parameters [\#59](https://github.com/arangodb/kube-arangodb/pull/59)
- rename test function [\#58](https://github.com/arangodb/kube-arangodb/pull/58)
- Detecting ImageID & ArangoDB version. [\#57](https://github.com/arangodb/kube-arangodb/pull/57)
- Adds ssl support for scaling test [\#53](https://github.com/arangodb/kube-arangodb/pull/53)
- Rotation support for members. [\#49](https://github.com/arangodb/kube-arangodb/pull/49)
- begin to add tests for `apis/storage/v1alpha` [\#36](https://github.com/arangodb/kube-arangodb/pull/36)

## [0.0.1](https://github.com/arangodb/kube-arangodb/tree/0.0.1) (2018-03-20)
**Merged pull requests:**

- Changed scope of ArangoLocalStorage to Cluster. [\#56](https://github.com/arangodb/kube-arangodb/pull/56)
- External crd creation [\#55](https://github.com/arangodb/kube-arangodb/pull/55)
- Rename default docker image to kube-arangodb [\#54](https://github.com/arangodb/kube-arangodb/pull/54)
- Splitting operator in two parts [\#52](https://github.com/arangodb/kube-arangodb/pull/52)
- Turn on TLS by default [\#51](https://github.com/arangodb/kube-arangodb/pull/51)
- Rename repository to `kube-arangodb` [\#48](https://github.com/arangodb/kube-arangodb/pull/48)
- Use single image tag to prevent polluting the docker hub [\#47](https://github.com/arangodb/kube-arangodb/pull/47)
- Renamed pkg/apis/arangodb to pkg/apis/deployment [\#46](https://github.com/arangodb/kube-arangodb/pull/46)
- Added release code [\#45](https://github.com/arangodb/kube-arangodb/pull/45)
- Cleaning up deployment, avoiding docker overrides [\#44](https://github.com/arangodb/kube-arangodb/pull/44)
- TLS support [\#43](https://github.com/arangodb/kube-arangodb/pull/43)
- Adds "Storage Resource" to user README [\#42](https://github.com/arangodb/kube-arangodb/pull/42)
- Reworked TLS spec [\#41](https://github.com/arangodb/kube-arangodb/pull/41)
- Set sesion affinity for coordinator [\#40](https://github.com/arangodb/kube-arangodb/pull/40)
- Set PublishNotReadyAddresses on coordinator&syncmasters service [\#39](https://github.com/arangodb/kube-arangodb/pull/39)
- Prepare test cluster [\#38](https://github.com/arangodb/kube-arangodb/pull/38)
- Run tests on multiple clusters in parallel [\#37](https://github.com/arangodb/kube-arangodb/pull/37)
- Implemented isDefault behavior of storage class [\#35](https://github.com/arangodb/kube-arangodb/pull/35)
- add some tests for util/k8sutil/erros.go [\#32](https://github.com/arangodb/kube-arangodb/pull/32)
- Adding `ArangoLocalStorage` resource \(wip\) [\#31](https://github.com/arangodb/kube-arangodb/pull/31)
- Added custom resource spec for ArangoDB Storage operator. [\#30](https://github.com/arangodb/kube-arangodb/pull/30)
- Added unit tests for k8s secrets & utility methods [\#28](https://github.com/arangodb/kube-arangodb/pull/28)
- Added unit test for creating affinity [\#27](https://github.com/arangodb/kube-arangodb/pull/27)
- More simple tests [\#26](https://github.com/arangodb/kube-arangodb/pull/26)
- Changed default storage engine to RocksDB [\#24](https://github.com/arangodb/kube-arangodb/pull/24)
- Adding command line tests for arangod commandlines. [\#23](https://github.com/arangodb/kube-arangodb/pull/23)
- UnitTests for plan\_builder [\#22](https://github.com/arangodb/kube-arangodb/pull/22)
- Unit tests for apis/arangodb/v1alpha package [\#21](https://github.com/arangodb/kube-arangodb/pull/21)
- Fix bash error [\#20](https://github.com/arangodb/kube-arangodb/pull/20)
- Renamed Controller to Operator [\#19](https://github.com/arangodb/kube-arangodb/pull/19)
- Cleanup kubernetes after tests [\#18](https://github.com/arangodb/kube-arangodb/pull/18)
- Adding rocksdb encryption key support [\#17](https://github.com/arangodb/kube-arangodb/pull/17)
- Adding test design [\#16](https://github.com/arangodb/kube-arangodb/pull/16)
- avoid sub-shell creation [\#15](https://github.com/arangodb/kube-arangodb/pull/15)
- Adding authentication support [\#14](https://github.com/arangodb/kube-arangodb/pull/14)
- Scaling deployments [\#13](https://github.com/arangodb/kube-arangodb/pull/13)
- Test framework [\#11](https://github.com/arangodb/kube-arangodb/pull/11)
- Change docs to "authentication default on" [\#10](https://github.com/arangodb/kube-arangodb/pull/10)
- Pod monitoring [\#9](https://github.com/arangodb/kube-arangodb/pull/9)
- Pod affinity [\#8](https://github.com/arangodb/kube-arangodb/pull/8)
- Extended storage docs wrt local storage [\#7](https://github.com/arangodb/kube-arangodb/pull/7)
- Adding event support [\#6](https://github.com/arangodb/kube-arangodb/pull/6)
- Added pod probes [\#5](https://github.com/arangodb/kube-arangodb/pull/5)
- Creating pods [\#4](https://github.com/arangodb/kube-arangodb/pull/4)
- Extending spec & status object. Implementing service & pvc creation [\#3](https://github.com/arangodb/kube-arangodb/pull/3)
- Initial API objects & vendoring [\#2](https://github.com/arangodb/kube-arangodb/pull/2)
- Added specification of custom resource [\#1](https://github.com/arangodb/kube-arangodb/pull/1)



\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,16 @@ endif
patch-readme:
$(ROOTDIR)/scripts/patch_readme.sh $(VERSION_MAJOR_MINOR_PATCH)

.PHONY: update-changelog
changelog:
docker run -it --rm \
-e CHANGELOG_GITHUB_TOKEN=$(shell cat ~/.arangodb/github-token) \
-v "$(ROOTDIR)":/usr/local/src/your-app \
ferrarimarco/github-changelog-generator \
--user arangodb \
--project kube-arangodb \
--no-author

.PHONY: docker-push
docker-push: docker
ifneq ($(DOCKERNAMESPACE), arangodb)
Expand Down
48 changes: 48 additions & 0 deletions pkg/apis/deployment/v1alpha/member_phase.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//
// DISCLAIMER
//
// Copyright 2018 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//
// Author Ewout Prangsma
//

package v1alpha

// MemberPhase is a strongly typed lifetime phase of a deployment member
type MemberPhase string

const (
// MemberPhaseNone indicates that the state is not set yet
MemberPhaseNone MemberPhase = ""
// MemberPhaseCreated indicates that all resources needed for the member have been created
MemberPhaseCreated MemberPhase = "Created"
// MemberPhaseFailed indicates that the member is gone beyond hope of recovery. It must be replaced with a new member.
MemberPhaseFailed MemberPhase = "Failed"
// MemberPhaseCleanOut indicates that a dbserver is in the process of being cleaned out
MemberPhaseCleanOut MemberPhase = "CleanOut"
// MemberPhaseShuttingDown indicates that a member is shutting down
MemberPhaseShuttingDown MemberPhase = "ShuttingDown"
// MemberPhaseRotating indicates that a member is being rotated
MemberPhaseRotating MemberPhase = "Rotating"
// MemberPhaseUpgrading indicates that a member is in the process of upgrading its database data format
MemberPhaseUpgrading MemberPhase = "Upgrading"
)

// IsFailed returns true when given phase == "Failed"
func (p MemberPhase) IsFailed() bool {
return p == MemberPhaseFailed
}
41 changes: 0 additions & 41 deletions pkg/apis/deployment/v1alpha/member_state.go

This file was deleted.

24 changes: 22 additions & 2 deletions pkg/apis/deployment/v1alpha/member_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ package v1alpha
import (
"time"

"k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand All @@ -33,8 +34,10 @@ type MemberStatus struct {
// ID holds the unique ID of the member.
// This id is also used within the ArangoDB cluster to identify this server.
ID string `json:"id"`
// State holds the current state of this member
State MemberState `json:"state"`
// Phase holds the current lifetime phase of this member
Phase MemberPhase `json:"phase"`
// CreatedAt holds the creation timestamp of this member.
CreatedAt metav1.Time `json:"created-at"`
// PersistentVolumeClaimName holds the name of the persistent volume claim used for this member (if any).
PersistentVolumeClaimName string `json:"persistentVolumeClaimName,omitempty"`
// PodName holds the name of the Pod that currently runs this member
Expand All @@ -44,6 +47,9 @@ type MemberStatus struct {
// RecentTerminatons holds the times when this member was recently terminated.
// First entry is the oldest. (do not add omitempty, since we want to be able to switch from a list to an empty list)
RecentTerminations []metav1.Time `json:"recent-terminations"`
// IsInitialized is set after the very first time a pod was created for this member.
// After that, DBServers must have a UUID field or fail.
IsInitialized bool `json:"initialized"`
}

// RemoveTerminationsBefore removes all recent terminations before the given timestamp.
Expand Down Expand Up @@ -78,3 +84,17 @@ func (s MemberStatus) RecentTerminationsSince(timestamp time.Time) int {
}
return count
}

// IsNotReadySince returns true when the given member has not been ready since the given timestamp.
// That means it:
// - A) Was created before timestamp and never reached a ready state or
// - B) The Ready condition is set to false, and last transision is before timestamp
func (s MemberStatus) IsNotReadySince(timestamp time.Time) bool {
cond, found := s.Conditions.Get(ConditionTypeReady)
if found {
// B
return cond.Status != v1.ConditionTrue && cond.LastTransitionTime.Time.Before(timestamp)
}
// A
return s.CreatedAt.Time.Before(timestamp)
}
4 changes: 2 additions & 2 deletions pkg/apis/deployment/v1alpha/member_status_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,15 @@ func (l MemberStatusList) SelectMemberToRemove() (MemberStatus, error) {
if len(l) > 0 {
// Try to find a not ready member
for _, m := range l {
if m.State == MemberStateNone {
if m.Phase == MemberPhaseNone {
return m, nil
}
}
// Pick a random member that is in created state
perm := rand.Perm(len(l))
for _, idx := range perm {
m := l[idx]
if m.State == MemberStateCreated {
if m.Phase == MemberPhaseCreated {
return m, nil
}
}
Expand Down
21 changes: 21 additions & 0 deletions pkg/apis/deployment/v1alpha/member_status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,24 @@ func TestMemberStatusRecentTerminations(t *testing.T) {
assert.Equal(t, 2, s.RemoveTerminationsBefore(time.Now()))
assert.Len(t, s.RecentTerminations, 1)
}

// TestMemberStatusIsNotReadySince tests the functions related to MemberStatus.IsNotReadySince.
func TestMemberStatusIsNotReadySince(t *testing.T) {
s := MemberStatus{
CreatedAt: metav1.Now(),
}
assert.False(t, s.IsNotReadySince(time.Now().Add(-time.Hour)))

s.CreatedAt.Time = time.Now().Add(-time.Hour)
assert.False(t, s.IsNotReadySince(time.Now().Add(-2*time.Hour)))
assert.True(t, s.IsNotReadySince(time.Now().Add(-(time.Hour - time.Minute))))

s.CreatedAt = metav1.Now()
s.Conditions.Update(ConditionTypeReady, true, "", "")
assert.False(t, s.IsNotReadySince(time.Now().Add(-time.Minute)))
assert.False(t, s.IsNotReadySince(time.Now().Add(time.Minute)))

s.Conditions.Update(ConditionTypeReady, false, "", "")
assert.False(t, s.IsNotReadySince(time.Now().Add(-time.Minute)))
assert.True(t, s.IsNotReadySince(time.Now().Add(time.Minute)))
}
1 change: 1 addition & 0 deletions pkg/apis/deployment/v1alpha/zz_generated.deepcopy.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ func (in *ImageInfo) DeepCopy() *ImageInfo {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *MemberStatus) DeepCopyInto(out *MemberStatus) {
*out = *in
in.CreatedAt.DeepCopyInto(&out.CreatedAt)
if in.Conditions != nil {
in, out := &in.Conditions, &out.Conditions
*out = make(ConditionList, len(*in))
Expand Down
15 changes: 12 additions & 3 deletions pkg/deployment/context_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,14 @@ func (d *Deployment) GetServerClient(ctx context.Context, group api.ServerGroup,
}

// GetAgencyClients returns a client connection for every agency member.
func (d *Deployment) GetAgencyClients(ctx context.Context) ([]arangod.Agency, error) {
// If the given predicate is not nil, only agents are included where the given predicate returns true.
func (d *Deployment) GetAgencyClients(ctx context.Context, predicate func(id string) bool) ([]arangod.Agency, error) {
agencyMembers := d.status.Members.Agents
result := make([]arangod.Agency, 0, len(agencyMembers))
for _, m := range agencyMembers {
if predicate != nil && !predicate(m.ID) {
continue
}
client, err := d.GetServerClient(ctx, api.ServerGroupAgents, m.ID)
if err != nil {
return nil, maskAny(err)
Expand All @@ -115,9 +119,11 @@ func (d *Deployment) GetAgencyClients(ctx context.Context) ([]arangod.Agency, er
}

// CreateMember adds a new member to the given group.
func (d *Deployment) CreateMember(group api.ServerGroup) error {
// If ID is non-empty, it will be used, otherwise a new ID is created.
func (d *Deployment) CreateMember(group api.ServerGroup, id string) error {
log := d.deps.Log
if err := d.createMember(group, d.apiObject); err != nil {
id, err := d.createMember(group, id, d.apiObject)
if err != nil {
log.Debug().Err(err).Str("group", group.AsRole()).Msg("Failed to create member")
return maskAny(err)
}
Expand All @@ -126,6 +132,9 @@ func (d *Deployment) CreateMember(group api.ServerGroup) error {
log.Debug().Err(err).Msg("Updating CR status failed")
return maskAny(err)
}
// Create event about it
d.CreateEvent(k8sutil.NewMemberAddEvent(id, group.AsRole(), d.apiObject))

return nil
}

Expand Down
3 changes: 3 additions & 0 deletions pkg/deployment/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (

api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha"
"github.com/arangodb/kube-arangodb/pkg/deployment/reconcile"
"github.com/arangodb/kube-arangodb/pkg/deployment/resilience"
"github.com/arangodb/kube-arangodb/pkg/deployment/resources"
"github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
Expand Down Expand Up @@ -92,6 +93,7 @@ type Deployment struct {
recentInspectionErrors int
clusterScalingIntegration *clusterScalingIntegration
reconciler *reconcile.Reconciler
resilience *resilience.Resilience
resources *resources.Resources
}

Expand All @@ -111,6 +113,7 @@ func New(config Config, deps Dependencies, apiObject *api.ArangoDeployment) (*De
clientCache: newClientCache(deps.KubeCli, apiObject),
}
d.reconciler = reconcile.NewReconciler(deps.Log, d)
d.resilience = resilience.NewResilience(deps.Log, d)
d.resources = resources.NewResources(deps.Log, d)
if d.status.AcceptedSpec == nil {
// We've validated the spec, so let's use it from now.
Expand Down
6 changes: 6 additions & 0 deletions pkg/deployment/deployment_inspector.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ func (d *Deployment) inspectDeployment(lastInterval time.Duration) time.Duration
d.CreateEvent(k8sutil.NewErrorEvent("Pod inspection failed", err, d.apiObject))
}

// Check members for resilience
if err := d.resilience.CheckMemberFailure(); err != nil {
hasError = true
d.CreateEvent(k8sutil.NewErrorEvent("Member failure detection failed", err, d.apiObject))
}

// Create scale/update plan
if err := d.reconciler.CreatePlan(); err != nil {
hasError = true
Expand Down
Loading

0 comments on commit 1daca01

Please sign in to comment.