Skip to content

Commit

Permalink
Shorten `grafana.com/rollout-mirror-replicas-from-resource-write-back…
Browse files Browse the repository at this point in the history
…-status-replicas` annotation (#171)

* Renamed `grafana.com/rollout-mirror-replicas-from-resource-write-back-status-replicas` annotation to `grafana.com/rollout-mirror-replicas-from-resource-write-back`

* Fix changelog.
  • Loading branch information
pstibrany authored Aug 28, 2024
1 parent a37d1cf commit 3a78df9
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 28 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## main / unreleased

* [CHANGE] Renamed `grafana.com/rollout-mirror-replicas-from-resource-write-back-status-replicas` annotation to `grafana.com/rollout-mirror-replicas-from-resource-write-back`, because it was too long (over 64 chars). #171

## v0.19.0

* [ENHANCEMENT] Updated dependencies, including: #165
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ Rollout-operator can use custom resource with `scale` and `status` subresources
* `grafana.com/rollout-mirror-replicas-from-resource-name`
* `grafana.com/rollout-mirror-replicas-from-resource-kind`
* `grafana.com/rollout-mirror-replicas-from-resource-api-version`
* `grafana.com/rollout-mirror-replicas-from-resource-write-back-status-replicas`
* `grafana.com/rollout-mirror-replicas-from-resource-write-back`

These annotations must be set on StatefulSet that rollout-operator will scale (ie. target statefulset).
Number of replicas in target statefulset will follow replicas in reference resource (from `scale` subresource).
Reference resource's `status` subresource will be updated with current number of replicas in target statefulset,
unless explicitly disabled by setting `grafana.com/rollout-mirror-replicas-from-resource-write-back-status-replicas` annotation to `false`.
unless explicitly disabled by setting `grafana.com/rollout-mirror-replicas-from-resource-write-back` annotation to `false`.

This is similar to using `grafana.com/rollout-downscale-leader`, but reference resource can be any kind of resource, not just statefulset. Furthermore `grafana.com/min-time-between-zones-downscale` is not respected when using scaling based on reference resource.

Expand Down
4 changes: 2 additions & 2 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ const (
// replicas based on replicas in this resource (its scale subresource).
RolloutMirrorReplicasFromResourceNameAnnotationKey = rolloutMirrorReplicasFromResourceAnnotationKeyPrefix + "-name"
RolloutMirrorReplicasFromResourceKindAnnotationKey = rolloutMirrorReplicasFromResourceAnnotationKeyPrefix + "-kind"
RolloutMirrorReplicasFromResourceAPIVersionAnnotationKey = rolloutMirrorReplicasFromResourceAnnotationKeyPrefix + "-api-version" // optional
RolloutMirrorReplicasFromResourceWriteBackStatusReplicas = rolloutMirrorReplicasFromResourceAnnotationKeyPrefix + "-write-back-status-replicas" // optional
RolloutMirrorReplicasFromResourceAPIVersionAnnotationKey = rolloutMirrorReplicasFromResourceAnnotationKeyPrefix + "-api-version" // optional
RolloutMirrorReplicasFromResourceWriteBackStatusReplicas = rolloutMirrorReplicasFromResourceAnnotationKeyPrefix + "-write-back" // optional

// RolloutDelayedDownscaleAnnotationKey configures delay for downscaling. Prepare-url must be configured as well, and must support GET, POST and DELETE methods.
RolloutDelayedDownscaleAnnotationKey = "grafana.com/rollout-delayed-downscale"
Expand Down
48 changes: 24 additions & 24 deletions pkg/controller/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,10 +413,10 @@ func TestRolloutController_Reconcile(t *testing.T) {
"should return early and scale up statefulset based on reference custom resource, but not patch the resource since it's disabled": {
statefulSets: []runtime.Object{
mockStatefulSet("ingester-zone-b", withReplicas(2, 2), withAnnotations(map[string]string{
"grafana.com/rollout-mirror-replicas-from-resource-name": "test",
"grafana.com/rollout-mirror-replicas-from-resource-kind": customResourceGVK.Kind,
"grafana.com/rollout-mirror-replicas-from-resource-api-version": customResourceGVK.GroupVersion().String(),
"grafana.com/rollout-mirror-replicas-from-resource-write-back-status-replicas": "false",
"grafana.com/rollout-mirror-replicas-from-resource-name": "test",
"grafana.com/rollout-mirror-replicas-from-resource-kind": customResourceGVK.Kind,
"grafana.com/rollout-mirror-replicas-from-resource-api-version": customResourceGVK.GroupVersion().String(),
"grafana.com/rollout-mirror-replicas-from-resource-write-back": "false",
})),
},
customResourceScaleSpecReplicas: 5,
Expand All @@ -440,10 +440,10 @@ func TestRolloutController_Reconcile(t *testing.T) {
"should return early and scale down statefulset based on reference custom resource, but not patch the resource since it's disabled": {
statefulSets: []runtime.Object{
mockStatefulSet("ingester-zone-b", withReplicas(3, 3), withAnnotations(map[string]string{
"grafana.com/rollout-mirror-replicas-from-resource-name": "test",
"grafana.com/rollout-mirror-replicas-from-resource-kind": customResourceGVK.Kind,
"grafana.com/rollout-mirror-replicas-from-resource-api-version": customResourceGVK.GroupVersion().String(),
"grafana.com/rollout-mirror-replicas-from-resource-write-back-status-replicas": "false",
"grafana.com/rollout-mirror-replicas-from-resource-name": "test",
"grafana.com/rollout-mirror-replicas-from-resource-kind": customResourceGVK.Kind,
"grafana.com/rollout-mirror-replicas-from-resource-api-version": customResourceGVK.GroupVersion().String(),
"grafana.com/rollout-mirror-replicas-from-resource-write-back": "false",
})),
},
customResourceScaleSpecReplicas: 2,
Expand All @@ -467,10 +467,10 @@ func TestRolloutController_Reconcile(t *testing.T) {
"should not patch scale subresource status.replicas since it's disabled, even though spec.replicas != statefulset.spec.replicas": {
statefulSets: []runtime.Object{
mockStatefulSet("ingester-zone-b", withReplicas(3, 3), withAnnotations(map[string]string{
"grafana.com/rollout-mirror-replicas-from-resource-name": "test",
"grafana.com/rollout-mirror-replicas-from-resource-kind": customResourceGVK.Kind,
"grafana.com/rollout-mirror-replicas-from-resource-api-version": customResourceGVK.GroupVersion().String(),
"grafana.com/rollout-mirror-replicas-from-resource-write-back-status-replicas": "false",
"grafana.com/rollout-mirror-replicas-from-resource-name": "test",
"grafana.com/rollout-mirror-replicas-from-resource-kind": customResourceGVK.Kind,
"grafana.com/rollout-mirror-replicas-from-resource-api-version": customResourceGVK.GroupVersion().String(),
"grafana.com/rollout-mirror-replicas-from-resource-write-back": "false",
})),
},
customResourceScaleSpecReplicas: 3,
Expand Down Expand Up @@ -521,10 +521,10 @@ func TestRolloutController_Reconcile(t *testing.T) {
"grafana.com/rollout-mirror-replicas-from-resource-api-version": customResourceGVK.GroupVersion().String(),
})),
mockStatefulSet("ingester-zone-c", withReplicas(5, 5), withAnnotations(map[string]string{
"grafana.com/rollout-mirror-replicas-from-resource-name": "test",
"grafana.com/rollout-mirror-replicas-from-resource-kind": customResourceGVK.Kind,
"grafana.com/rollout-mirror-replicas-from-resource-api-version": customResourceGVK.GroupVersion().String(),
"grafana.com/rollout-mirror-replicas-from-resource-write-back-status-replicas": "true", // Patching of reference resource is explicitly enabled.
"grafana.com/rollout-mirror-replicas-from-resource-name": "test",
"grafana.com/rollout-mirror-replicas-from-resource-kind": customResourceGVK.Kind,
"grafana.com/rollout-mirror-replicas-from-resource-api-version": customResourceGVK.GroupVersion().String(),
"grafana.com/rollout-mirror-replicas-from-resource-write-back": "true", // Patching of reference resource is explicitly enabled.
})),
mockStatefulSet("ingester-zone-d", withReplicas(2, 2), withAnnotations(map[string]string{
"grafana.com/rollout-mirror-replicas-from-resource-name": "test",
Expand All @@ -543,16 +543,16 @@ func TestRolloutController_Reconcile(t *testing.T) {
mockStatefulSet("ingester-zone-a", withReplicas(4, 4)),
// Is already scaled.
mockStatefulSet("ingester-zone-b", withReplicas(5, 5), withAnnotations(map[string]string{
"grafana.com/rollout-mirror-replicas-from-resource-name": "test",
"grafana.com/rollout-mirror-replicas-from-resource-kind": customResourceGVK.Kind,
"grafana.com/rollout-mirror-replicas-from-resource-api-version": customResourceGVK.GroupVersion().String(),
"grafana.com/rollout-mirror-replicas-from-resource-write-back-status-replicas": "false", // Explicitly disabled.
"grafana.com/rollout-mirror-replicas-from-resource-name": "test",
"grafana.com/rollout-mirror-replicas-from-resource-kind": customResourceGVK.Kind,
"grafana.com/rollout-mirror-replicas-from-resource-api-version": customResourceGVK.GroupVersion().String(),
"grafana.com/rollout-mirror-replicas-from-resource-write-back": "false", // Explicitly disabled.
})),
mockStatefulSet("ingester-zone-c", withReplicas(5, 5), withAnnotations(map[string]string{
"grafana.com/rollout-mirror-replicas-from-resource-name": "test",
"grafana.com/rollout-mirror-replicas-from-resource-kind": customResourceGVK.Kind,
"grafana.com/rollout-mirror-replicas-from-resource-api-version": customResourceGVK.GroupVersion().String(),
"grafana.com/rollout-mirror-replicas-from-resource-write-back-status-replicas": "bad value", // Disabled through wrong value.
"grafana.com/rollout-mirror-replicas-from-resource-name": "test",
"grafana.com/rollout-mirror-replicas-from-resource-kind": customResourceGVK.Kind,
"grafana.com/rollout-mirror-replicas-from-resource-api-version": customResourceGVK.GroupVersion().String(),
"grafana.com/rollout-mirror-replicas-from-resource-write-back": "bad value", // Disabled through wrong value.
})),
mockStatefulSet("ingester-zone-d", withReplicas(2, 2), withAnnotations(map[string]string{
"grafana.com/rollout-mirror-replicas-from-resource-name": "test",
Expand Down

0 comments on commit 3a78df9

Please sign in to comment.