mirror of
https://github.com/rancher/os.git
synced 2025-08-31 22:32:14 +00:00
Do not use the previous network settings on DigitalOcean
This commit is contained in:
@@ -62,9 +62,16 @@ func CloudInit(cfg *config.CloudConfig) (*config.CloudConfig, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(stateConfig.Rancher.Network.Interfaces) > 0 {
|
if len(stateConfig.Rancher.Network.Interfaces) > 0 {
|
||||||
cfg.Rancher.Network = stateConfig.Rancher.Network
|
// DO also uses static networking, but this IP may change if:
|
||||||
if err := config.Set("rancher.network", stateConfig.Rancher.Network); err != nil {
|
// 1. not using Floating IP
|
||||||
log.Error(err)
|
// 2. creating a droplet with a snapshot, the snapshot cached the previous IP
|
||||||
|
if onlyDigitalOcean(cfg.Rancher.CloudInit.Datasources) {
|
||||||
|
log.Info("Do not use the previous network settings on DigitalOcean")
|
||||||
|
} else {
|
||||||
|
cfg.Rancher.Network = stateConfig.Rancher.Network
|
||||||
|
if err := config.Set("rancher.network", stateConfig.Rancher.Network); err != nil {
|
||||||
|
log.Error(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,3 +120,16 @@ func onlyConfigDrive(datasources []string) bool {
|
|||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func onlyDigitalOcean(datasources []string) bool {
|
||||||
|
if len(datasources) != 1 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
for _, ds := range datasources {
|
||||||
|
parts := strings.SplitN(ds, ":", 2)
|
||||||
|
if parts[0] == "digitalocean" {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user