Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fs-drift touchup #343

Merged
merged 6 commits into from
Sep 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion snafu/fs_drift_wrapper/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
FROM registry.access.redhat.com/ubi8:latest

RUN dnf install -y --nodocs git python3-pip
RUN dnf install -y --nodocs procps-ng iproute net-tools ethtool nmap iputils
RUN ln -s /usr/bin/python3 /usr/bin/python
COPY . /opt/snafu/
RUN pip3 install -e /opt/snafu/
Expand Down
38 changes: 23 additions & 15 deletions snafu/fs_drift_wrapper/fs_drift_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@

from . import trigger_fs_drift

# this could become common class in snafu/utils later


class SnafuStorageException(Exception):
pass


logger = logging.getLogger("snafu")


Expand All @@ -29,26 +36,27 @@ def __init__(self, parser):
parser.add_argument("-y", "--yaml-input-file", help="fs-drift parameters passed via YAML input file")
self.args = parser.parse_args()

self.server = ""

self.cluster_name = "mycluster"
if "clustername" in os.environ:
self.cluster_name = os.environ["clustername"]

self.uuid = ""
if "uuid" in os.environ:
self.uuid = os.environ["uuid"]

self.user = ""
if "test_user" in os.environ:
self.user = os.environ["test_user"]

if not self.args.top:
raise SnafuSmfException("must supply directory where you access flies") # noqa
raise SnafuStorageException("must supply directory where you access files")
self.cluster_name = os.environ["clustername"] if "clustername" in os.environ else ""
self.uuid = os.environ["uuid"] if "uuid" in os.environ else ""
self.user = os.environ["test_user"] if "test_user" in os.environ else ""
self.samples = self.args.samples
self.working_dir = self.args.top
self.result_dir = self.args.dir
self.yaml_input_file = self.args.yaml_input_file
logger.info(
("cluster_name %s user %s uuid %s samples %d" + "working_dir %s result_dir %s yaml_input_file %s")
% (
self.cluster_name,
self.user,
self.uuid,
self.samples,
self.working_dir,
self.result_dir,
self.yaml_input_file,
)
)

def run(self):
if not os.path.exists(self.result_dir):
Expand Down
6 changes: 5 additions & 1 deletion snafu/fs_drift_wrapper/trigger_fs_drift.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
import subprocess
import time

regex = r"counters.([0-9]{2}).[0-9,\.,\-,a-z,A-Z]*.json" # noqa
from snafu.vfs_stat import get_vfs_stat_dict

regex = r"counters.([0-9]{2}).[0-9,\.,\-,a-z,A-Z]*.json"
counters_regex_prog = re.compile(regex)


Expand Down Expand Up @@ -68,13 +70,15 @@ def emit_actions(self):
self.logger.exception(e)
raise FsDriftWrapperException("fs-drift.py non-zero process return code %d" % e.returncode)
self.logger.info("completed sample {} , results in {}".format(self.sample, json_output_file))
fsdict = get_vfs_stat_dict(self.working_dir)
with open(json_output_file) as f:
data = json.load(f)
params = data["parameters"]
timestamp = data["results"]["date"]
threads = data["results"]["in-thread"]
for tid in threads.keys():
thrd = threads[tid]
thrd["fsdict"] = fsdict
thrd["date"] = timestamp
thrd["thr-id"] = tid
thrd["sample"] = self.sample
Expand Down
6 changes: 5 additions & 1 deletion snafu/smallfile_wrapper/smallfile_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
logger = logging.getLogger("snafu")


class SnafuStorageException(Exception):
pass


class smallfile_wrapper:
def __init__(self, parser):
# collect arguments
Expand Down Expand Up @@ -51,7 +55,7 @@ def __init__(self, parser):
self.redis_timeout_th = os.environ["redis_timeout_th"] if "redis_timeout_th" in os.environ else 200
self.clients = os.environ["clients"] if "clients" in os.environ else 1
if not self.args.top:
raise SnafuSmfException("must supply directory where you access flies") # noqa
raise SnafuStorageException("must supply directory where you access files")
self.samples = self.args.samples
self.working_dir = self.args.top
self.result_dir = self.args.dir
Expand Down