Skip to content

Commit

Permalink
microcloud/cmd/microcloud: apply config for when a custom encaps Gene…
Browse files Browse the repository at this point in the history
…ve IP is needed

Signed-off-by: Gabriel Mougard <gabriel.mougard@canonical.com>
  • Loading branch information
gabrielmougard committed Jul 5, 2024
1 parent 0a86133 commit 776a81c
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions cmd/microcloud/main_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,13 +401,21 @@ func AddPeers(sh *service.Handler, systems map[string]InitSystem) error {

// Prepare a JoinConfig to send to each joiner.
joinConfig := make(map[string]types.ServicesPut, len(systems))
membersWithCustomEncapsulationIP := []string{}
for peer, info := range systems {
joinConfig[peer] = types.ServicesPut{
Tokens: []types.ServiceToken{},
Address: info.ServerInfo.Address,
LXDConfig: info.JoinConfig,
CephConfig: info.MicroCephDisks,
}

if info.OVNGeneveAddr != "" {
p := joinConfig[peer]
p.OVNConfig = map[string]string{fmt.Sprintf("%s.ovn-encap-ip", info.ServerInfo.Name): info.OVNGeneveAddr}
membersWithCustomEncapsulationIP = append(membersWithCustomEncapsulationIP, info.ServerInfo.Name)
joinConfig[peer] = p
}
}

_, bootstrap := systems[sh.Name]
Expand Down Expand Up @@ -495,6 +503,22 @@ func AddPeers(sh *service.Handler, systems map[string]InitSystem) error {
}
}

// After all systems have joined and that the database has been updated and
// if some nodes had been configured with custom encapsulation IPs, we can check the members' API extensions
// If they don't have the `custom_encapsulation_ip` extension, output that the supplied custom encapsulation IPs
// were ignored.
if len(membersWithCustomEncapsulationIP) > 0 {
hasFeature, err := sh.Services[types.MicroOVN].(*service.OVNService).HasCustomEncapsulationIpFeature(context.Background())
if err != nil {
return err
}

if !hasFeature {
fmt.Println("Underlay network setup for MicroOVN was not applied because your MicroOVN memmbers do not support custom encapsulation IP for the Geneve tunnel, skipping")
return nil
}
}

return nil
}

Expand Down Expand Up @@ -721,6 +745,20 @@ func setupCluster(s *service.Handler, systems map[string]InitSystem) error {
}
}

if s.Type() == types.MicroOVN {
microOvnBootstrapConf := make(map[string]string)
for _, system := range systems {
// If the system needs to be bootstrapped with a custom ovn encapsulation ip for geneve, add it to the init config.
if system.OVNGeneveAddr != "" {
microOvnBootstrapConf[fmt.Sprintf("%s.ovn-encap-ip", system.ServerInfo.Name)] = system.OVNGeneveAddr
}
}

if len(microOvnBootstrapConf) > 0 {
s.SetConfig(microOvnBootstrapConf)
}
}

// set a 2 minute timeout to bootstrap a service in case the node is slow.
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
defer cancel()
Expand Down

0 comments on commit 776a81c

Please sign in to comment.