@@ -59,7 +59,10 @@ func platformBasedDisksNames(platform string) []string {
5959 case VspherePlatform :
6060 // vSphere data disks are added sequentially to the SCSI controller starting
6161 // at unit 1 (unit 0 is the boot disk), so /dev/sd[b-e] mapping is stable
62- // for simple configurations without extra SCSI controllers.
62+ // for simple configurations without extra SCSI controllers. These names are
63+ // used only by tests that do not boot new nodes via Ignition. The scale-up
64+ // test ([PolarionID:84219]) discovers stable /dev/disk/by-path/ entries at
65+ // runtime via discoverVSphereSCSIByPathDisks instead.
6366 return []string {
6467 "/dev/sdb" ,
6568 "/dev/sdc" ,
@@ -96,6 +99,28 @@ func discoverNVMeByPathDisks(node *Node) []string {
9699 return paths
97100}
98101
102+ // discoverVSphereSCSIByPathDisks discovers the /dev/disk/by-path/ entries for
103+ // non-boot SCSI data disks on a vSphere node. The SCSI unit number is
104+ // deterministic (data disks start at unit 1), but the PCI address prefix
105+ // depends on the VM hardware version and cannot be hardcoded. This function
106+ // reads it from a live probe node that already has data disks attached.
107+ // Disks that have partitions (i.e. the boot disk) are excluded.
108+ func discoverVSphereSCSIByPathDisks (node * Node ) []string {
109+ script := `for p in /dev/disk/by-path/*scsi*; do [[ $p == *part* ]] && continue; ls ${p}-part* &>/dev/null && continue; echo "$p"; done | sort`
110+ stdout , _ , err := node .DebugNodeWithChrootStd ("bash" , "-c" , script )
111+ o .ExpectWithOffset (1 , err ).NotTo (o .HaveOccurred (), "Failed to discover SCSI by-path disks on node %s" , node .GetName ())
112+
113+ var paths []string
114+ for _ , line := range strings .Split (strings .TrimSpace (stdout ), "\n " ) {
115+ line = strings .TrimSpace (line )
116+ if line != "" {
117+ paths = append (paths , line )
118+ }
119+ }
120+ logger .Infof ("Discovered %d non-boot SCSI by-path disks on node %s: %v" , len (paths ), node .GetName (), paths )
121+ return paths
122+ }
123+
99124var _ = g .Describe ("[sig-mco][Suite:openshift/machine-config-operator/disruptive][Disruptive][OCPFeatureGate:IrreconcilableMachineConfig][Serial]" , g .Ordered , func () {
100125 defer g .GinkgoRecover ()
101126
@@ -204,12 +229,13 @@ var _ = g.Describe("[sig-mco][Suite:openshift/machine-config-operator/disruptive
204229 err = platformBasedDisksPatch (platform , newMS )
205230 o .Expect (err ).NotTo (o .HaveOccurred ())
206231
207- // On AWS, NVMe device enumeration is non-deterministic. Scale up a probe
208- // node first to discover the stable /dev/disk/by-path/ entries, then use
209- // those paths in the MachineConfig so Ignition can reliably find the disks.
232+ // On AWS and vSphere, device paths are non-deterministic or depend on the
233+ // VM hardware version. Scale up a probe node first to discover the stable
234+ // /dev/disk/by-path/ entries, then use those paths in the MachineConfig
235+ // so Ignition can reliably find the disks.
210236 disks := platformBasedDisksNames (platform )
211237 var probeNode * Node
212- if platform == AWSPlatform {
238+ if platform == AWSPlatform || platform == VspherePlatform {
213239 exutil .By ("Step 2.5: Scale up probe node to discover disk paths" )
214240 o .Expect (newMS .ScaleTo (1 )).To (o .Succeed ())
215241 o .Expect (newMS .WaitUntilReady ("10m" )).To (o .Succeed ())
@@ -219,8 +245,16 @@ var _ = g.Describe("[sig-mco][Suite:openshift/machine-config-operator/disruptive
219245 probeNode = probeNodes [0 ]
220246 logger .Infof ("Probe node is: %s" , probeNode .GetName ())
221247
222- discoveredDisks := discoverNVMeByPathDisks (probeNode )
223- o .Expect (discoveredDisks ).To (o .HaveLen (2 ), "Expected exactly 2 non-boot NVMe disks on probe node %s" , probeNode .GetName ())
248+ var discoveredDisks []string
249+
250+ if platform == AWSPlatform {
251+ discoveredDisks := discoverNVMeByPathDisks (probeNode )
252+ o .Expect (discoveredDisks ).To (o .HaveLen (2 ), "Expected exactly 2 non-boot NVMe disks on probe node %s" , probeNode .GetName ())
253+ } else {
254+ discoveredDisks := discoverVSphereSCSIByPathDisks (probeNode )
255+ o .Expect (discoveredDisks ).To (o .HaveLen (2 ), "Expected exactly 2 non-boot SCSI disks on probe node %s" , probeNode .GetName ())
256+ }
257+
224258 disks = discoveredDisks
225259 }
226260
@@ -255,7 +289,7 @@ var _ = g.Describe("[sig-mco][Suite:openshift/machine-config-operator/disruptive
255289
256290 exutil .By ("Step 5: Scale up test node with MC applied via Ignition" )
257291 var testNode * Node
258- if platform == AWSPlatform {
292+ if platform == AWSPlatform || platform == VspherePlatform {
259293 o .Expect (newMS .ScaleTo (2 )).To (o .Succeed ())
260294 o .Expect (newMS .WaitUntilReady ("10m" )).To (o .Succeed ())
261295
0 commit comments