diff --git a/cmd/incusd/api_cluster.go b/cmd/incusd/api_cluster.go index 465acb3a3e2..9444e0c9754 100644 --- a/cmd/incusd/api_cluster.go +++ b/cmd/incusd/api_cluster.go @@ -623,6 +623,7 @@ func clusterPutJoin(d *Daemon, r *http.Request, req api.ClusterPut) response.Res d.events.SetLocalLocation(d.serverName) + // Create all storage pools and networks. err = clusterInitMember(localClient, client, req.MemberConfig) if err != nil { return fmt.Errorf("Failed to initialize member: %w", err) @@ -765,13 +766,8 @@ func clusterPutJoin(d *Daemon, r *http.Request, req api.ClusterPut) response.Res return err } - // Start clustering tasks. - d.startClusterTasks() - revert.Add(func() { d.stopClusterTasks() }) - - // Handle optional service integration on cluster join + // Add the new node to the default cluster group. err = s.DB.Cluster.Transaction(context.TODO(), func(ctx context.Context, tx *db.ClusterTx) error { - // Add the new node to the default cluster group. err := tx.AddNodeToClusterGroup(ctx, "default", req.ServerName) if err != nil { return fmt.Errorf("Failed to add new member to the default cluster group: %w", err) @@ -783,6 +779,11 @@ func clusterPutJoin(d *Daemon, r *http.Request, req api.ClusterPut) response.Res return err } + // Start clustering tasks. + d.startClusterTasks() + revert.Add(func() { d.stopClusterTasks() }) + + // Load the configuration. var nodeConfig *node.Config err = s.DB.Node.Transaction(context.TODO(), func(ctx context.Context, tx *db.NodeTx) error { var err error @@ -1045,6 +1046,11 @@ func clusterInitMember(d incus.InstanceServer, client incus.InstanceServer, memb continue } + // OVN networks don't need local creation. + if network.Type == "ovn" { + continue + } + post := api.InitNetworksProjectPost{ NetworksPost: api.NetworksPost{ NetworkPut: network.NetworkPut, @@ -2422,13 +2428,13 @@ func internalClusterPostAccept(d *Daemon, r *http.Request) response.Response { d.clusterMembershipMutex.Lock() defer d.clusterMembershipMutex.Unlock() - // Check that the pools and networks provided by the joining node have - // configs that match the cluster ones. + // Make sure we have all the expected storage pools. err = clusterCheckStoragePoolsMatch(r.Context(), s.DB.Cluster, req.StoragePools) if err != nil { return response.SmartError(err) } + // Make sure we have all the expected networks. err = clusterCheckNetworksMatch(r.Context(), s.DB.Cluster, req.Networks) if err != nil { return response.SmartError(err) @@ -2844,8 +2850,18 @@ func clusterCheckNetworksMatch(ctx context.Context, clusterDB *db.Cluster, reqNe } for _, networkName := range networkNames { - found := false + _, network, _, err := tx.GetNetworkInAnyState(ctx, networkProjectName, networkName) + if err != nil { + return err + } + + // OVN networks don't need local creation. + if network.Type == "ovn" { + continue + } + // Check that the network is present locally. + found := false for _, reqNetwork := range reqNetworks { if reqNetwork.Name != networkName || reqNetwork.Project != networkProjectName { continue @@ -2853,11 +2869,6 @@ func clusterCheckNetworksMatch(ctx context.Context, clusterDB *db.Cluster, reqNe found = true - _, network, _, err := tx.GetNetworkInAnyState(ctx, networkProjectName, networkName) - if err != nil { - return err - } - if reqNetwork.Type != network.Type { return fmt.Errorf("Mismatching type for network %q in project %q", networkName, networkProjectName) } diff --git a/internal/server/cluster/membership.go b/internal/server/cluster/membership.go index c3f48ba0037..b1745ecf80a 100644 --- a/internal/server/cluster/membership.go +++ b/internal/server/cluster/membership.go @@ -524,7 +524,8 @@ func Join(state *state.State, gateway *Gateway, networkCert *localtls.CertInfo, for name, id := range network { config, ok := networks[name] if !ok { - return fmt.Errorf("Joining member has no config for network %s", name) + // Not all networks are present as virtual networks (OVN) don't need entries. + continue } err := tx.NetworkNodeJoin(id, node.ID) diff --git a/shared/archive/detect.go b/shared/archive/detect.go index e14b62fcadf..f7768b1ec33 100644 --- a/shared/archive/detect.go +++ b/shared/archive/detect.go @@ -27,7 +27,7 @@ func DetectCompressionFile(f io.Reader) ([]string, string, []string, error) { // bz2 - 2 bytes, 'BZ' signature/magic number // gz - 2 bytes, 0x1f 0x8b // lzma - 6 bytes, { [0x000, 0xE0], '7', 'z', 'X', 'Z', 0x00 } - - // xy - 6 bytes, header format { 0xFD, '7', 'z', 'X', 'Z', 0x00 } + // xz - 6 bytes, header format { 0xFD, '7', 'z', 'X', 'Z', 0x00 } // tar - 263 bytes, trying to get ustar from 257 - 262 header := make([]byte, 263) _, err := f.Read(header)