Skip to content

Commit 6fe326b

Browse files
authored
Merge pull request #1824 from stgraber/main
incusd/networks: Validate configuration on join too
2 parents 7c1b2d3 + 27204c8 commit 6fe326b

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

cmd/incusd/networks.go

+19-10
Original file line numberDiff line numberDiff line change
@@ -797,25 +797,34 @@ func doNetworksCreate(ctx context.Context, s *state.State, n network.Network, cl
797797
revert := revert.New()
798798
defer revert.Fail()
799799

800-
// Don't validate network config during pre-cluster-join phase, as if network has ACLs they won't exist
801-
// in the local database yet. Once cluster join is completed, network will be restarted to give chance for
802-
// ACL firewall config to be applied.
803-
if clientType != clusterRequest.ClientTypeJoiner {
804-
// Validate so that when run on a cluster node the full config (including node specific config)
805-
// is checked.
806-
err := n.Validate(n.Config())
807-
if err != nil {
808-
return err
800+
validateConfig := n.Config()
801+
802+
// Skip the ACLs during validation on cluster join as those aren't yet available in the database.
803+
if clientType == clusterRequest.ClientTypeJoiner {
804+
validateConfig = map[string]string{}
805+
806+
for k, v := range n.Config() {
807+
if k == "security.acls" || strings.HasPrefix(k, "security.acls.") {
808+
continue
809+
}
810+
811+
validateConfig[k] = v
809812
}
810813
}
811814

815+
// Validate so that when run on a cluster node the full config (including node specific config) is checked.
816+
err := n.Validate(validateConfig)
817+
if err != nil {
818+
return err
819+
}
820+
812821
if n.LocalStatus() == api.NetworkStatusCreated {
813822
logger.Debug("Skipping local network create as already created", logger.Ctx{"project": n.Project(), "network": n.Name()})
814823
return nil
815824
}
816825

817826
// Run initial creation setup for the network driver.
818-
err := n.Create(clientType)
827+
err = n.Create(clientType)
819828
if err != nil {
820829
return err
821830
}

0 commit comments

Comments
 (0)