Skip to content

Commit e6bc982

Browse files
authored
[Feature] Add SpecPropagated condition (#1212)
1 parent 207a606 commit e6bc982

File tree

9 files changed

+89
-1
lines changed

9 files changed

+89
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## [master](https://github.com/arangodb/kube-arangodb/tree/master) (N/A)
44
- (Bugfix) Remove PDBs if group count is 0
5+
- (Feature) Add SpecPropagated condition
56

67
## [1.2.22](https://github.com/arangodb/kube-arangodb/tree/1.2.22) (2022-12-13)
78
- (Bugfix) Do not manage ports in managed ExternalAccess mode

docs/generated/metrics/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
| [arangodb_operator_rebalancer_moves_succeeded](./arangodb_operator_rebalancer_moves_succeeded.md) | arangodb_operator | rebalancer | Counter | Define how many moves succeeded |
2525
| [arangodb_operator_resources_arangodeployment_accepted](./arangodb_operator_resources_arangodeployment_accepted.md) | arangodb_operator | resources | Gauge | Defines if ArangoDeployment has been accepted |
2626
| [arangodb_operator_resources_arangodeployment_immutable_errors](./arangodb_operator_resources_arangodeployment_immutable_errors.md) | arangodb_operator | resources | Counter | Counter for deployment immutable errors |
27+
| [arangodb_operator_resources_arangodeployment_propagated](./arangodb_operator_resources_arangodeployment_propagated.md) | arangodb_operator | resources | Gauge | Defines if ArangoDeployment Spec is propagated |
2728
| [arangodb_operator_resources_arangodeployment_status_restores](./arangodb_operator_resources_arangodeployment_status_restores.md) | arangodb_operator | resources | Counter | Counter for deployment status restored |
2829
| [arangodb_operator_resources_arangodeployment_uptodate](./arangodb_operator_resources_arangodeployment_uptodate.md) | arangodb_operator | resources | Gauge | Defines if ArangoDeployment is uptodate |
2930
| [arangodb_operator_resources_arangodeployment_validation_errors](./arangodb_operator_resources_arangodeployment_validation_errors.md) | arangodb_operator | resources | Counter | Counter for deployment validation errors |
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# arangodb_operator_resources_arangodeployment_propagated (Gauge)
2+
3+
## Description
4+
5+
Defines if ArangoDeployment Spec is propagated
6+
7+
## Labels
8+
9+
| Label | Description |
10+
|:---------:|:---------------------|
11+
| namespace | Deployment Namespace |
12+
| name | Deployment Name |

internal/metrics.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,15 @@ namespaces:
186186
description: "Deployment Namespace"
187187
- key: name
188188
description: "Deployment Name"
189+
arangodeployment_propagated:
190+
shortDescription: "Defines if ArangoDeployment Spec is propagated"
191+
description: "Defines if ArangoDeployment Spec is propagated"
192+
type: "Gauge"
193+
labels:
194+
- key: namespace
195+
description: "Deployment Namespace"
196+
- key: name
197+
description: "Deployment Name"
189198
arangodeployment_uptodate:
190199
shortDescription: "Defines if ArangoDeployment is uptodate"
191200
description: "Defines if ArangoDeployment is uptodate"

pkg/apis/deployment/v1/conditions.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ const (
7070
ConditionTypeUpToDate ConditionType = "UpToDate"
7171
// ConditionTypeSpecAccepted indicates that the deployment spec has been accepted.
7272
ConditionTypeSpecAccepted ConditionType = "SpecAccepted"
73+
// ConditionTypeSpecPropagated indicates that the deployment has been at least once UpToDate after spec acceptance.
74+
ConditionTypeSpecPropagated ConditionType = "SpecPropagated"
7375
// ConditionTypeMarkedToRemove indicates that the member is marked to be removed.
7476
ConditionTypeMarkedToRemove ConditionType = "MarkedToRemove"
7577
// ConditionTypeScaleDownCandidate indicates that the member will be picked in ScaleDown operaion.

pkg/apis/deployment/v2alpha1/conditions.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ const (
7070
ConditionTypeUpToDate ConditionType = "UpToDate"
7171
// ConditionTypeSpecAccepted indicates that the deployment spec has been accepted.
7272
ConditionTypeSpecAccepted ConditionType = "SpecAccepted"
73+
// ConditionTypeSpecPropagated indicates that the deployment has been at least once UpToDate after spec acceptance.
74+
ConditionTypeSpecPropagated ConditionType = "SpecPropagated"
7375
// ConditionTypeMarkedToRemove indicates that the member is marked to be removed.
7476
ConditionTypeMarkedToRemove ConditionType = "MarkedToRemove"
7577
// ConditionTypeScaleDownCandidate indicates that the member will be picked in ScaleDown operaion.

pkg/deployment/deployment_inspector.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ func (d *Deployment) inspectDeployment(lastInterval util.Interval) util.Interval
143143
d.currentObject = updated
144144

145145
d.metrics.Deployment.Accepted = updated.Status.Conditions.IsTrue(api.ConditionTypeSpecAccepted)
146+
d.metrics.Deployment.Propagated = updated.Status.Conditions.IsTrue(api.ConditionTypeSpecPropagated)
146147
d.metrics.Deployment.UpToDate = updated.Status.Conditions.IsTrue(api.ConditionTypeUpToDate)
147148

148149
// Is the deployment in failed state, if so, give up.
@@ -231,6 +232,16 @@ func (d *Deployment) inspectDeploymentWithError(ctx context.Context, lastInterva
231232
if !status.Conditions.IsTrue(api.ConditionTypeSpecAccepted) {
232233
condition, exists := status.Conditions.Get(api.ConditionTypeUpToDate)
233234
if !exists || condition.IsTrue() {
235+
propagatedCondition, propagatedExists := status.Conditions.Get(api.ConditionTypeSpecPropagated)
236+
if !propagatedExists || propagatedCondition.IsTrue() {
237+
if err = d.updateConditionWithHash(ctx, api.ConditionTypeSpecPropagated, false, "Spec Changed", "Spec Object changed. Waiting until spec will be applied", ""); err != nil {
238+
return minInspectionInterval, errors.Wrapf(err, "Unable to update SpecPropagated condition")
239+
240+
}
241+
242+
return minInspectionInterval, nil // Retry ASAP
243+
}
244+
234245
if err = d.updateConditionWithHash(ctx, api.ConditionTypeUpToDate, false, "Spec Changed", "Spec Object changed. Waiting until plan will be applied", currentChecksum); err != nil {
235246
return minInspectionInterval, errors.Wrapf(err, "Unable to update UpToDate condition")
236247

@@ -374,6 +385,12 @@ func (d *Deployment) inspectDeploymentWithError(ctx context.Context, lastInterva
374385
}
375386
}
376387

388+
if status.Conditions.IsTrue(api.ConditionTypeUpToDate) && !status.Conditions.IsTrue(api.ConditionTypeSpecPropagated) {
389+
if err = d.updateConditionWithHash(ctx, api.ConditionTypeSpecPropagated, true, "Spec is Propagated", "Spec is Propagated", ""); err != nil {
390+
return minInspectionInterval, errors.Wrapf(err, "Unable to update SpecPropagated condition")
391+
}
392+
}
393+
377394
// Execute current step of scale/update plan
378395
retrySoon, err := d.reconciler.ExecutePlan(ctx)
379396
if err != nil {

pkg/deployment/metrics.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ type Metrics struct {
3939
ArangodbOperatorEngineOpsAlerts int
4040

4141
Deployment struct {
42-
Accepted, UpToDate bool
42+
Accepted, UpToDate, Propagated bool
4343
}
4444
}
4545

@@ -62,6 +62,11 @@ func (d *Deployment) CollectMetrics(m metrics.PushMetric) {
6262
} else {
6363
m.Push(metric_descriptions.ArangodbOperatorResourcesArangodeploymentUptodateGauge(0, d.namespace, d.name))
6464
}
65+
if d.metrics.Deployment.Propagated {
66+
m.Push(metric_descriptions.ArangodbOperatorResourcesArangodeploymentPropagatedGauge(1, d.namespace, d.name))
67+
} else {
68+
m.Push(metric_descriptions.ArangodbOperatorResourcesArangodeploymentPropagatedGauge(0, d.namespace, d.name))
69+
}
6570

6671
if c := d.agencyCache; c != nil {
6772
m.Push(metric_descriptions.ArangodbOperatorAgencyCachePresentGauge(1, d.namespace, d.name))

pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeployment_propagated.go

Lines changed: 39 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)