Configs created as Config CRs are missing from list-config and other Factory.ListConfigs consumers
Describe the bug
A config created as a Config custom resource (kubevela#7211) is missing from every consumer that lists configs through pkg/config's Factory.ListConfigs: the list-config workflow step (config.#ListConfig) and VelaUX's config lists, including its image-registry and Helm-repository pickers. The Config controller materializes each Config into a Secret carrying the same labels as a legacy config, and ListConfigs deliberately skips any Secret owned by a Config, so the CR-backed config is never returned. Nothing lists the Config CRs instead.
vela config list has the mirror image: in its default auto mode it lists only Config CRs, so legacy configs are missing there. No consumer lists both, although #7211's design ("dual-read, single-write", kubevela#7308) says the two representations coexist.
Affects KubeVela master (1.12 line) since #7211. Consumers outside this repo are affected too: VelaUX calls Factory.ListConfigs for its config pages, image registries, Helm chart repositories and the Grafana menu.
To Reproduce
- A ConfigTemplate CR:
apiVersion: config.oam.dev/v1alpha1
kind: ConfigTemplate
metadata:
name: demo-endpoint
namespace: vela-system
spec:
scope: system
template: |
metadata: name: "demo-endpoint"
template: {
parameter: url: string
output: {
apiVersion: "v1"
kind: "Secret"
stringData: url: parameter.url
}
}- One Config CR and one legacy config of that template in
vela-system:
apiVersion: config.oam.dev/v1alpha1
kind: Config
metadata:
name: from-crd-global
namespace: vela-system
spec:
templateRef:
name: demo-endpoint
properties:
url: https://crd.example.comvela config create from-legacy -t demo-endpoint -n vela-system --config-mode legacy url=https://legacy.example.com(Any legacy writer works; VelaUX's POST /api/v1/configs was used here.)
- Both exist as labelled Secrets:
$ kubectl get secret -n vela-system -l config.oam.dev/type=demo-endpoint -o 'custom-columns=NAME:.metadata.name,OWNER:.metadata.ownerReferences[0].kind'
NAME OWNER
from-crd-global Config
from-legacy <none>- List them from a workflow:
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: list-configs-demo
namespace: default
spec:
components: []
workflow:
steps:
- name: list
type: list-config
properties:
template: demo-endpoint
namespace: vela-system
outputs:
- name: found
valueFrom: '"list-config found \(len(output.$returns.configs)) config(s)"'
- name: report
type: print-message-in-status
inputs:
- from: found
parameterKey: message$ kubectl get app list-configs-demo -o jsonpath='{.status.workflow.steps[1].message}'
list-config found 1 config(s)Only from-legacy is returned. vela config list -t demo-endpoint -n vela-system returns only from-crd-global.
Expected behavior
list-config (and Factory.ListConfigs) returns both configs, and so does vela config list. kubevela#7308 describes the model as "dual-read, single-write" with both representations coexisting, so a reader of either should see configs of both kinds.
Screenshots
N/A.
KubeVela Version
Core: master at f450c6e (built locally; `pkg/config` and the config controllers unchanged from master)
CLI: built from the same commitAffects every build since #7211; released 1.11.x predates the CRDs.
Cluster information
k3d, local single-node, Kubernetes v1.35.5 (k3s).
Additional context
- Where it appears in the code:
pkg/config/factory.go:814ListConfigslists Secrets by label and skips anyisConfigCRDOwnedSecret (factory.go:805-811, called at thecontinueinside the loop).pkg/workflow/providers/config/config.go:127thelist-configprovider callsfactory.ListConfigs.references/cli/config.go:387-420lists Config CRs only when the CLI is in CRD mode (references/cli/config_crd.go:45,autoby default).- The Config controller writes the owned Secret with the legacy labels "for compat" (
pkg/controller/config.oam.dev/v1alpha1/config/config_controller.go:202-254).
- Suggested fix: make
ListConfigsdual-read. Return legacy Secrets as today, plus each Config CR, built from the CR (alias, description, template) and its materialized Secret (properties), carrying the CR's phase, with a field saying which store it came from. The CLI's list would then use the same function in every mode. A CR write path in the Factory (movingconfig_crd.go's create, including the<name>-propertiescompanion Secret for sensitive templates) would let the workflowcreate-configstep and VelaUX write CRs too; todayconfig.#CreateConfigalways writes a legacy Secret. - Internal Configs: SourceDefinition's cache entries are Config CRs labelled
sourcedefinition.oam.dev/name(pkg/controller/core.oam.dev/v1beta1/application/source_cache_store_config.go:210-245). A dual-read list should leave those out. - Requirements from a consumer (VelaUX), whichever fix lands:
- A CR-backed config in list results carries its materialized Secret as
Config.Secret, as a legacy config does today. VelaUX builds image pull credentials from it and reads a Helm repository'surlfrom it. - Each returned config says which store it came from and, for a CR, its phase and conditions, so a caller can route updates and deletes, and show why a config is in Error.
- Deleting a CR-backed config deletes the Config CR (and any companion properties Secret), never only its owned Secret, which the controller recreates.
- Whether the cluster serves the Config CRDs is exposed to library callers, decided as the CLI's
automode decides it, so a caller against an older control plane stays on the legacy path without its own discovery. - A distribution of a CR-backed config is owned by its Config CR whichever caller creates it, as
setDistributionOwnerdoes for the CLI (references/cli/config_crd.go:182).
- A CR-backed config in list results carries its materialized Secret as
- Related: ConfigTemplate CRs are likewise missing from
Factory.ListTemplates(separate issue, https://github.com/kubevela/kubevela/issues/7417). - Verified: the steps above were run against a controller built from master on k3d; the outputs shown are observed. The
vela config create --config-mode legacyform in step 2 was not run (VelaUX's API created the legacy config), but it writes through the sameFactory.CreateOrUpdateConfig.
Source: kubevela/kubevela