Repository navigation
🚀 New Features
Agent Grouping Library
In agentless mode, one agent can now serve several clusters instead of one agent for each cluster. The new flag --agent-clusters-per-instance N, on addon-controller and classifier, makes one drift-detection-manager and one sveltos-agent Deployment serve a group of up to N clusters of the same namespace and shard. The default is 1, which keeps the current behavior, and the flag is ignored when the agent runs in the managed cluster and in pull mode. The members of a group are recorded in a ConfigMap with the same name as the Deployment. A cluster is placed in the first group with room and never moves afterwards, and concurrent placements of the same cluster are serialized, so it is never in two groups. Placement state is rebuilt from the ConfigMaps on restart. The Deployment of a group is removed when its last member leaves, and members whose cluster is gone are removed by a periodic sweep. For sveltos-agent only global agent patches apply to a group. AgentGrouping is a new licensed feature: grouping requires a Sveltos Enterprise license granting it, enforced by the agents.
PRs: libsveltos #715, addon-controller #2086, classifier #535
⚙️ Improvements
libsveltos: Lua Tables Are Pre-sized When Converting Resources
Converting a Kubernetes resource to a Lua table grew every table key by key, reallocating it several times. The tables are now sized from the input. On a 16.5 KB Pod the conversion went from about 300 us to 165 us and from 721 KB to 224 KB allocated. With 3,000 Pods in a kind cluster, sveltos-agent allocated 15 GB in 5 minutes instead of 40 GB, and its peak RSS went from 928 MiB to 758 MiB.
PR: libsveltos #716
libsveltos: Compiled CEL Programs Are Cached
Every evaluation of a CEL rule built the environment and parsed, checked and planned the rule again for each object. The compiled program is now kept per expression in a bounded cache of 512 expressions and 1 MiB of rule text, about 16 MB at most. An edited rule is a different key, and an invalid rule is not parsed again for every object. A rule evaluation went from 20.9 us to 0.28 us for a small rule, and from 24.4 ms to 0.12 ms for a 64 KB rule. In a kind cluster, sveltos-agent re-evaluating an EventSource with 3 CEL rules over 20,000 ConfigMaps used 1.87 s of CPU instead of 33.27 s, and its allocation rate went from 149 MB/s to 4 MB/s.
PR: libsveltos #718
sveltos-agent: Smaller Informer Cache
With --discard-managed-fields, the agent removed managedFields from the objects it caches but kept the last-applied-configuration annotation, which holds a full copy of any object created with kubectl apply. The annotation is now removed too, and other annotations are kept. With 20,000 ConfigMaps of about 1.5 KB created with kubectl apply, heap after GC went from about 144 MB to 104 MB and peak RSS from 272 MB to 203 MB.
addon-controller: Dependencies Are Requeued Instead of Polled
A ClusterSummary waiting on a dependsOn prerequisite, or a prerequisite waiting for its dependents to be removed, noticed the change only at its next 10 second poll. That added up to 10 seconds for each level of dependency. When a ClusterSummary becomes Provisioned, its dependents are now requeued, and when one is removed, the ClusterSummaries it depends on are requeued if they are being deleted. On 6 fake clusters a dependent now finishes 10 s after its prerequisite instead of 19 to 20 s, and a whole delete takes 30 s instead of 55 s. With --auto-deploy-dependencies=false a deploy still falls back to the poll.
PR: addon-controller #2110
🐞 Bug Fixes
ClusterPromotion: Stuck With a Current Stage That Had No Status Entry
The controller writes the spec and the status of a ClusterPromotion in two requests, so a reconcile that read a stale status could overwrite status.stages and drop the entry of the stage just started. Without the entry the stage could never be marked as provisioned, and the promotion stayed on it whatever the trigger, with manual approval or not. This was reported after the upgrade to v1.17.0. The state is now detected and the stage is started again. If the stage is no longer in the spec, the promotion restarts from the first stage.
driftExclusions Ignored on Metadata Annotations and Labels
An exclusion on /metadata/annotations/... or /metadata/labels/... had no effect: a change to that annotation or label was reported as drift and the profile was redeployed, for example when an operator stamps an annotation on an object Sveltos delivers. The hash is now computed after the exclusions are applied. Resources not matched by any exclusion keep the same hash.
PR: addon-controller #2098
Helm Chart Resources Not Tracked for Drift When the CRD Is Only in the Managed Cluster
When drift-detection-manager runs in the management cluster, the kind of a resource rendered by a Helm chart was resolved against the management cluster. A custom resource with no namespace whose CRD is only in the managed cluster failed with no matches for kind, helmResourceHashes stayed empty and no drift was detected for that ResourceSummary. The kind is now resolved against the cluster hosting the deployed resources. A new functional test covers it.
PR: addon-controller #2113
addon-controller: Empty Chart Name for a Flux-sourced Helm Chart
chartName is optional for a Helm chart from a Flux source, but it was copied as is into the ResourceSummary, where it must not be empty. With ContinuousWithDriftDetection the ResourceSummary was never created and the deploy was retried forever, raising the Helm release revision each time. The last segment of the Flux source path, or the release name, is now reported. The value is informational: drift is matched by release name and namespace.
PR: addon-controller #2111
classifier: sveltos-agent Not Redeployed When --registry Changes
The hash that decides whether sveltos-agent must be redeployed did not include the registry, so after classifier-manager restarted with a different --registry the agents kept pulling from the previous one. The registry and the NATS watcher flag are now part of the hash, and going back to the default is detected too.
PR: classifier #537
event-manager: Metrics Kept Series of Deleted EventTriggers and Removed Clusters
When a cluster stopped matching an EventTrigger or was deleted, reconcile_outcome_total, reconcile_last_success_timestamp_seconds and matching_resources kept its last values, and a deleted EventTrigger kept its matching_clusters. They stayed until event-manager restarted. The series are now removed with the cluster entry or the EventTrigger. Metrics of other EventTriggers and clusters are untouched.
PR: event-manager #535
classifier: Metrics Kept Series of Deleted Clusters
reconcile_duration_seconds, reconcile_outcome_total and reconcile_last_success_timestamp_seconds are labeled by cluster and were never cleaned. On a management cluster creating and deleting about 280 clusters a day, classifier exported 10,720 distinct cluster_name values for 37 live clusters, about 161k samples per scrape. The series of a cluster are now removed when the cluster is deleted.
PR: classifier #542
sveltos-agent: Reports Too Large to Be Stored Were Retried Forever
When the EventReport or HealthCheckReport was too large to be written, the agent requeued the evaluation on every cycle. The same objects gave the same oversized report, so it never succeeded and kept the agent at about one CPU core. The evaluation is no longer requeued for that error and runs again when the EventSource, the HealthCheck or the selected resources change. The reason is recorded in status.agentFailureMessage with the number of matching resources. An existing report keeps its spec, so the management cluster keeps acting on the last stored result. EventReport updates were also skipped while a failure message was set, so the message never cleared. It now does.
User-supplied Lua Ran With the io and os Libraries Open
Lua scripts coming from Sveltos resources ran in a state with the io and os libraries fully available, so a script could read files or environment variables of the pod. libsveltos has a new NewSandboxedState that opens only the base, package, table, string, math and coroutine libraries, keeps time, date, clock and difftime from os, removes dofile and loadfile, and empties package.path so require cannot load files from the host. Preloaded modules (json, strings, runes, sprig) keep working. classifier and sveltoscluster-manager now use it. See the upgrade note.
PRs: libsveltos #721, classifier #545, sveltoscluster-manager #393
⚠️ Upgrade notes
Across Sveltos, Lua scripts run in a sandbox. A script that uses io, os functions other than time, date, clock and difftime, dofile, loadfile, or require of a file on disk now fails. Scripts that only use the standard string, table and math libraries, and the json, strings, runes and sprig modules, are not affected.