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