From 1720c920adb7b0ccdf859020c29b1fadf5280882 Mon Sep 17 00:00:00 2001 From: ajanikow <12255597+ajanikow@users.noreply.github.com> Date: Thu, 18 Jun 2020 05:28:57 +0000 Subject: [PATCH 1/2] Add Plan Changed Events --- pkg/deployment/reconcile/plan_builder.go | 9 +++++++++ pkg/util/k8sutil/events.go | 17 +++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/pkg/deployment/reconcile/plan_builder.go b/pkg/deployment/reconcile/plan_builder.go index 94ec722c0..be49441d6 100644 --- a/pkg/deployment/reconcile/plan_builder.go +++ b/pkg/deployment/reconcile/plan_builder.go @@ -73,7 +73,16 @@ func (d *Reconciler) CreatePlan(ctx context.Context, cachedStatus inspector.Insp // Nothing to do return nil, false } + + // Send events + for id := len(status.Plan); id < len(newPlan); id++ { + action := newPlan[id] + d.log.Info().Msgf("Registering Action event") + d.context.CreateEvent(k8sutil.NewPlanAppendEvent(apiObject, action.Type.String(), action.Group.AsRole(), action.MemberID, action.Reason)) + } + status.Plan = newPlan + if err := d.context.UpdateStatus(status, lastVersion); err != nil { return maskAny(err), false } diff --git a/pkg/util/k8sutil/events.go b/pkg/util/k8sutil/events.go index 24e0dd48d..fb6ed05a6 100644 --- a/pkg/util/k8sutil/events.go +++ b/pkg/util/k8sutil/events.go @@ -153,6 +153,23 @@ func NewAccessPackageDeletedEvent(apiObject APIObject, apSecretName string) *Eve return event } +// NewPlanTimeoutEvent creates an event indicating that an item on a reconciliation plan has been added +func NewPlanAppendEvent(apiObject APIObject, itemType, memberID, role, reason string) *Event { + event := newDeploymentEvent(apiObject) + event.Type = v1.EventTypeNormal + event.Reason = "Plan Action added" + msg := fmt.Sprintf("An plan item of type %s", itemType) + if role != "" { + msg = fmt.Sprintf("%s for member %s with role %s", msg, memberID, role) + } + msg = fmt.Sprintf("%s has beed added", msg) + if reason != "" { + msg = fmt.Sprintf("%s with reason: %s", msg, reason) + } + event.Message = msg + return event +} + // NewPlanTimeoutEvent creates an event indicating that an item on a reconciliation plan did not // finish before its deadline. func NewPlanTimeoutEvent(apiObject APIObject, itemType, memberID, role string) *Event { From 46d59282cbe3d0297042a8bc55a02fd0ff3d2db1 Mon Sep 17 00:00:00 2001 From: ajanikow <12255597+ajanikow@users.noreply.github.com> Date: Sat, 20 Jun 2020 08:59:15 +0000 Subject: [PATCH 2/2] Remove debug line --- CHANGELOG.md | 1 + pkg/deployment/reconcile/plan_builder.go | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 50a2e38f6..a0a0a8be5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - Add runtime TLS rotation for ArangoDB EE 3.7+ - Add Kustomize support - Improve Helm 3 support +- Allow to customize ID Pod selectors ## [1.0.3](https://github.com/arangodb/kube-arangodb/tree/1.0.3) (2020-05-25) - Prevent deletion of not known PVC's diff --git a/pkg/deployment/reconcile/plan_builder.go b/pkg/deployment/reconcile/plan_builder.go index be49441d6..63d97187a 100644 --- a/pkg/deployment/reconcile/plan_builder.go +++ b/pkg/deployment/reconcile/plan_builder.go @@ -77,7 +77,6 @@ func (d *Reconciler) CreatePlan(ctx context.Context, cachedStatus inspector.Insp // Send events for id := len(status.Plan); id < len(newPlan); id++ { action := newPlan[id] - d.log.Info().Msgf("Registering Action event") d.context.CreateEvent(k8sutil.NewPlanAppendEvent(apiObject, action.Type.String(), action.Group.AsRole(), action.MemberID, action.Reason)) }