|
|
14f8ab |
From 1ca8a545833e0a6e674984245338b8675ddc58bc Mon Sep 17 00:00:00 2001
|
|
|
14f8ab |
From: Kotresh HR <khiremat@redhat.com>
|
|
|
14f8ab |
Date: Fri, 10 Jan 2020 16:48:14 +0530
|
|
|
14f8ab |
Subject: [PATCH 348/349] glusterfind: Fix py2/py3 issues
|
|
|
14f8ab |
|
|
|
14f8ab |
1. In dictionary values(), returns list in py2 and not in py3.
|
|
|
14f8ab |
So explicitly convert it into list.
|
|
|
14f8ab |
2. xattr module returns values in bytes. So explicitly convert
|
|
|
14f8ab |
them to str to work both with py2 and py3
|
|
|
14f8ab |
|
|
|
14f8ab |
Backport of:
|
|
|
14f8ab |
> Patch: https://review.gluster.org/23993
|
|
|
14f8ab |
> fixes: bz#1789439
|
|
|
14f8ab |
> Change-Id: I27a639cda4f7a4ece9744a97c3d16e247906bd94
|
|
|
14f8ab |
> Signed-off-by: Kotresh HR <khiremat@redhat.com>
|
|
|
14f8ab |
|
|
|
14f8ab |
BUG: 1789447
|
|
|
14f8ab |
Change-Id: I27a639cda4f7a4ece9744a97c3d16e247906bd94
|
|
|
14f8ab |
Signed-off-by: Kotresh HR <khiremat@redhat.com>
|
|
|
14f8ab |
Reviewed-on: https://code.engineering.redhat.com/gerrit/189215
|
|
|
14f8ab |
Reviewed-by: Shwetha Acharya <sacharya@redhat.com>
|
|
|
14f8ab |
Tested-by: RHGS Build Bot <nigelb@redhat.com>
|
|
|
14f8ab |
Reviewed-by: Hari Gowtham Gopal <hgowtham@redhat.com>
|
|
|
14f8ab |
Reviewed-by: Sunny Kumar <sunkumar@redhat.com>
|
|
|
14f8ab |
---
|
|
|
14f8ab |
tools/glusterfind/src/changelog.py | 14 +++++++++-----
|
|
|
14f8ab |
tools/glusterfind/src/main.py | 8 ++++----
|
|
|
14f8ab |
2 files changed, 13 insertions(+), 9 deletions(-)
|
|
|
14f8ab |
|
|
|
14f8ab |
diff --git a/tools/glusterfind/src/changelog.py b/tools/glusterfind/src/changelog.py
|
|
|
14f8ab |
index d8f97e0..d972fb5 100644
|
|
|
14f8ab |
--- a/tools/glusterfind/src/changelog.py
|
|
|
14f8ab |
+++ b/tools/glusterfind/src/changelog.py
|
|
|
14f8ab |
@@ -14,6 +14,7 @@ import sys
|
|
|
14f8ab |
import time
|
|
|
14f8ab |
import xattr
|
|
|
14f8ab |
import logging
|
|
|
14f8ab |
+from gfind_py2py3 import bytearray_to_str
|
|
|
14f8ab |
from argparse import ArgumentParser, RawDescriptionHelpFormatter
|
|
|
14f8ab |
import hashlib
|
|
|
14f8ab |
try:
|
|
|
14f8ab |
@@ -105,9 +106,10 @@ def populate_pgfid_and_inodegfid(brick, changelog_data):
|
|
|
14f8ab |
changelog_data.inodegfid_add(os.stat(p).st_ino, gfid)
|
|
|
14f8ab |
file_xattrs = xattr.list(p)
|
|
|
14f8ab |
for x in file_xattrs:
|
|
|
14f8ab |
- if x.startswith("trusted.pgfid."):
|
|
|
14f8ab |
+ x_str = bytearray_to_str(x)
|
|
|
14f8ab |
+ if x_str.startswith("trusted.pgfid."):
|
|
|
14f8ab |
# PGFID in pgfid table
|
|
|
14f8ab |
- changelog_data.pgfid_add(x.split(".")[-1])
|
|
|
14f8ab |
+ changelog_data.pgfid_add(x_str.split(".")[-1])
|
|
|
14f8ab |
except (IOError, OSError):
|
|
|
14f8ab |
# All OS Errors ignored, since failures will be logged
|
|
|
14f8ab |
# in End. All GFIDs present in gfidpath table
|
|
|
14f8ab |
@@ -122,10 +124,12 @@ def enum_hard_links_using_gfid2path(brick, gfid, args):
|
|
|
14f8ab |
try:
|
|
|
14f8ab |
file_xattrs = xattr.list(p)
|
|
|
14f8ab |
for x in file_xattrs:
|
|
|
14f8ab |
- if x.startswith("trusted.gfid2path."):
|
|
|
14f8ab |
+ x_str = bytearray_to_str(x)
|
|
|
14f8ab |
+ if x_str.startswith("trusted.gfid2path."):
|
|
|
14f8ab |
# get the value for the xattr i.e. <PGFID>/<BN>
|
|
|
14f8ab |
- v = xattr.getxattr(p, x)
|
|
|
14f8ab |
- pgfid, bn = v.split(os.sep)
|
|
|
14f8ab |
+ v = xattr.getxattr(p, x_str)
|
|
|
14f8ab |
+ v_str = bytearray_to_str(v)
|
|
|
14f8ab |
+ pgfid, bn = v_str.split(os.sep)
|
|
|
14f8ab |
try:
|
|
|
14f8ab |
path = symlink_gfid_to_path(brick, pgfid)
|
|
|
14f8ab |
fullpath = os.path.join(path, bn)
|
|
|
14f8ab |
diff --git a/tools/glusterfind/src/main.py b/tools/glusterfind/src/main.py
|
|
|
14f8ab |
index fefe4a3..dfc9d07 100644
|
|
|
14f8ab |
--- a/tools/glusterfind/src/main.py
|
|
|
14f8ab |
+++ b/tools/glusterfind/src/main.py
|
|
|
14f8ab |
@@ -633,7 +633,7 @@ def mode_query(session_dir, args):
|
|
|
14f8ab |
# Merger
|
|
|
14f8ab |
if args.full:
|
|
|
14f8ab |
if len(g_pid_nodefile_map) > 0:
|
|
|
14f8ab |
- cmd = ["sort", "-u"] + g_pid_nodefile_map.values() + \
|
|
|
14f8ab |
+ cmd = ["sort", "-u"] + list(g_pid_nodefile_map.values()) + \
|
|
|
14f8ab |
["-o", args.outfile]
|
|
|
14f8ab |
execute(cmd,
|
|
|
14f8ab |
exit_msg="Failed to merge output files "
|
|
|
14f8ab |
@@ -645,7 +645,7 @@ def mode_query(session_dir, args):
|
|
|
14f8ab |
# Read each Changelogs db and generate finaldb
|
|
|
14f8ab |
create_file(args.outfile, exit_on_err=True, logger=logger)
|
|
|
14f8ab |
outfilemerger = OutputMerger(args.outfile + ".db",
|
|
|
14f8ab |
- g_pid_nodefile_map.values())
|
|
|
14f8ab |
+ list(g_pid_nodefile_map.values()))
|
|
|
14f8ab |
write_output(args.outfile, outfilemerger, args.field_separator)
|
|
|
14f8ab |
|
|
|
14f8ab |
try:
|
|
|
14f8ab |
@@ -702,7 +702,7 @@ def mode_pre(session_dir, args):
|
|
|
14f8ab |
# Merger
|
|
|
14f8ab |
if args.full:
|
|
|
14f8ab |
if len(g_pid_nodefile_map) > 0:
|
|
|
14f8ab |
- cmd = ["sort", "-u"] + g_pid_nodefile_map.values() + \
|
|
|
14f8ab |
+ cmd = ["sort", "-u"] + list(g_pid_nodefile_map.values()) + \
|
|
|
14f8ab |
["-o", args.outfile]
|
|
|
14f8ab |
execute(cmd,
|
|
|
14f8ab |
exit_msg="Failed to merge output files "
|
|
|
14f8ab |
@@ -714,7 +714,7 @@ def mode_pre(session_dir, args):
|
|
|
14f8ab |
# Read each Changelogs db and generate finaldb
|
|
|
14f8ab |
create_file(args.outfile, exit_on_err=True, logger=logger)
|
|
|
14f8ab |
outfilemerger = OutputMerger(args.outfile + ".db",
|
|
|
14f8ab |
- g_pid_nodefile_map.values())
|
|
|
14f8ab |
+ list(g_pid_nodefile_map.values()))
|
|
|
14f8ab |
write_output(args.outfile, outfilemerger, args.field_separator)
|
|
|
14f8ab |
|
|
|
14f8ab |
try:
|
|
|
14f8ab |
--
|
|
|
14f8ab |
1.8.3.1
|
|
|
14f8ab |
|