Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
- (Documentation) Refactor metrics (Part 1)
- (Bugfix) Extend Agency HealthCheck for replace
- (Bugfix) Allow to remove resources (CPU & Memory) on the managed pods
- (Bugfix) Add DistributeShardsLike support

## [1.2.13](https://github.com/arangodb/kube-arangodb/tree/1.2.13) (2022-06-07)
- (Bugfix) Fix arangosync members state inspection
Expand Down
29 changes: 17 additions & 12 deletions docs/generated/metrics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,20 @@

## List

| Name | Namespace | Group | Type | Description |
|:---------------------------------------------------------------------------------------------------------------:|:-----------------:|:------------:|:-----:|:---------------------------------------------------|
| [arangodb_operator_agency_errors](./arangodb_operator_agency_errors.md) | arangodb_operator | agency | Count | Current count of agency cache fetch errors |
| [arangodb_operator_agency_fetches](./arangodb_operator_agency_fetches.md) | arangodb_operator | agency | Count | Current count of agency cache fetches |
| [arangodb_operator_agency_index](./arangodb_operator_agency_index.md) | arangodb_operator | agency | Gauge | Current index of the agency cache |
| [arangodb_operator_agency_cache_health_present](./arangodb_operator_agency_cache_health_present.md) | arangodb_operator | agency_cache | Gauge | Determines if local agency cache health is present |
| [arangodb_operator_agency_cache_healthy](./arangodb_operator_agency_cache_healthy.md) | arangodb_operator | agency_cache | Gauge | Determines if agency is healthy |
| [arangodb_operator_agency_cache_leaders](./arangodb_operator_agency_cache_leaders.md) | arangodb_operator | agency_cache | Gauge | Determines agency leader vote count |
| [arangodb_operator_agency_cache_member_commit_offset](./arangodb_operator_agency_cache_member_commit_offset.md) | arangodb_operator | agency_cache | Gauge | Determines agency member commit offset |
| [arangodb_operator_agency_cache_member_serving](./arangodb_operator_agency_cache_member_serving.md) | arangodb_operator | agency_cache | Gauge | Determines if agency member is reachable |
| [arangodb_operator_agency_cache_present](./arangodb_operator_agency_cache_present.md) | arangodb_operator | agency_cache | Gauge | Determines if local agency cache is present |
| [arangodb_operator_agency_cache_serving](./arangodb_operator_agency_cache_serving.md) | arangodb_operator | agency_cache | Gauge | Determines if agency is serving |
| Name | Namespace | Group | Type | Description |
|:---------------------------------------------------------------------------------------------------------------:|:-----------------:|:------------:|:-------:|:---------------------------------------------------|
| [arangodb_operator_agency_errors](./arangodb_operator_agency_errors.md) | arangodb_operator | agency | Counter | Current count of agency cache fetch errors |
| [arangodb_operator_agency_fetches](./arangodb_operator_agency_fetches.md) | arangodb_operator | agency | Counter | Current count of agency cache fetches |
| [arangodb_operator_agency_index](./arangodb_operator_agency_index.md) | arangodb_operator | agency | Gauge | Current index of the agency cache |
| [arangodb_operator_agency_cache_health_present](./arangodb_operator_agency_cache_health_present.md) | arangodb_operator | agency_cache | Gauge | Determines if local agency cache health is present |
| [arangodb_operator_agency_cache_healthy](./arangodb_operator_agency_cache_healthy.md) | arangodb_operator | agency_cache | Gauge | Determines if agency is healthy |
| [arangodb_operator_agency_cache_leaders](./arangodb_operator_agency_cache_leaders.md) | arangodb_operator | agency_cache | Gauge | Determines agency leader vote count |
| [arangodb_operator_agency_cache_member_commit_offset](./arangodb_operator_agency_cache_member_commit_offset.md) | arangodb_operator | agency_cache | Gauge | Determines agency member commit offset |
| [arangodb_operator_agency_cache_member_serving](./arangodb_operator_agency_cache_member_serving.md) | arangodb_operator | agency_cache | Gauge | Determines if agency member is reachable |
| [arangodb_operator_agency_cache_present](./arangodb_operator_agency_cache_present.md) | arangodb_operator | agency_cache | Gauge | Determines if local agency cache is present |
| [arangodb_operator_agency_cache_serving](./arangodb_operator_agency_cache_serving.md) | arangodb_operator | agency_cache | Gauge | Determines if agency is serving |
| [arangodb_operator_rebalancer_enabled](./arangodb_operator_rebalancer_enabled.md) | arangodb_operator | rebalancer | Gauge | Determines if rebalancer is enabled |
| [arangodb_operator_rebalancer_moves_current](./arangodb_operator_rebalancer_moves_current.md) | arangodb_operator | rebalancer | Gauge | Define how many moves are currently in progress |
| [arangodb_operator_rebalancer_moves_failed](./arangodb_operator_rebalancer_moves_failed.md) | arangodb_operator | rebalancer | Counter | Define how many moves failed |
| [arangodb_operator_rebalancer_moves_generated](./arangodb_operator_rebalancer_moves_generated.md) | arangodb_operator | rebalancer | Counter | Define how many moves were generated |
| [arangodb_operator_rebalancer_moves_succeeded](./arangodb_operator_rebalancer_moves_succeeded.md) | arangodb_operator | rebalancer | Counter | Define how many moves succeeded |
2 changes: 1 addition & 1 deletion docs/generated/metrics/arangodb_operator_agency_errors.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# arangodb_operator_agency_errors (Count)
# arangodb_operator_agency_errors (Counter)

## Description

Expand Down
2 changes: 1 addition & 1 deletion docs/generated/metrics/arangodb_operator_agency_fetches.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# arangodb_operator_agency_fetches (Count)
# arangodb_operator_agency_fetches (Counter)

## Description

Expand Down
12 changes: 12 additions & 0 deletions docs/generated/metrics/arangodb_operator_rebalancer_enabled.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# arangodb_operator_rebalancer_enabled (Gauge)

## Description

Determines if rebalancer is enabled

## Labels

| Label | Description |
|:---------:|:---------------------|
| namespace | Deployment Namespace |
| name | Deployment Name |
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# arangodb_operator_rebalancer_moves_current (Gauge)

## Description

Define how many moves are currently in progress

## Labels

| Label | Description |
|:---------:|:---------------------|
| namespace | Deployment Namespace |
| name | Deployment Name |
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# arangodb_operator_rebalancer_moves_failed (Counter)

## Description

Define how many moves failed

## Labels

| Label | Description |
|:---------:|:---------------------|
| namespace | Deployment Namespace |
| name | Deployment Name |
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# arangodb_operator_rebalancer_moves_generated (Counter)

## Description

Define how many moves were generated

## Labels

| Label | Description |
|:---------:|:---------------------|
| namespace | Deployment Namespace |
| name | Deployment Name |
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# arangodb_operator_rebalancer_moves_succeeded (Counter)

## Description

Define how many moves succeeded

## Labels

| Label | Description |
|:---------:|:---------------------|
| namespace | Deployment Namespace |
| name | Deployment Name |
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ require (
github.com/arangodb/go-driver v1.2.1
github.com/arangodb/go-driver/v2 v2.0.0-20211021031401-d92dcd5a4c83
github.com/arangodb/go-upgrade-rules v0.0.0-20180809110947-031b4774ff21
github.com/arangodb/rebalancer v0.1.1
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will add Linter rune to check it out

github.com/cenkalti/backoff v2.2.1+incompatible
github.com/dchest/uniuri v0.0.0-20160212164326-8902c56451e9
github.com/gin-gonic/gin v1.7.2
Expand Down
50 changes: 48 additions & 2 deletions internal/metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ namespaces:
fetches:
shortDescription: "Current count of agency cache fetches"
description: "Current count of agency cache fetches"
type: "Count"
type: "Counter"
labels:
- key: namespace
description: "Deployment Namespace"
Expand All @@ -97,7 +97,53 @@ namespaces:
errors:
shortDescription: "Current count of agency cache fetch errors"
description: "Current count of agency cache fetch errors"
type: "Count"
type: "Counter"
labels:
- key: namespace
description: "Deployment Namespace"
- key: name
description: "Deployment Name"
rebalancer:
enabled:
shortDescription: "Determines if rebalancer is enabled"
description: "Determines if rebalancer is enabled"
type: "Gauge"
labels:
- key: namespace
description: "Deployment Namespace"
- key: name
description: "Deployment Name"
moves_generated:
shortDescription: "Define how many moves were generated"
description: "Define how many moves were generated"
type: "Counter"
labels:
- key: namespace
description: "Deployment Namespace"
- key: name
description: "Deployment Name"
moves_succeeded:
shortDescription: "Define how many moves succeeded"
description: "Define how many moves succeeded"
type: "Counter"
labels:
- key: namespace
description: "Deployment Namespace"
- key: name
description: "Deployment Name"
moves_failed:
shortDescription: "Define how many moves failed"
description: "Define how many moves failed"
type: "Counter"
labels:
- key: namespace
description: "Deployment Namespace"
- key: name
description: "Deployment Name"
moves_current:
shortDescription: "Define how many moves are currently in progress"
description: "Define how many moves are currently in progress"
type: "Gauge"
labels:
- key: namespace
description: "Deployment Namespace"
Expand Down
1 change: 1 addition & 0 deletions pkg/apis/deployment/v1/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ const (
// Rebalancer
ActionTypeRebalancerGenerate ActionType = "RebalancerGenerate"
ActionTypeRebalancerCheck ActionType = "RebalancerCheck"
ActionTypeRebalancerClean ActionType = "RebalancerClean"

// Resources
ActionTypeResourceSync ActionType = "ResourceSync"
Expand Down
1 change: 1 addition & 0 deletions pkg/apis/deployment/v2alpha1/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ const (
// Rebalancer
ActionTypeRebalancerGenerate ActionType = "RebalancerGenerate"
ActionTypeRebalancerCheck ActionType = "RebalancerCheck"
ActionTypeRebalancerClean ActionType = "RebalancerClean"

// Resources
ActionTypeResourceSync ActionType = "ResourceSync"
Expand Down
4 changes: 3 additions & 1 deletion pkg/deployment/agency/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,9 @@ func getLeader(ctx context.Context, size int, clients map[string]agency.Agency)
for id := range names {
if h.leaderID == h.names[id] {
h.leader = clients[names[id]].Connection()
return clients[names[id]], configs[id], h, nil
if cfg := configs[id]; cfg != nil {
return clients[names[id]], cfg, h, nil
}
}
}

Expand Down
45 changes: 5 additions & 40 deletions pkg/deployment/agency/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,55 +21,20 @@
package agency

import (
_ "embed"
"encoding/json"
"testing"

"github.com/stretchr/testify/require"
)

func Test_Config_Unmarshal(t *testing.T) {
data := `{
"term": 0,
"leaderId": "AGNT-fd0f4fc7-b60b-44bb-9f5e-5fc91f708f82",
"commitIndex": 94,
"lastCompactionAt": 0,
"nextCompactionAfter": 500,
"lastAcked": {
"AGNT-fd0f4fc7-b60b-44bb-9f5e-5fc91f708f82": {
"lastAckedTime": 0,
"lastAckedIndex": 94
}
},
"configuration": {
"pool": {
"AGNT-fd0f4fc7-b60b-44bb-9f5e-5fc91f708f82": "tcp://[::1]:4001"
},
"active": [
"AGNT-fd0f4fc7-b60b-44bb-9f5e-5fc91f708f82"
],
"id": "AGNT-fd0f4fc7-b60b-44bb-9f5e-5fc91f708f82",
"agency size": 1,
"pool size": 1,
"endpoint": "tcp://[::1]:4001",
"min ping": 1,
"max ping": 5,
"timeoutMult": 1,
"supervision": true,
"supervision frequency": 1,
"compaction step size": 500,
"compaction keep size": 50000,
"supervision grace period": 10,
"supervision ok threshold": 5,
"version": 2,
"startup": "origin"
},
"engine": "rocksdb",
"version": "3.10.0-devel"
}`
//go:embed testdata/config.json
var config []byte

func Test_Config_Unmarshal(t *testing.T) {
var cfg Config

require.NoError(t, json.Unmarshal([]byte(data), &cfg))
require.NoError(t, json.Unmarshal(config, &cfg))

require.Equal(t, "AGNT-fd0f4fc7-b60b-44bb-9f5e-5fc91f708f82", cfg.LeaderId)
require.Equal(t, uint64(94), cfg.CommitIndex)
Expand Down
1 change: 1 addition & 0 deletions pkg/deployment/agency/plan_collections.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ type StatePlanCollection struct {
MinReplicationFactor *int `json:"minReplicationFactor,omitempty"`
WriteConcern *int `json:"writeConcern,omitempty"`
ReplicationFactor *ReplicationFactor `json:"replicationFactor,omitempty"`
DistributeShardsLike *string `json:"distributeShardsLike,omitempty"`
}

func (a *StatePlanCollection) GetReplicationFactor(shard string) ReplicationFactor {
Expand Down
4 changes: 4 additions & 0 deletions pkg/deployment/agency/rf.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ const (

type ReplicationFactor int

func (r *ReplicationFactor) IsNil() bool {
return r == nil
}

func (r *ReplicationFactor) IsUnknown() bool {
if r == nil {
return false
Expand Down
37 changes: 35 additions & 2 deletions pkg/deployment/agency/state_test.go

Large diffs are not rendered by default.

38 changes: 38 additions & 0 deletions pkg/deployment/agency/testdata/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"term": 0,
"leaderId": "AGNT-fd0f4fc7-b60b-44bb-9f5e-5fc91f708f82",
"commitIndex": 94,
"lastCompactionAt": 0,
"nextCompactionAfter": 500,
"lastAcked": {
"AGNT-fd0f4fc7-b60b-44bb-9f5e-5fc91f708f82": {
"lastAckedTime": 0,
"lastAckedIndex": 94
}
},
"configuration": {
"pool": {
"AGNT-fd0f4fc7-b60b-44bb-9f5e-5fc91f708f82": "tcp://[::1]:4001"
},
"active": [
"AGNT-fd0f4fc7-b60b-44bb-9f5e-5fc91f708f82"
],
"id": "AGNT-fd0f4fc7-b60b-44bb-9f5e-5fc91f708f82",
"agency size": 1,
"pool size": 1,
"endpoint": "tcp://[::1]:4001",
"min ping": 1,
"max ping": 5,
"timeoutMult": 1,
"supervision": true,
"supervision frequency": 1,
"compaction step size": 500,
"compaction keep size": 50000,
"supervision grace period": 10,
"supervision ok threshold": 5,
"version": 2,
"startup": "origin"
},
"engine": "rocksdb",
"version": "3.10.0-devel"
}
Loading