#22115·meshery

[Server] Kubernetes context registration reports success when context persistence fails

Author: maverickaayushCreated Sep 27, 2026Updated Sep 28, 2026

Description

Local Kubernetes context registration reports success after the connection row is saved even when saving the corresponding Kubernetes context fails. This leaves a connection without its required context/credentials and prevents callers from detecting the partial write.

Current Behavior

If the context database write fails, SaveK8sContext returns the created connection and a nil error.

Expected Behavior

SaveK8sContext should propagate the context persistence error (and ideally avoid or reconcile the partial connection write) so registration is not reported as successful.

Steps to Reproduce

  1. Configure a local provider with a working connection persister.
  2. Configure its Kubernetes-context persister with a closed database.
  3. Call SaveK8sContext with a valid context.
  4. Observe that the method returns nil error after the context write fails.

Evidence

$ go test ./server/models -run '^TestReproSaveK8sContextReportsContextPersistenceFailure$' -count=1
SaveK8sContext reported success after K8s context persistence failed
FAIL

Root Cause

DefaultLocalProvider.SaveK8sContext explicitly discards both return values from SaveMesheryK8sContext and always returns success once SaveConnection succeeds.

Affected Components

  • Meshery Server
  • Local provider
  • Kubernetes connection registration
  • Connection/context persistence lifecycle

Validation

Executed on master commit 5b75615243e92b088b4ebf6e7bff82d6f60e5462:

go test ./server/models -run '^TestReproSaveK8sContextReportsContextPersistenceFailure$' -count=1

Result: deterministic failure; the injected persistence failure is returned as success.

Acceptance Criteria

  • A failed context write returns a non-nil error to the registration caller.
  • Registration does not leave an unexplained successful connection/context mismatch, either through atomic persistence or explicit cleanup/reconciliation.
  • A regression test forces the second persistence step to fail.

References