#7418·kubevela

[Bug] --allow-cross-namespace-resource is silently ignored by GetPlacementsFromTopologyPolicies

Author: sakirr05Created Sep 29, 2026Updated Sep 30, 2026
Labelstype/bug

Is there an existing issue for this?

  • I have searched the existing issues

Affected area

Multi-cluster

KubeVela version

v1.11.0

Kubernetes version and distribution

not environment-specific; this is a code-level bug independent of the cluster. Verified with unit tests against envtest (Kubernetes v1.31.0)

Describe the bug

GetPlacementsFromTopologyPolicies in both pkg/workflow/providers/multicluster/multicluster.go and its legacy counterpart in pkg/workflow/providers/legacy/multicluster/multicluster.go hardcode true for the allowCrossNamespace argument instead of passing resourcekeeper, allowCrossNamespaceResource, the flag --allow-cross-namespace-resource controls. deploy.go in both packages does this correctsly

The bundled export-service and expor-data WorkflowStepDefinitions call the legacy provider directly and feed the result into kube.#Apply, which writes to the cluster without any further namespace check.

So an Application author can places a resource to a nsmespace they dont own even when the operator has explicitly disabled cross-namespace resources, with no error and nothing logged

To reproduce

To reproduce:

  1. Run vela-core with --allow-cross-namespace-resource=false.
  2. Apply an Application in namespace team-a with a topology policy targeting namespace: team-b.
  3. Use the bundled export-service (or export-data) step referencing that policy.
  4. The resource is created in team-b anyway, with no rejection.

Expected behavior

Step 4 should fail the same way the standard deploy step does, with cannot cross namespace

Screenshots or logs

Code showing the bug

deploy.go passes the operator-configured flag, as expected:

placements, err := pkgpolicy.GetPlacementsFromTopologyPolicies(
    ctx, executor.cli, executor.af.Namespace, policies,
    resourcekeeper.AllowCrossNamespaceResource,
)

But the CUE-callable provider hardcodes true, ignoring --allow-cross-namespace-resource entirely:

placements, err := pkgpolicy.GetPlacementsFromTopologyPolicies(
    ctx, params.KubeClient, params.Appfile.Namespace, policies,
    true, // should be resourcekeeper.AllowCrossNamespaceResource
)

The same hardcoded true appears in the legacy provider, which is what the bundled export-service and export-data steps call:

placements, err := pkgpolicy.GetPlacementsFromTopologyPolicies(
    ctx, params.KubeClient, params.Appfile.Namespace, policies,
    true, // should be resourcekeeper.AllowCrossNamespaceResource
)

Inside GetPlacementsFromTopologyPolicies, that argument is the only thing gating the cross-namespace check:

if !allowCrossNamespace && (ns != appNs && ns != "") {
    return errors.Errorf("cannot cross namespace")
}

Additional context

No response