Reconfigure Linseed and linseed user when migrating from multi-index to single-index - #5132
Open
asincu wants to merge 4 commits into
Open
Reconfigure Linseed and linseed user when migrating from multi-index to single-index#5132asincu wants to merge 4 commits into
asincu wants to merge 4 commits into
Conversation
cluster This will be set operator bootstrap config map and enabled when migrating from multi-index format to single-index format. Linseed will reconfigure its environment variables to set the correct backend for the indices it is using and also set the base index name used for Cloud.
…hile migrating to single-index storage Single-tenant clusters migrating to single-index storage need Linseed to hold RBAC for the new calico_* indices. es-kube-controllers cannot grant that, so during the migration the operator's log-storage users controller takes over user provisioning and es-kube-controllers stops running its elasticsearch configuration controller. - Run the users controller in single-tenant mode when IndexMigration is set, building the tenant configuration from the cloud config ConfigMap since single-tenant clusters have no Tenant resource. - Name the single-tenant Linseed and Dashboards users the way es-kube-controllers named them (<name>-<tenantID>-secure), and repoint existing credential secrets at those users while keeping their passwords, so credentials provisioned before the migration keep resolving. - Declare the standard single-index names on the Tenant that CloudConfig.ToTenant builds, gated on the caller opting in, so that clusters which are not migrating keep falling back to their existing index names. Sort the declared indices, as they are generated from a map. - Report the users TigeraStatus in the log-storage conditions aggregate while migrating.
…rom writing on every reconcile updateConditions built its result by ranging over the desiredConditions map, so the order of LogStorage.Status.Conditions was randomized on every reconcile. Conditions is an atomic list, so a reorder is a real change to the stored object: each reconcile bumped the resourceVersion, and since this controller also watches LogStorage, that re-enqueued itself. The write loop ran continuously, and reconciles fired faster than the informer cache could converge - so reconciles read a stale tigera-secure and their status updates were rejected with "the object has been modified". Sort the conditions by type so the stored list is stable, skip the status update entirely when the computed conditions match what is already stored, and requeue instead of erroring when an update does hit a conflict.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the operator’s log-storage reconciliation path for Calico Cloud index migration, shifting Elasticsearch user provisioning responsibilities and reconfiguring Linseed to use the correct single-index backend and index base names during migration.
Changes:
- Add an
IndexMigration/UseSingleIndexsignal from bootstrap config through controller options into rendering logic. - Disable es-kube-controllers’
elasticsearchconfigurationcontroller during index migration and move user provisioning to the operator’s log-storage users controller. - Add Cloud single-index base index naming defaults and ensure deterministic ordering to avoid reconcile churn.
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/render/logstorage/linseed/linseed.go | Adds single-index backend env var rendering for single-tenant migration path. |
| pkg/render/kubecontrollers/kube-controllers.go | Adds IndexMigration flag and gates elasticsearchconfiguration controller enablement. |
| pkg/render/kubecontrollers/kube-controllers_test.go | Adds test asserting elasticsearchconfiguration is disabled during migration. |
| pkg/render/common/cloudconfig/cloudconfig.go | Extends ToTenant to optionally populate standard single-index base names deterministically. |
| pkg/render/common/cloudconfig/cloudconfig_test.go | Adds tests for ToTenant(useSingleIndex) behavior and stable ordering. |
| pkg/controller/utils/elasticsearch.go | Adds single-tenant username formatting and single-tenant Linseed/Dashboards user helpers. |
| pkg/controller/policyrecommendation/policyrecommendation_controller.go | Updates CloudConfig ToTenant call signature. |
| pkg/controller/options/options.go | Adds IndexMigration option plumbed from bootstrap config. |
| pkg/controller/manager/manager_controller_cloud.go | Updates CloudConfig ToTenant call signature. |
| pkg/controller/logstorage/users/users_controller.go | Enables operator user provisioning for single-tenant index migration; adds single-tenant user naming and credential “re-pointing”. |
| pkg/controller/logstorage/users/users_controller_test.go | Adds controller tests for single-tenant migrating behavior and credential repointing. |
| pkg/controller/logstorage/linseed/linseed_controller.go | Plumbs index-migration flag into Linseed render config and CloudConfig tenant conversion. |
| pkg/controller/logstorage/kubecontrollers/es_kube_controllers.go | Plumbs IndexMigration through controller state. |
| pkg/controller/logstorage/kubecontrollers/cloud.go | Sets kube-controllers render config IndexMigration during Cloud reconcile. |
| pkg/controller/logstorage/initializer/conditions_controller.go | Avoids no-op status writes, handles conflicts, and stabilizes condition ordering; includes users controller condition in migration. |
| pkg/controller/logstorage/dashboards/dashboards_controller.go | Updates CloudConfig ToTenant call signature and clarifies credential provisioning during migration. |
| pkg/controller/intrusiondetection/intrusiondetection_controller.go | Updates CloudConfig ToTenant call signature. |
| pkg/controller/compliance/compliance_controller.go | Updates CloudConfig ToTenant call signature. |
| pkg/common/discovery/discovery.go | Adds INDEX_MIGRATION bootstrap config parsing helper. |
| cmd/main.go | Reads INDEX_MIGRATION bootstrap config and sets controller options. |
| api/v1/tenant_types.go | Adds Cloud standard base index name mapping by datatype. |
Comment on lines
287
to
+290
| var enabledControllers []string | ||
| if !cfg.Tenant.MultiTenant() { | ||
| // Zero and single tenant cluster needs elasticsearch configuration | ||
| enabledControllers = append(enabledControllers, "authorization", "elasticsearchconfiguration") | ||
| enabledControllers = append(enabledControllers, "authorization") |
| DataTypePolicyActivity: "ELASTIC_POLICY_ACTIVITY_BASE_INDEX_NAME", | ||
| } | ||
|
|
||
| var CloudStandardIndices = map[DataType]string{ |
Comment on lines
+60
to
+62
| // This field is enabled in the last phase of an index migration for a single tenant format, | ||
| // we need to reconfigure | ||
| IndexMigration bool |
Comment on lines
+431
to
+432
| // For single-tenant clusters migrating to multi-tenant style indices, | ||
| // use the elastic-single-index backend and configure index base names. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
indices it is using and also set the base index name used for Cloud.
Release Note
For PR author
make gen-filesmake gen-versionsFor PR reviewers
A note for code reviewers - all pull requests must have the following:
kind/bugif this is a bugfix.kind/enhancementif this is a a new feature.enterpriseif this PR applies to Calico Enterprise only.