Skip to content

fix: ensure default namespace is used when none is specified for Kube… - #1021

Merged
Anson Qian (anson627) merged 1 commit into
mainfrom
fix-namespace-check-before-apply
Feb 3, 2026
Merged

Anson Qian (anson627) merged 1 commit into
mainfrom
fix-namespace-check-before-apply

Conversation

@anson627

@anson627 Anson Qian (anson627) commented Jan 16, 2026 •

Copy link
Copy Markdown
Contributor

This pull request updates the Kubernetes client logic to improve how namespaces are handled when applying manifests. Instead of raising an error when a namespace is missing for namespaced resources, the code now defaults to using the "default" namespace. Corresponding tests have also been updated to reflect this new behavior, ensuring that resources are created in the "default" namespace if none is specified.

Key changes include:

Namespace handling improvements:

  • Updated _apply_single_manifest in kubernetes_client.py to default to "default" namespace for namespaced resources if no namespace is provided in the manifest or as a parameter, instead of raising a ValueError. [1] [2] [3]

Test updates:

  • Refactored multiple tests in test_kubernetes_client.py to assert that the "default" namespace is used when a namespace is missing, rather than expecting an error. This includes tests for Deployments, StatefulSets, MPIJobs, Services, and ConfigMaps. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]

Logging and update logic:

  • Adjusted test expectations to reflect that logs and update calls now use "default" as the namespace when none is provided.

These changes make the manifest application process more robust and user-friendly by eliminating unnecessary errors and providing a sensible default namespace.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request changes the Kubernetes client's behavior when applying manifests that lack a namespace specification. Previously, the client would raise a ValueError for namespaced resources without a namespace. Now it defaults to using the "default" namespace instead. The test suite has been comprehensively updated to verify this new defaulting behavior.

Changes:

  • Modified _apply_single_manifest to default to "default" namespace for all resources when no namespace is specified
  • Updated 10+ unit tests to expect "default" namespace instead of ValueError when namespace is missing
  • Removed namespace validation checks that previously raised ValueErrors

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 8 comments.

File Description
modules/python/clients/kubernetes_client.py Updated _apply_single_manifest to default to "default" namespace, removing explicit namespace requirement checks
modules/python/tests/clients/test_kubernetes_client.py Updated tests to verify "default" namespace is used when none is specified, replacing tests that expected ValueError

@anson627
Anson Qian (anson627) force-pushed the fix-namespace-check-before-apply branch from cdfda96 to 532d86d Compare February 3, 2026 15:05
@anson627
Anson Qian (anson627) merged commit 67b1530 into main Feb 3, 2026
3 checks passed
@anson627
Anson Qian (anson627) deleted the fix-namespace-check-before-apply branch February 3, 2026 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants