Skip to content
Open
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 api/operator/v1beta1/vmextra_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const (
UpdateStatusOperational UpdateStatus = "operational"
UpdateStatusFailed UpdateStatus = "failed"
UpdateStatusPaused UpdateStatus = "paused"
UpdateStatusIgnored UpdateStatus = "ignored"
)

// WorkloadKind represents the kind of Kubernetes workload managed by an operator component.
Expand Down
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ aliases:
* FEATURE: [helm-converter](https://docs.victoriametrics.com/operator/helm-converter/): parse the victoria-metrics-auth chart's `config` value (vmauth's own native config file). Each `config.users` entry is converted into a standalone `VMUser` CR, and `config.unauthorized_user` is converted into the `VMAuth` CR's `spec.unauthorizedUserAccessSpec`. The generated `VMUser` CRs are appended to the same output file as additional YAML documents, and the `VMAuth` CR's `spec.userSelector` is set to a dedicated label matching them, so the operator actually loads them (a bare `VMAuth` CR's default selectors match nothing). See [#2397](https://github.com/VictoriaMetrics/operator/issues/2397).
* FEATURE: [vmoperator](https://docs.victoriametrics.com/operator/): introduce `VLDistributed` CR, which controls multiple region-distributed VictoriaLogs clusters.

* BUGFIX: [vmoperator](https://docs.victoriametrics.com/operator/): support `Ignored` status for child objects that were not picked, also do not set `Failed` status if object was applied on at least one parent object. See [#2432](https://github.com/VictoriaMetrics/operator/issues/2432).
* BUGFIX: [vmoperator](https://docs.victoriametrics.com/operator/): removed `library/` component, while building CR images that do not contain `/` in repo name. See [#2409](https://github.com/VictoriaMetrics/operator/issues/2409).
* BUGFIX: [vmoperator](https://docs.victoriametrics.com/operator/): log only the changed key names and value sizes, instead of the full values, when updating `ConfigMap`. Previously a single `data_diff` log line could reach multiple megabytes for large ConfigMaps and break downstream log pipelines with per-line size limits. See [#2426](https://github.com/VictoriaMetrics/operator/issues/2426).
* BUGFIX: [vmagent](https://docs.victoriametrics.com/operator/resources/vmagent/), [vmsingle](https://docs.victoriametrics.com/operator/resources/vmsingle/): add missing `list` verb to config-reloader's secrets RBAC rule. See [#2384](https://github.com/VictoriaMetrics/operator/issues/2384).
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package k8stools

import (
"sigs.k8s.io/controller-runtime/pkg/client"

vmv1beta1 "github.com/VictoriaMetrics/operator/api/operator/v1beta1"
)

// ObjectWithConditions is satisfied by any CRD type exposing StatusMetadata.Conditions.
type ObjectWithConditions interface {
client.Object
GetStatusMetadata() *vmv1beta1.StatusMetadata
}

// ChildConditionIndexField is the field-indexer name reconcile.StatusForChildObjects uses
// to find children carrying a specific parent's Applied condition without listing every
// object of that kind. Every CRD kind passed to StatusForChildObjects must have
// ChildConditionIndexerFunc registered under this name on the manager.
const ChildConditionIndexField = "status.conditions.type"

// ChildConditionIndexerFunc indexes an object by every condition Type it currently carries.
func ChildConditionIndexerFunc(obj client.Object) []string {
sw, ok := obj.(ObjectWithConditions)
if !ok {
return nil
}
conds := sw.GetStatusMetadata().Conditions
if len(conds) == 0 {
return nil
}
keys := make([]string, 0, len(conds))
for _, c := range conds {
keys = append(keys, c.Type)
}
return keys
}
18 changes: 18 additions & 0 deletions internal/controller/operator/factory/k8stools/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,21 @@ func GetTestClientWithObjects(predefinedObjects []runtime.Object) client.Client
return getTestClient(predefinedObjects, &fns)
}

// childConditionIndexedKinds are the CRD kinds reconcile.StatusForChildObjects can be
// called with; they need ChildConditionIndexField registered for release lookups to work.
var childConditionIndexedKinds = []client.Object{
&vmv1beta1.VMRule{},
&vmv1beta1.VMServiceScrape{},
&vmv1beta1.VMPodScrape{},
&vmv1beta1.VMProbe{},
&vmv1beta1.VMScrapeConfig{},
&vmv1beta1.VMStaticScrape{},
&vmv1beta1.VMNodeScrape{},
&vmv1beta1.VMUser{},
&vmv1beta1.VMAlertmanagerConfig{},
&vmv1.VMAnomalyConfig{},
}

func getTestClient(predefinedObjects []runtime.Object, fns *interceptor.Funcs) client.Client {
builder := fake.NewClientBuilder().
WithScheme(testGetScheme()).
Expand Down Expand Up @@ -140,6 +155,9 @@ func getTestClient(predefinedObjects []runtime.Object, fns *interceptor.Funcs) c
&vpav1.VerticalPodAutoscaler{},
).
WithRuntimeObjects(predefinedObjects...)
for _, obj := range childConditionIndexedKinds {
builder = builder.WithIndex(obj, ChildConditionIndexField, ChildConditionIndexerFunc)
}
if fns != nil {
builder = builder.WithInterceptorFuncs(*fns)
}
Expand Down
Loading