feat(KLEF-204): Namespace aware provisioning - #35
Merged
Conversation
Adds NamespaceID support to WorkloadSpec so namespace-scoped provision jobs are accepted and routed correctly; previously jobs with only namespace_id set were rejected as invalid (project_id required). Also adds Discover() to RuntimeAdapter for startup re-adoption of existing workloads, namespace-scoped Docker network management, and updated labels package with kleff.io/namespace_id support.
JeremyNRoos
force-pushed
the
feat/namespace-aware-provisioning
branch
from
May 28, 2026 07:54
82c8ea7 to
bcb8ebd
Compare
isaacwallace123
approved these changes
May 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
Summary
project_idon everyWorkloadSpec; now jobs with onlynamespace_idare accepted and routed correctlyuser.namespace.servernameformat so spawned containers are identifiable and scoped across namespaces without collisionKLEFF_NODE_NETWORKconfig to attach all spawned containers to a fixed Docker network alongside the platform APIDiscover()toRuntimeAdapterso the daemon re-adopts existing containers on startup without losing stateServerRepositoryadapter for local daemon state persistenceRelated Issues
Closes #
Changes
What's Included
internal/application/ports/workload.go—NamespaceIDandNamespaceSlugfields onWorkloadSpec; provision validation now accepts namespace-only jobs (noproject_idrequired)internal/application/ports/runtime_adapter.go—Discover()method added toRuntimeAdapterinterfaceinternal/application/ports/server_repository.go—ServerRepositoryinterface (Save,FindByID,UpdateStatus,ListAll)internal/adapters/out/runtime/docker/docker.go—user.namespace.servernamecontainer naming;KLEFF_NODE_NETWORKnetwork attachment on provision; namespace-scoped Docker network management;Discover()implementation for startup re-adoptioninternal/adapters/out/runtime/kubernetes/kubernetes.go— stubDiscover()to satisfy interfaceinternal/adapters/out/repository/sqlite/server_repository.go— SQLite adapter: upsert onSave,FindByID,UpdateStatus,ListAllinternal/app/config/config.go—NodeNetworkfield read fromKLEFF_NODE_NETWORKenv varcmd/kleffd/main.go— wiresNodeNetworkconfig; callsDiscover()on startup to re-adopt existing containerscmd/kleffctl/main.go— updated for port interface changespkg/labels/labels.go+labels_test.go—kleff.io/namespace_idlabel added; label builder updatedinternal/workers/provision_worker.go,start_worker.go,stop_worker.go,restart_worker.go,delete_worker.go— all workers propagateNamespaceID/NamespaceSlugthrough to runtime callsinternal/workers/mocks_test.go— updated mocks for new interfaceinternal/logs/tailer.go,internal/metrics/scraper.go— updated for newWorkloadSpecshapeWhat's Not Included
Testing
How Was This Tested?
kleff-localnetwork; namespace-scoped provision job dispatched via platform API; container confirmed on correct network with name inuser.namespace.servernameformatDiscover()on daemon restart re-adopted a pre-existing container; subsequent stop/delete operations succeededTest Coverage
Breaking Changes
Does this PR introduce breaking changes?
If yes, describe the impact and any required migration steps:
WorkloadSpecgainsNamespaceIDandNamespaceSlugfields — callers that constructWorkloadSpecdirectly must be updated. The platform API already sends these fields as of the companion panel PR.RuntimeAdaptergainsDiscover()— any additional runtime implementations must add this method.Security Considerations
If any box is checked, describe the security impact and any mitigations applied:
Containers are attached to the network named by
KLEFF_NODE_NETWORK. In production this must be a restricted internal overlay network accessible only to the platform API and daemon. For local dev the default iskleff-local. Do not expose this network to untrusted services.Documentation
Does this PR require documentation updates?
If yes, check all that apply:
README.mdARCHITECTURE.md/docsUI/UX (If Applicable)
Screenshots or recordings:
Pre-Merge Checklist
feat:,fix:,chore:,docs:,refactor:,test:)Reviewer Notes