Skip to content

Commit ee0ba30

Browse files
Merge pull request openshift#7145 from hamzy/PowerVS-MULTIARCH-3492
OCPBUGS-14077: MULTIARCH-3492: Avoid conflicting subnets
2 parents 976e277 + c47f0d0 commit ee0ba30

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

pkg/types/defaults/installconfig.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,6 @@ func SetInstallConfigDefaults(c *types.InstallConfig) {
4242
{CIDR: *libvirtdefaults.DefaultMachineCIDR},
4343
}
4444
}
45-
if c.Platform.PowerVS != nil {
46-
c.Networking.MachineNetwork = []types.MachineNetworkEntry{
47-
{CIDR: *powervsdefaults.DefaultMachineCIDR},
48-
}
49-
}
5045
}
5146
if c.Networking.NetworkType == "" {
5247
c.Networking.NetworkType = defaultNetworkType
@@ -122,6 +117,9 @@ func SetInstallConfigDefaults(c *types.InstallConfig) {
122117
}
123118
case c.Platform.PowerVS != nil:
124119
powervsdefaults.SetPlatformDefaults(c.Platform.PowerVS)
120+
c.Networking.MachineNetwork = []types.MachineNetworkEntry{
121+
{CIDR: *powervsdefaults.DefaultMachineCIDR},
122+
}
125123
case c.Platform.None != nil:
126124
nonedefaults.SetPlatformDefaults(c.Platform.None)
127125
case c.Platform.Nutanix != nil:

pkg/types/powervs/defaults/platform.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package defaults
22

33
import (
4+
"crypto/rand"
5+
"fmt"
6+
"math/big"
7+
48
"github.com/openshift/installer/pkg/ipnet"
59
"github.com/openshift/installer/pkg/types/powervs"
610
)
@@ -13,4 +17,11 @@ var (
1317

1418
// SetPlatformDefaults sets the defaults for the platform.
1519
func SetPlatformDefaults(p *powervs.Platform) {
20+
n, err := rand.Int(rand.Reader, big.NewInt(253))
21+
if err != nil {
22+
panic(err)
23+
}
24+
subnet := n.Int64()
25+
// MustParseCIDR parses a CIDR from its string representation. If the parse fails, the function will panic.
26+
DefaultMachineCIDR = ipnet.MustParseCIDR(fmt.Sprintf("192.168.%d.0/24", subnet))
1627
}

0 commit comments

Comments
 (0)