Skip to content

Destructive-apply guards query an empty kube context on AWS and Azure #197

Open

Description

@malon64

Milestone: v0.8-beta — Cloud and On-Premises Beta
Roadmap sequence: #183 (revised 2026-09-15)

Context

olf/deployment/cloud/platform.py::platform_up calls the two destructive-apply
guards before the drift reset:

require_no_stage_removal(config, tools, env=env)
require_no_shared_namespace_replacement(config, tools, env=env)

Both derive the cluster they inspect from config.kube_context
(local/platform.py:194 and :220, via kube_ops.namespace_exists and
deployed_stages_the_topology_dropped).

On AWS and Azure that value is empty at this point. DeploymentContext.aws()
and .azure() default kube_context: str = "" (deployment/context.py:287,
:336); only local sets one statically (kind-<cluster>, :268). The cloud
provider resolves the real context from the foundation outputs, but it does so
into a throwaway copy used solely to build the command environment:

# cloud/provider.py:103-104
facts = self._foundation_facts
resolved_context = replace(self.context, kube_context=facts.kube_context)

replace() returns a new object. self.config.context.kube_context stays "".

The contrast is visible three lines below the guards in the same function:
kube_ops.import_namespace_if_missing_in_state(...) is passed
context=facts.kube_context explicitly. The guards are not.

Impact

The guards issue kubectl --context '' get namespace ... — verified by
instrumenting the runner in tests/test_provider_conformance.py, which prints:

KUBECTL: ['kubectl', '--context', 'kind-openlakeforge-local', 'get', 'namespace', ...]   # local
KUBECTL: ['kubectl', '--context', '', 'get', 'namespace', ...]                           # aws
KUBECTL: ['kubectl', '--context', '', 'get', 'namespace', ...]                           # azure

An empty --context falls through to the kubeconfig's current context. When
that happens to be the deployment's own cluster the guard works by luck; when
the operator has switched contexts — routine, and likelier on a workstation
driving more than one environment — the guard inspects the wrong cluster.

Both guards then fail open: namespace_exists returns False and
deployed_stages_the_topology_dropped returns nothing, so an apply that should
have been refused proceeds. This is the apply that deletes a stage's namespace,
its services, and its credentials, or that replaces the pre-v0.3 lakehouse
shared namespace and everything stateful in it (SeaweedFS, PostgreSQL, Polaris).

The failure is silent — a guard that finds nothing looks exactly like a guard
with nothing to find.

Why it was invisible

olf.deployment.cloud.platform is on the mypy override list, and until
#193 no test drove the
guards through the cloud path at all. The suite added there catches that the
guards run; it does not assert which cluster they query, which is how this
survived. docs/technical-debt.md carries the corrected claim.

Fix

Pass the foundation-resolved context to both guards on the cloud path, as the
sibling import_namespace_if_missing_in_state call already does. That likely
means giving the guards an explicit context parameter rather than reading
config.kube_context, since the config is the thing that does not know it yet.

Then assert it: extend _guard_runner in tests/test_provider_conformance.py
to reject a kubectl invocation whose --context is not the provider's resolved
one, so this cannot regress. That assertion fails today.

Worth doing alongside the DeploymentConfig protocol work in #187, which owns
the same two guards — but the context bug is independently shippable and should
not wait for it.

Acceptance

  • Both guards query the foundation-resolved cluster on AWS and Azure.
  • test_provider_conformance.py fails if a guard queries an empty or wrong context.
  • The docs/technical-debt.md row is updated to what is then true.

Activity

  1. added
    bug
    on Sep 10, 2026
  2. added this to the milestone on Sep 15, 2026
  3. added
    track: operability
    on Oct 5, 2026
  4. added
    help wanted
    on Oct 21, 2026
  5. modified the milestones: , v0.9-beta — Cloud Beta (AWS, Scaleway, OVH) on Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bughelp wantedtrack: operability

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions