-
-
Notifications
You must be signed in to change notification settings - Fork 766
Add option to disable default all-to-all policy #3970
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
@aliamerj Thanks for your contribution! Could you please take a look at the failing tests? |
1d3a758
to
afb2202
Compare
@bcmmbaga |
afb2202
to
4cf7a10
Compare
I don't know why i am getting the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall but there are a couple of missing pieces needed to make this work as expected
-
We should only add the peer to the
All
group whenDisableDefaultPolicy
is set tofalse
, since the group won't be created when it's enabled.
netbird/management/server/peer.go
Lines 610 to 613 in 684501f
err = transaction.AddPeerToAllGroup(ctx, store.LockingStrengthUpdate, accountID, newPeer.ID) if err != nil { return fmt.Errorf("failed adding peer to All group: %w", err) } -
We should make
DisableDefaultPolicy
configurable viasetup.env
and include appropriate tests. By default it should remainfalse
unless explicitly configured by the user. For reference check how it's handled in this PR
4cf7a10
to
7e6c9c8
Compare
i will work on the setup.env and tests next , |
@bcmmbaga |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new configuration option DisableDefaultPolicy
that stops automatically creating the all-to-all policy/group during account and peer setup when enabled.
- Added
disableDefaultPolicy
flag toDefaultAccountManager
and propagated it throughBuildManager
. - Wrapped default policy creation calls in account and peer logic behind this flag.
- Updated all existing tests and infrastructure files to pass or expose the new flag (default
false
).
Reviewed Changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
management/server/account.go | Added disableDefaultPolicy field, BuildManager parameter, and gated default-group creation in account logic |
management/server/peer.go | Wrapped AddPeerToAllGroup behind disableDefaultPolicy check |
management/server/nameserver_test.go | Updated BuildManager call to include the new flag |
management/server/management_test.go | Updated BuildManager invocation with the new parameter |
management/server/management_proto_test.go | Propagated new flag to BuildManager in tests |
management/server/http/testing/testing_tools/tools.go | Passed false for the new flag in black-box API builder |
management/server/group_test.go | Added the false argument to newAccountWithId calls |
management/server/ephemeral_test.go | Updated newAccountWithId invocation with the flag |
management/server/dns_test.go | Included the new false parameter in account initialization |
management/server/account_test.go | Adjusted newAccountWithId and BuildManager usages |
management/cmd/management.go | Propagated config.DisableDefaultPolicy to BuildManager |
management/client/client_test.go | Updated test setup to pass the new flag |
client/server/server_test.go | Added false for disableDefaultPolicy in BuildManager calls |
client/internal/engine_test.go | Included the new flag parameter in manager startup |
client/cmd/testutil_test.go | Passed false for the new parameter in test helper |
.github/workflows/test-infrastructure-files.yml | Set CI_NETBIRD_MGMT_DISABLE_DEFAULT_POLICY and validated it |
infrastructure_files/{base.setup.env,setup.env.example,...} | Exposed NETBIRD_MGMT_DISABLE_DEFAULT_POLICY in env and templates |
Signed-off-by: aliamerj <aliamer19ali@gmail.com>
86f19ab
to
4672873
Compare
|
@bcmmbaga, |
@@ -1558,6 +1558,10 @@ func (a *Account) AddAllGroup() error { | |||
} | |||
a.Groups = map[string]*Group{allGroup.ID: allGroup} | |||
|
|||
if disableDefaultPolicy { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aliamerj this change should only affect adding the default policy. Nothing else. The add all group should stay as is because the ALL group is used everywhere, and its existence is independent from the default policy. It basically should contain all peers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you please check my comment about the all group?
Thanks for the review! I want to clarify how the implementation handles the "All" group and default policy: In the AddAllGroup function: func (a *Account) AddAllGroup(disableDefaultPolicy bool) error {
if len(a.Groups) == 0 {
// 1. ALWAYS create the "All" group
allGroup := &Group{...}
a.Groups = map[string]*Group{allGroup.ID: allGroup}
// 2. Only conditionally create the policy
if disableDefaultPolicy {
return nil // Skip policy creation
}
// 3. Create default policy (only when not disabled)
defaultPolicy := &Policy{...}
a.Policies = []*Policy{defaultPolicy}
}
return nil
} The "All" group is always created regardless of the disableDefaultPolicy flag Only the policy creation is conditional In account creation paths: // newAccountWithId ALWAYS calls AddAllGroup
func newAccountWithId(..., disableDefaultPolicy bool) *Account {
acc := &Account{...}
acc.AddAllGroup(disableDefaultPolicy) // Always called
return acc
}
// GetOrCreateAccountByPrivateDomain ALWAYS calls AddAllGroup
newAccount.AddAllGroup(am.DisableDefaultPolicy) This ensures:
So I didn't get it , what should i change ? |
Describe your changes
This PR introduces a new configuration option
DisableDefaultPolicy
that prevents the creation of the default all-to-all policy when new accounts are created. This is useful for automation scenarios where explicit policies are preferred.Key Changes:
Testing:
Issue ticket number and link
Closes #3932
Stack
Checklist