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