Skip to content

Fix PrefectDeployment namespace resolution fallback logic#205

Merged
chrisguidry merged 2 commits intomainfrom
202-fix-namespace-fallback
Sep 19, 2025
Merged

Fix PrefectDeployment namespace resolution fallback logic#205
chrisguidry merged 2 commits intomainfrom
202-fix-namespace-fallback

Conversation

@chrisguidry
Copy link
Collaborator

The PrefectDeployment controller had a bug where it would hardcode "default"
as the fallback namespace instead of using the deployment's own namespace when
the server reference didn't specify a namespace.

This caused deployments to fail when the PrefectServer was in a different
namespace than "default", even when both resources were in the same namespace.

Changes

  • Updated NewClientFromServerReference to accept fallbackNamespace parameter
  • Fixed fallback logic to use provided namespace instead of hardcoded "default"
  • Updated NewClientFromK8s to pass the deployment's namespace as fallback
  • Added comprehensive tests to verify the fix works correctly
  • Updated Ginkgo version in .mise.toml to match go.mod (2.25.2)

The fix ensures that when a PrefectDeployment references a PrefectServer by
name only (without namespace), it correctly falls back to using the
deployment's namespace instead of always defaulting to "default".

Testing

  • Unit tests added and passing
  • Integration tested with minikube to verify namespace resolution works correctly
  • All existing tests continue to pass

Closes #202

🤖 Generated with Claude Code

The PrefectDeployment controller had a bug where it would hardcode "default"
as the fallback namespace instead of using the deployment's own namespace when
the server reference didn't specify a namespace.

This caused deployments to fail when the PrefectServer was in a different
namespace than "default", even when both resources were in the same namespace.

Changes:
- Updated NewClientFromServerReference to accept fallbackNamespace parameter
- Fixed fallback logic to use provided namespace instead of hardcoded "default"
- Updated NewClientFromK8s to pass the deployment's namespace as fallback
- Added comprehensive tests to verify the fix works correctly
- Updated Ginkgo version in .mise.toml to match go.mod (2.25.2)

The fix ensures that when a PrefectDeployment references a PrefectServer by
name only (without namespace), it correctly falls back to using the
deployment's namespace instead of always defaulting to "default".

Closes #202

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Replaced the problematic test that attempted actual port-forwarding
during test execution with focused URL generation tests. The original
test was failing in CI due to port-forwarding setup issues, but the
core namespace fallback logic is properly tested through direct URL
generation verification.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@chrisguidry chrisguidry merged commit 98ee2d7 into main Sep 19, 2025
3 checks passed
@chrisguidry chrisguidry deleted the 202-fix-namespace-fallback branch September 19, 2025 19:10
@mitchnielsen mitchnielsen added the fix Fix-related changes label Dec 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Fix-related changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix PrefectDeployment namespace resolution fallback logic

2 participants