Lorenz Brun | 3705012 | 2021-03-30 14:00:27 +0200 | [diff] [blame] | 1 | Copyright 2020 The Monogon Project Authors. |
| 2 | |
| 3 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | you may not use this file except in compliance with the License. |
| 5 | You may obtain a copy of the License at |
| 6 | |
| 7 | http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | |
| 9 | Unless required by applicable law or agreed to in writing, software |
| 10 | distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | See the License for the specific language governing permissions and |
| 13 | limitations under the License. |
| 14 | |
| 15 | |
| 16 | From f0c9fc613c15e30453295beb25bf73763a4a82df Mon Sep 17 00:00:00 2001 |
| 17 | From: Lorenz Brun <lorenz@brun.one> |
| 18 | Date: Mon, 29 Mar 2021 13:56:06 +0200 |
| 19 | Subject: [PATCH] Removed questionable block device pseudo-locks |
| 20 | |
| 21 | This code implements a weird sort of lock using Linux loop devices. It's not exclusive (multiple loop devices per |
| 22 | backing device are supported) and the devices themselves are not accessed. The lock is also not exclusive as multiple |
| 23 | loop devices per backing device are allowed. The only mention of why any of this is done is in the comment below, stating |
| 24 | that it is possible that a device can be removed and another device can be attached with the same name. In Metropolis |
| 25 | this is not a problem as our CSI/Provisioner setup exercises tight control over devices, thus silent removals are not |
| 26 | possible. |
| 27 | |
| 28 | Because this code calls the losetup utility which Metropolis doesn't want to ship and also repeatedly lists loop devices |
| 29 | in an inefficient manner which will cause problems with the anticipated density of VM-hosting Metropolis nodes and |
| 30 | does nothing for us, let's just nuke it instead of rewriting it against //metropolis/pkg/loop. |
| 31 | --- |
| 32 | pkg/volume/util/util.go | 18 ------------------ |
| 33 | 1 file changed, 18 deletions(-) |
| 34 | |
| 35 | diff --git a/pkg/volume/util/util.go b/pkg/volume/util/util.go |
| 36 | index 367e05a0d1a..f53f1dcbb4e 100644 |
| 37 | --- a/pkg/volume/util/util.go |
| 38 | +++ b/pkg/volume/util/util.go |
| 39 | @@ -527,17 +527,6 @@ func MapBlockVolume( |
| 40 | return fmt.Errorf("blkUtil.MapDevice failed. devicePath: %s, podVolumeMapPath:%s, volumeMapName: %s, bindMount: %v: %v", |
| 41 | devicePath, podVolumeMapPath, volumeMapName, false, mapErr) |
| 42 | } |
| 43 | - |
| 44 | - // Take file descriptor lock to keep a block device opened. Otherwise, there is a case |
| 45 | - // that the block device is silently removed and attached another device with the same name. |
| 46 | - // Container runtime can't handle this problem. To avoid unexpected condition fd lock |
| 47 | - // for the block device is required. |
| 48 | - _, mapErr = blkUtil.AttachFileDevice(filepath.Join(globalMapPath, string(podUID))) |
| 49 | - if mapErr != nil { |
| 50 | - return fmt.Errorf("blkUtil.AttachFileDevice failed. globalMapPath:%s, podUID: %s: %v", |
| 51 | - globalMapPath, string(podUID), mapErr) |
| 52 | - } |
| 53 | - |
| 54 | return nil |
| 55 | } |
| 56 | |
| 57 | @@ -551,13 +540,6 @@ func UnmapBlockVolume( |
| 58 | volumeMapName string, |
| 59 | podUID utypes.UID, |
| 60 | ) error { |
| 61 | - // Release file descriptor lock. |
| 62 | - err := blkUtil.DetachFileDevice(filepath.Join(globalUnmapPath, string(podUID))) |
| 63 | - if err != nil { |
| 64 | - return fmt.Errorf("blkUtil.DetachFileDevice failed. globalUnmapPath:%s, podUID: %s: %v", |
| 65 | - globalUnmapPath, string(podUID), err) |
| 66 | - } |
| 67 | - |
| 68 | // unmap devicePath from pod volume path |
| 69 | unmapDeviceErr := blkUtil.UnmapDevice(podDeviceUnmapPath, volumeMapName, false /* bindMount */) |
| 70 | if unmapDeviceErr != nil { |
| 71 | -- |
| 72 | 2.25.1 |
| 73 | |