1
0
Fork 0
mirror of https://github.com/arangodb/kube-arangodb.git synced 2024-12-14 11:57:37 +00:00

[Feature] Add SpecPropagated condition (#1212)

This commit is contained in:
Adam Janikowski 2022-12-19 12:53:42 +01:00 committed by GitHub
parent 207a606a85
commit e6bc982f53
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 89 additions and 1 deletions

View file

@ -2,6 +2,7 @@
## [master](https://github.com/arangodb/kube-arangodb/tree/master) (N/A)
- (Bugfix) Remove PDBs if group count is 0
- (Feature) Add SpecPropagated condition
## [1.2.22](https://github.com/arangodb/kube-arangodb/tree/1.2.22) (2022-12-13)
- (Bugfix) Do not manage ports in managed ExternalAccess mode

View file

@ -24,6 +24,7 @@
| [arangodb_operator_rebalancer_moves_succeeded](./arangodb_operator_rebalancer_moves_succeeded.md) | arangodb_operator | rebalancer | Counter | Define how many moves succeeded |
| [arangodb_operator_resources_arangodeployment_accepted](./arangodb_operator_resources_arangodeployment_accepted.md) | arangodb_operator | resources | Gauge | Defines if ArangoDeployment has been accepted |
| [arangodb_operator_resources_arangodeployment_immutable_errors](./arangodb_operator_resources_arangodeployment_immutable_errors.md) | arangodb_operator | resources | Counter | Counter for deployment immutable errors |
| [arangodb_operator_resources_arangodeployment_propagated](./arangodb_operator_resources_arangodeployment_propagated.md) | arangodb_operator | resources | Gauge | Defines if ArangoDeployment Spec is propagated |
| [arangodb_operator_resources_arangodeployment_status_restores](./arangodb_operator_resources_arangodeployment_status_restores.md) | arangodb_operator | resources | Counter | Counter for deployment status restored |
| [arangodb_operator_resources_arangodeployment_uptodate](./arangodb_operator_resources_arangodeployment_uptodate.md) | arangodb_operator | resources | Gauge | Defines if ArangoDeployment is uptodate |
| [arangodb_operator_resources_arangodeployment_validation_errors](./arangodb_operator_resources_arangodeployment_validation_errors.md) | arangodb_operator | resources | Counter | Counter for deployment validation errors |

View file

@ -0,0 +1,12 @@
# arangodb_operator_resources_arangodeployment_propagated (Gauge)
## Description
Defines if ArangoDeployment Spec is propagated
## Labels
| Label | Description |
|:---------:|:---------------------|
| namespace | Deployment Namespace |
| name | Deployment Name |

View file

@ -186,6 +186,15 @@ namespaces:
description: "Deployment Namespace"
- key: name
description: "Deployment Name"
arangodeployment_propagated:
shortDescription: "Defines if ArangoDeployment Spec is propagated"
description: "Defines if ArangoDeployment Spec is propagated"
type: "Gauge"
labels:
- key: namespace
description: "Deployment Namespace"
- key: name
description: "Deployment Name"
arangodeployment_uptodate:
shortDescription: "Defines if ArangoDeployment is uptodate"
description: "Defines if ArangoDeployment is uptodate"

View file

@ -70,6 +70,8 @@ const (
ConditionTypeUpToDate ConditionType = "UpToDate"
// ConditionTypeSpecAccepted indicates that the deployment spec has been accepted.
ConditionTypeSpecAccepted ConditionType = "SpecAccepted"
// ConditionTypeSpecPropagated indicates that the deployment has been at least once UpToDate after spec acceptance.
ConditionTypeSpecPropagated ConditionType = "SpecPropagated"
// ConditionTypeMarkedToRemove indicates that the member is marked to be removed.
ConditionTypeMarkedToRemove ConditionType = "MarkedToRemove"
// ConditionTypeScaleDownCandidate indicates that the member will be picked in ScaleDown operaion.

View file

@ -70,6 +70,8 @@ const (
ConditionTypeUpToDate ConditionType = "UpToDate"
// ConditionTypeSpecAccepted indicates that the deployment spec has been accepted.
ConditionTypeSpecAccepted ConditionType = "SpecAccepted"
// ConditionTypeSpecPropagated indicates that the deployment has been at least once UpToDate after spec acceptance.
ConditionTypeSpecPropagated ConditionType = "SpecPropagated"
// ConditionTypeMarkedToRemove indicates that the member is marked to be removed.
ConditionTypeMarkedToRemove ConditionType = "MarkedToRemove"
// ConditionTypeScaleDownCandidate indicates that the member will be picked in ScaleDown operaion.

View file

@ -143,6 +143,7 @@ func (d *Deployment) inspectDeployment(lastInterval util.Interval) util.Interval
d.currentObject = updated
d.metrics.Deployment.Accepted = updated.Status.Conditions.IsTrue(api.ConditionTypeSpecAccepted)
d.metrics.Deployment.Propagated = updated.Status.Conditions.IsTrue(api.ConditionTypeSpecPropagated)
d.metrics.Deployment.UpToDate = updated.Status.Conditions.IsTrue(api.ConditionTypeUpToDate)
// Is the deployment in failed state, if so, give up.
@ -231,6 +232,16 @@ func (d *Deployment) inspectDeploymentWithError(ctx context.Context, lastInterva
if !status.Conditions.IsTrue(api.ConditionTypeSpecAccepted) {
condition, exists := status.Conditions.Get(api.ConditionTypeUpToDate)
if !exists || condition.IsTrue() {
propagatedCondition, propagatedExists := status.Conditions.Get(api.ConditionTypeSpecPropagated)
if !propagatedExists || propagatedCondition.IsTrue() {
if err = d.updateConditionWithHash(ctx, api.ConditionTypeSpecPropagated, false, "Spec Changed", "Spec Object changed. Waiting until spec will be applied", ""); err != nil {
return minInspectionInterval, errors.Wrapf(err, "Unable to update SpecPropagated condition")
}
return minInspectionInterval, nil // Retry ASAP
}
if err = d.updateConditionWithHash(ctx, api.ConditionTypeUpToDate, false, "Spec Changed", "Spec Object changed. Waiting until plan will be applied", currentChecksum); err != nil {
return minInspectionInterval, errors.Wrapf(err, "Unable to update UpToDate condition")
@ -374,6 +385,12 @@ func (d *Deployment) inspectDeploymentWithError(ctx context.Context, lastInterva
}
}
if status.Conditions.IsTrue(api.ConditionTypeUpToDate) && !status.Conditions.IsTrue(api.ConditionTypeSpecPropagated) {
if err = d.updateConditionWithHash(ctx, api.ConditionTypeSpecPropagated, true, "Spec is Propagated", "Spec is Propagated", ""); err != nil {
return minInspectionInterval, errors.Wrapf(err, "Unable to update SpecPropagated condition")
}
}
// Execute current step of scale/update plan
retrySoon, err := d.reconciler.ExecutePlan(ctx)
if err != nil {

View file

@ -39,7 +39,7 @@ type Metrics struct {
ArangodbOperatorEngineOpsAlerts int
Deployment struct {
Accepted, UpToDate bool
Accepted, UpToDate, Propagated bool
}
}
@ -62,6 +62,11 @@ func (d *Deployment) CollectMetrics(m metrics.PushMetric) {
} else {
m.Push(metric_descriptions.ArangodbOperatorResourcesArangodeploymentUptodateGauge(0, d.namespace, d.name))
}
if d.metrics.Deployment.Propagated {
m.Push(metric_descriptions.ArangodbOperatorResourcesArangodeploymentPropagatedGauge(1, d.namespace, d.name))
} else {
m.Push(metric_descriptions.ArangodbOperatorResourcesArangodeploymentPropagatedGauge(0, d.namespace, d.name))
}
if c := d.agencyCache; c != nil {
m.Push(metric_descriptions.ArangodbOperatorAgencyCachePresentGauge(1, d.namespace, d.name))

View file

@ -0,0 +1,39 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 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
//
package metric_descriptions
import "github.com/arangodb/kube-arangodb/pkg/util/metrics"
var (
arangodbOperatorResourcesArangodeploymentPropagated = metrics.NewDescription("arangodb_operator_resources_arangodeployment_propagated", "Defines if ArangoDeployment Spec is propagated", []string{`namespace`, `name`}, nil)
)
func init() {
registerDescription(arangodbOperatorResourcesArangodeploymentPropagated)
}
func ArangodbOperatorResourcesArangodeploymentPropagated() metrics.Description {
return arangodbOperatorResourcesArangodeploymentPropagated
}
func ArangodbOperatorResourcesArangodeploymentPropagatedGauge(value float64, namespace string, name string) metrics.Metric {
return ArangodbOperatorResourcesArangodeploymentPropagated().Gauge(value, namespace, name)
}