Skip to content

Commit d562b93

Browse files
authored
[Feature] Add Plan Changed Events (#585)
1 parent 6c98ba2 commit d562b93

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- Add runtime TLS rotation for ArangoDB EE 3.7+
77
- Add Kustomize support
88
- Improve Helm 3 support
9+
- Allow to customize ID Pod selectors
910

1011
## [1.0.3](https://github.com/arangodb/kube-arangodb/tree/1.0.3) (2020-05-25)
1112
- Prevent deletion of not known PVC's

pkg/deployment/reconcile/plan_builder.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,15 @@ func (d *Reconciler) CreatePlan(ctx context.Context, cachedStatus inspector.Insp
7373
// Nothing to do
7474
return nil, false
7575
}
76+
77+
// Send events
78+
for id := len(status.Plan); id < len(newPlan); id++ {
79+
action := newPlan[id]
80+
d.context.CreateEvent(k8sutil.NewPlanAppendEvent(apiObject, action.Type.String(), action.Group.AsRole(), action.MemberID, action.Reason))
81+
}
82+
7683
status.Plan = newPlan
84+
7785
if err := d.context.UpdateStatus(status, lastVersion); err != nil {
7886
return maskAny(err), false
7987
}

pkg/util/k8sutil/events.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,23 @@ func NewAccessPackageDeletedEvent(apiObject APIObject, apSecretName string) *Eve
153153
return event
154154
}
155155

156+
// NewPlanTimeoutEvent creates an event indicating that an item on a reconciliation plan has been added
157+
func NewPlanAppendEvent(apiObject APIObject, itemType, memberID, role, reason string) *Event {
158+
event := newDeploymentEvent(apiObject)
159+
event.Type = v1.EventTypeNormal
160+
event.Reason = "Plan Action added"
161+
msg := fmt.Sprintf("An plan item of type %s", itemType)
162+
if role != "" {
163+
msg = fmt.Sprintf("%s for member %s with role %s", msg, memberID, role)
164+
}
165+
msg = fmt.Sprintf("%s has beed added", msg)
166+
if reason != "" {
167+
msg = fmt.Sprintf("%s with reason: %s", msg, reason)
168+
}
169+
event.Message = msg
170+
return event
171+
}
172+
156173
// NewPlanTimeoutEvent creates an event indicating that an item on a reconciliation plan did not
157174
// finish before its deadline.
158175
func NewPlanTimeoutEvent(apiObject APIObject, itemType, memberID, role string) *Event {

0 commit comments

Comments
 (0)