Skip to content

Commit 21acdd7

Browse files
committed
fix: Remove sourceNamespaces from AppProjects synced to managed agents
Signed-off-by: Mike Ng <[email protected]>
1 parent 591bcce commit 21acdd7

File tree

4 files changed

+12
-15
lines changed

4 files changed

+12
-15
lines changed

docs/user-guide/appprojects.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,9 @@ When an AppProject is sent to an agent, it undergoes transformation to make it a
6464
namespace: "guestbook" # Preserves original namespace restrictions
6565
```
6666

67-
2. **Source Namespaces**: Limited to only the agent's namespace:
67+
2. **Source Namespaces**: Removed completely since they're only used on the control plane for routing
6868

69-
```yaml
70-
sourceNamespaces:
71-
- agent-production # The specific agent namespace
72-
```
69+
The `sourceNamespaces` field is used on the control plane to determine which agents should receive the AppProject. Once the AppProject arrives at the agent cluster, this field is removed as it's no longer needed.
7370

7471
3. **Roles**: Removed since they're not relevant on the workload cluster
7572

@@ -174,7 +171,7 @@ The transformation logic differs significantly between managed and autonomous ag
174171
- **Direction**: AppProject flows from principal to agent
175172
- **Selection**: Uses glob pattern matching on `sourceNamespaces` and `destinations` to determine which agents receive the project
176173
- **Destinations**: Filtered to only include destinations matching the agent, then transformed to `in-cluster`
177-
- **Source Namespaces**: Replaced with the single agent namespace
174+
- **Source Namespaces**: Removed completely since they're only used on the control plane for routing
178175
- **Name**: Remains unchanged
179176

180177
### Autonomous Agents (Agent → Principal)

internal/manager/appproject/appproject.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,8 +482,9 @@ func AgentSpecificAppProject(appProject v1alpha1.AppProject, agent string) v1alp
482482
}
483483
appProject.Spec.Destinations = filteredDst
484484

485-
// Only allow Applications to be managed from the agent namespace
486-
appProject.Spec.SourceNamespaces = []string{agent}
485+
// Remove sourceNamespaces since they are not relevant on the workload cluster
486+
// They are only used on the control plane to determine which agents should receive the AppProject
487+
appProject.Spec.SourceNamespaces = nil
487488

488489
// Remove the roles since they are not relevant on the workload cluster
489490
appProject.Spec.Roles = []v1alpha1.ProjectRole{}

internal/manager/appproject/appproject_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ func TestAgentSpecificAppProject(t *testing.T) {
561561
Server: "https://kubernetes.default.svc",
562562
},
563563
},
564-
SourceNamespaces: []string{"cluster-prod"},
564+
SourceNamespaces: nil,
565565
Roles: []v1alpha1.ProjectRole{},
566566
},
567567
},
@@ -617,7 +617,7 @@ func TestAgentSpecificAppProject(t *testing.T) {
617617
Server: "https://kubernetes.default.svc",
618618
},
619619
},
620-
SourceNamespaces: []string{"prod-cluster-1"},
620+
SourceNamespaces: nil,
621621
Roles: []v1alpha1.ProjectRole{},
622622
},
623623
},
@@ -661,7 +661,7 @@ func TestAgentSpecificAppProject(t *testing.T) {
661661
},
662662
Spec: v1alpha1.AppProjectSpec{
663663
Destinations: []v1alpha1.ApplicationDestination{},
664-
SourceNamespaces: []string{"prod-cluster"},
664+
SourceNamespaces: nil,
665665
Roles: []v1alpha1.ProjectRole{},
666666
},
667667
},
@@ -687,7 +687,7 @@ func TestAgentSpecificAppProject(t *testing.T) {
687687
},
688688
Spec: v1alpha1.AppProjectSpec{
689689
Destinations: []v1alpha1.ApplicationDestination{},
690-
SourceNamespaces: []string{"test-agent"},
690+
SourceNamespaces: nil,
691691
Roles: []v1alpha1.ProjectRole{},
692692
},
693693
},
@@ -724,7 +724,7 @@ func TestAgentSpecificAppProject(t *testing.T) {
724724
Namespace: "default",
725725
},
726726
},
727-
SourceNamespaces: []string{"test-agent"},
727+
SourceNamespaces: nil,
728728
Roles: []v1alpha1.ProjectRole{},
729729
},
730730
},

test/e2e/appproject_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@ func (suite *AppProjectTestSuite) Test_AppProject_Managed() {
7373
requires.Equal("in-cluster", mappProject.Spec.Destinations[0].Name)
7474
requires.Equal("https://kubernetes.default.svc", mappProject.Spec.Destinations[0].Server)
7575

76-
requires.Len(mappProject.Spec.SourceNamespaces, 1)
77-
requires.Equal("agent-managed", mappProject.Spec.SourceNamespaces[0])
76+
requires.Nil(mappProject.Spec.SourceNamespaces)
7877

7978
// Modify the appProject on the principal and ensure the change is propagated
8079
// to the managed-agent

0 commit comments

Comments
 (0)