Skip to content

Commit

Permalink
make missing / empty serial mechanism more robust rockstor#937
Browse files Browse the repository at this point in the history
As we have recently enhanced the _update_disk_state mechanism with
the ability to accurately maintain removed drive info it is necessary
to enhance this flag mechanism that could previously under certain conditions
lead to repeat serial number entries in the db for removed devices. This in turn
could lead to a distortion of info on removed devices.
N.B. the previous UI flag mechanisms are maintained to allow for existing configs
that may have existing removed device info upon upgrade. All future flags will use
the new mechanism.
  • Loading branch information
phillxnet committed Dec 12, 2015
1 parent cfca624 commit ce733be
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions src/rockstor/fs/btrfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from system.exceptions import (CommandException, NonBTRFSRootException)
from pool_scrub import PoolScrub
from django_ztask.decorators import task
import uuid

import logging
logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -845,9 +846,12 @@ def scan_disks(min_size):
dmap['SERIAL'] = get_disk_serial(dmap['NAME'], None)
if (dmap['SERIAL'] == '' or (dmap['SERIAL'] in serials)):
# No serial number still or its a repeat.
# Overwrite drive serial entry with drive name:
# see disks_table.jst for a use of this flag mechanism.
dmap['SERIAL'] = dmap['NAME']
# Overwrite drive serial entry in db with 'fake-serial-' + uuid4
# see disk/disks_table.jst for a use of this flag mechanism.
# Previously we did dmap['SERIAL'] = dmap['NAME'] which is less
# robust as it can itself produce duplicate serial numbers in db
dmap['SERIAL'] = 'fake-serial-' + str(uuid.uuid4())
# 12 chars (fake-serial-) + 36 chars (uuid4) = 48 chars
serials.append(dmap['SERIAL'])
for k in dmap.keys():
if (dmap[k] == ''):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</td>
<td>
<% if (disk.get('serial') == null || disk.get('serial') == '' || disk.get('serial') == disk.get('name')) { %>
<% if (disk.get('serial') == null || disk.get('serial') == '' || disk.get('serial') == disk.get('name') || disk.get('serial').length == 48) { %>
<div class="alert alert-danger">
<h4>Warning! Disk serial number or UUID is not legitimate or unique.</h4>
Disk names may change unfavourably upon reboot leading to inadvertent drive reallocation and potential data loss. This error is caused by the source of these disks such as your Hypervisor or SAN. Please ensure that disks are provided with unique serial numbers before proceeding further
Expand Down

0 comments on commit ce733be

Please sign in to comment.