Saturday, December 16, 2017

tape drive over iscsi problems

One of the problem with running a tape drive as an iscsi target is that there was no software I found that worked.  I tried IETD, TGT, and of course TARGETCLI.  After thinking and googling about this problem for about a day or so I decided to see if I could patch the python code on which targetcli runs.  I am suprised I can still code!!! This tool me perhaps half an hour to figure, it has been a long time since i wrote any thing. 

This file is ... rtslib/utils.py

-----------PATCH 1 of 2 --------------------------------------
1. In function convert_scsi_path_to_hctl

OLD:
    try:
        hctl = os.listdir("/sys/block/%s/device/scsi_device"
                          % devname)[0].split(':')
    except:
        return None
    return [int(data) for data in hctl]

NEW:
    try:
       hctl = os.listdir("/sys/block/%s/device/scsi_device"
                             % devname)[0].split(':')
       return [int(data) for data in hctl]
    except OSError: pass

    try:
       hctl = os.listdir("/sys/class/scsi_tape/%s/device/scsi_device"
                          % devname)[0].split(':')
       return [int(data) for data in hctl]
    except OSError: pass

    return None

-----------PATCH 2 of 2 --------------------------------------
In function convert_scsi_hctl_to_path
OLD:
    for devname in os.listdir("/sys/block"):
        path = "/dev/%s" % devname
        hctl = [host, controller, target, lun]
        if convert_scsi_path_to_hctl(path) == hctl:
            return os.path.realpath(path)
NEW:
    for devname in os.listdir("/sys/block"):
        path = "/dev/%s" % devname
        hctl = [host, controller, target, lun]
        if convert_scsi_path_to_hctl(path) == hctl:
            return os.path.realpath(path)
    try:
        for devname in os.listdir("/sys/class/scsi_tape"):
            path = "/dev/%s" % devname
            hctl = [host, controller, target, lun]
            if convert_scsi_path_to_hctl(path) == hctl:
                return os.path.realpath(path)
    except OSError: pass

Friday, December 01, 2017

pgsql archive command notes

This is a critique of documented "archive_command" usage in pgsql.  There is an example which says:

  archive_command = 'test ! -f /destination/%f && cp %p /destination/%f"

I wouldnt use this.  The problem is if the disk is full, I tested cp to produce short files (partial files).  Even if it does exit with a nonzero exit code, the next copy attempt will be seen as a success ("test ! -f __" is false since the file is already there). 
What I would do is use rsync.  In its default setting, it does not create short files:

  archive_command = 'test ! -f /destination/%f && rsync %p /destination/%f"

ep

Creating ipip tunnels in RedHat 8 that is compatible with LVS/TUN. Every few seasons I built a virtual LVS (Linux Virtual Server) mock up ju...