...

Source file src/k8s.io/kubernetes/pkg/volume/rbd/rbd_windows_test.go

Documentation: k8s.io/kubernetes/pkg/volume/rbd

     1  //go:build windows
     2  // +build windows
     3  
     4  /*
     5  Copyright 2022 The Kubernetes Authors.
     6  
     7  Licensed under the Apache License, Version 2.0 (the "License");
     8  you may not use this file except in compliance with the License.
     9  You may obtain a copy of the License at
    10  
    11      http://www.apache.org/licenses/LICENSE-2.0
    12  
    13  Unless required by applicable law or agreed to in writing, software
    14  distributed under the License is distributed on an "AS IS" BASIS,
    15  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    16  See the License for the specific language governing permissions and
    17  limitations under the License.
    18  */
    19  
    20  package rbd
    21  
    22  import (
    23  	"strconv"
    24  
    25  	"k8s.io/mount-utils"
    26  )
    27  
    28  func (fake *fakeDiskManager) AttachDisk(b rbdMounter) (string, error) {
    29  	fake.mutex.Lock()
    30  	defer fake.mutex.Unlock()
    31  
    32  	// Windows expects Disk Numbers. We start with rbdMapIndex 0, referring to the first Disk.
    33  	volIds, err := mount.ListVolumesOnDisk(strconv.Itoa(fake.rbdMapIndex))
    34  	if err != nil {
    35  		return "", err
    36  	}
    37  	fake.rbdDevices[volIds[0]] = true
    38  	devicePath := strconv.Itoa(fake.rbdMapIndex)
    39  	fake.rbdMapIndex++
    40  	return devicePath, nil
    41  }
    42  
    43  func getLoggedSource(devicePath string) (string, error) {
    44  	// Windows mounter is mounting based on the Disk's Unique ID.
    45  	volIds, err := mount.ListVolumesOnDisk(devicePath)
    46  	if err != nil {
    47  		return "", err
    48  	}
    49  	return volIds[0], nil
    50  }
    51  

View as plain text