From 02f651c019bd104b0b6904b78a7b6aea1d27391b Mon Sep 17 00:00:00 2001 From: Adam Janikowski <12255597+ajanikow@users.noreply.github.com> Date: Wed, 7 Oct 2020 20:33:17 +0200 Subject: [PATCH] [Feature] Fix ChaosMonkey (#642) --- CHANGELOG.md | 2 ++ pkg/deployment/context_impl.go | 19 +++++++++++++++++++ pkg/deployment/deployment.go | 8 ++++---- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 603841318..6b48fd647 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ - Enable by default and promote to Production Ready - JWT Rotation Feature, TLS Rotation Feature - Deprecate K8S < 1.16 - Fix Upgrade procedure to safely evict pods during upgrade +- Fix Panics in Deployments without authentication +- Fix ChaosMonkey mode ## [1.0.8](https://github.com/arangodb/kube-arangodb/tree/1.0.8) (2020-09-10) - Fix Volume rotation on AKS diff --git a/pkg/deployment/context_impl.go b/pkg/deployment/context_impl.go index 6fe1249ab..f1cf0279e 100644 --- a/pkg/deployment/context_impl.go +++ b/pkg/deployment/context_impl.go @@ -570,3 +570,22 @@ func (d *Deployment) SecretsInterface() k8sutil.SecretInterface { func (d *Deployment) GetName() string { return d.apiObject.GetName() } + +func (d *Deployment) GetOwnedPods() ([]v1.Pod, error) { + pods, err := d.GetKubeCli().CoreV1().Pods(d.apiObject.GetNamespace()).List(meta.ListOptions{}) + if err != nil { + return nil, err + } + + podList := make([]v1.Pod, 0, len(pods.Items)) + + for _, p := range pods.Items { + if !d.isOwnerOf(&p) { + continue + } + c := p.DeepCopy() + podList = append(podList, *c) + } + + return podList, nil +} diff --git a/pkg/deployment/deployment.go b/pkg/deployment/deployment.go index f55a38415..75985b7fc 100644 --- a/pkg/deployment/deployment.go +++ b/pkg/deployment/deployment.go @@ -164,10 +164,10 @@ func New(config Config, deps Dependencies, apiObject *api.ArangoDeployment) (*De go d.resources.RunDeploymentHealthLoop(d.stopCh) go d.resources.RunDeploymentShardSyncLoop(d.stopCh) } - //if config.AllowChaos { - // d.chaosMonkey = chaos.NewMonkey(deps.Log, d) - // go d.chaosMonkey.Run(d.stopCh) - //} + if config.AllowChaos { + d.chaosMonkey = chaos.NewMonkey(deps.Log, d) + go d.chaosMonkey.Run(d.stopCh) + } return d, nil }