Skip to content

Commit

Permalink
DBG
Browse files Browse the repository at this point in the history
  • Loading branch information
mvollmer committed Aug 28, 2024
1 parent 37ba9ce commit 498470c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 6 deletions.
15 changes: 10 additions & 5 deletions pkg/storaged/btrfs/btrfs-tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@

TMP_MP_DIR = "/var/lib/cockpit/btrfs"

def debug(msg):
subprocess.check_call(["logger", msg])

def ensure_tmp_mp_dir():
os.makedirs(TMP_MP_DIR, mode=0o700, exist_ok=True)

Expand Down Expand Up @@ -67,7 +70,7 @@ def add_tmp_mountpoint(fs, dev, opt_repair):
global tmp_mountpoints
uuid = fs['uuid']
if uuid not in tmp_mountpoints:
# sys.stderr.write(f"ADDING {uuid}\n")
debug(f"ADDING {uuid}")
tmp_mountpoints.add(uuid)
ensure_tmp_mp_dir()
with atomic_file(TMP_MP_DIR + "/db") as db:
Expand All @@ -77,24 +80,25 @@ def add_tmp_mountpoint(fs, dev, opt_repair):
db[uuid] = 1
if not fs['has_tmp_mountpoint'] and (db[uuid] == 1 or opt_repair):
dir = TMP_MP_DIR + "/" + uuid
# sys.stderr.write(f"MOUNTING {dir}\n")
debug(f"MOUNTING {dir}")
os.makedirs(dir, exist_ok=True)
subprocess.check_call(["mount", dev, dir])

def remove_tmp_mountpoint(uuid):
global tmp_mountpoints
if uuid in tmp_mountpoints:
# sys.stderr.write(f"REMOVING {uuid}\n")
debug(f"REMOVING {uuid}")
tmp_mountpoints.remove(uuid)
ensure_tmp_mp_dir()
with atomic_file(TMP_MP_DIR + "/db") as db:
if db[uuid] == 1:
dir = TMP_MP_DIR + "/" + uuid
try:
# sys.stderr.write(f"UNMOUNTING {dir}\n")
debug(f"UNMOUNTING {dir}")
subprocess.check_call(["umount", dir])
subprocess.check_call(["rmdir", dir])
except Exception:
debug(f"UNMOUNTING ERROR")
# XXX - log error, try harder?
pass

Check warning

Code scanning / CodeQL

Unnecessary pass Warning

Unnecessary 'pass' statement.
del db[uuid]
Expand Down Expand Up @@ -153,7 +157,7 @@ def get_usages(uuid):
return usages;

def poll(opt_mount, opt_repair):
# sys.stderr.write("POLL\n")
debug(f"POLL mount {opt_mount} repair {opt_repair}")
filesystems = list_filesystems()
info = { }
for fs in filesystems.values():
Expand Down Expand Up @@ -188,6 +192,7 @@ def cmd_poll(opt_mount):
sys.stdout.flush()

def cmd_do(uuid, cmd):
debug(f"DO {uuid} {cmd}")
filesystems = list_filesystems()
for fs in filesystems.values():
if fs['uuid'] == uuid:
Expand Down
2 changes: 1 addition & 1 deletion test/run
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ RUN_OPTS=""
ALL_TESTS="$(test/common/run-tests --test-dir test/verify -l)"

RE_NETWORKING='Networking|Bonding|Connection|TestBridge|WireGuard|Firewall|Team|IPA|AD|Kerberos'
RE_STORAGE='Storage'
RE_STORAGE='TestStorageAnaconda.testBtrfs'
RE_EXPENSIVE='HostSwitching|MultiMachine|Updates|Superuser|Kdump|Pages'

# every known case needs to set RUN_OPTS to something non-empty, so that we can check if we hit any branch
Expand Down
21 changes: 21 additions & 0 deletions test/verify/check-storage-anaconda
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,27 @@ class TestStorageAnaconda(storagelib.StorageCase):
}
})

def testBtrfs2(self):
self.testBtrfs()

def testBtrfs3(self):
self.testBtrfs()

def testBtrfs4(self):
self.testBtrfs()

def testBtrfs5(self):
self.testBtrfs()

def testBtrfs6(self):
self.testBtrfs()

def testBtrfs7(self):
self.testBtrfs()

def testBtrfs8(self):
self.testBtrfs()

def testBiosboot(self):
b = self.browser

Expand Down

0 comments on commit 498470c

Please sign in to comment.