Skip to content

Commit

Permalink
fixmybmc fpga_ver.sh check
Browse files Browse the repository at this point in the history
Summary:
From oncall runbook: https://www.internalfb.com/intern/wiki/FBOSS_Platform/FBOSS_Platform_Oncall_Runbook/#fbar-hostname-audits-min

Simply checks the output of fpga_ver.sh. After D62903380 fpga_ver.sh will `exit 1` if any PIM is not able to be detected.

Test Plan:
```root@fboss311782520-oob:~# fixmybmc
Loaded 4 checks
Running checks...
Running check: fpga_ver_ok
Running check: provisioning_stable_image
Running check: eth0_up
Running check: sshd_running
Result summary:
	Passed: 4
	Problems: 0
	Errors: 0
root@fboss311782520-oob:~# vi /usr/local/bin/fpga_ver.sh
root@fboss311782520-oob:~# fixmybmc
Loaded 4 checks
Running checks...
Running check: fpga_ver_ok
Running check: provisioning_stable_image
Running check: eth0_up
Running check: sshd_running
Result summary:
	Passed: 3
	Problems: 1
	Errors: 0
fpga_ver_ok
	fpga_ver.sh returned error. Check the below output for more details.
	Command: fpga_ver.sh
	stdout:
	DOMFPGA1 is not detected
	DOMFPGA2: 0.56
	Not all DOMFPGA or PIM were detected/inserted. Please review the logs above.... exiting

	Remediation:
	Run `wedge_power.sh reset -s` to powercycle the device then run fixmybmc again and see if it has resolved. If not, send this error to ENS Break/Fix.
```

Reviewed By: alandau

Differential Revision: D63042979

fbshipit-source-id: bfbcda69b0eab0eb4e6ffc6cc859623cbabf8179
  • Loading branch information
Scott8440 authored and facebook-github-bot committed Sep 19, 2024
1 parent e8de4fe commit 3b22667
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Copyright 2015-present Facebook. All rights reserved.

from . import image_version, interface, ssh # noqa: F401
from . import fpga, image_version, interface, ssh # noqa: F401
26 changes: 26 additions & 0 deletions common/recipes-utils/fixmybmc/files/fixmybmc/modules/fpga.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from fixmybmc.bmccheck import bmcCheck
from fixmybmc.status import Problem
from fixmybmc.utils import run_cmd


@bmcCheck
def fpga_ver_ok():
"""
Check if output from fpga_ver.sh is ok
"""
check_cmd = "fpga_ver.sh"

status = run_cmd(check_cmd.split(" "))
if status.returncode == 0:
return None
return Problem(
description=(
"fpga_ver.sh returned error. Check the below output for more details."
),
cmd_status=status,
manual_remediation=(
"Run `wedge_power.sh reset -s` to powercycle the device then run "
"fixmybmc again and see if it has resolved. If not, send this error "
"to ENS Break/Fix."
),
)
27 changes: 20 additions & 7 deletions common/recipes-utils/fixmybmc/files/fixmybmc/status.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# pyre
from subprocess import CompletedProcess
from typing import List


class Status:
Expand Down Expand Up @@ -40,12 +42,8 @@ def info(self):
parts.append(self.exception)
if self.description is not None:
parts.append(self.description)
if self.cmd_status.args:
parts.append(f"Command: {' '.join(self.cmd_status.args)}")
if self.cmd_status.stdout is not None:
parts.append(f"stdout: {self.cmd_status.stdout}")
if self.cmd_status.stderr is not None:
parts.append(f"stderr: {self.cmd_status.stderr}")
if self.cmd_status:
parts += get_cmd_status_text(self.cmd_status)
return "\n".join(parts) or None


Expand All @@ -59,12 +57,14 @@ def __init__(
*,
description=None,
exception=None,
cmd_status=None,
manual_remediation=None,
) -> None:
if description is None and exception is None:
raise TypeError("either description or exception must be provided")
self.description = description
self.exception = exception
self.cmd_status = cmd_status
self.manual_remediation = manual_remediation

@property
Expand All @@ -78,6 +78,19 @@ def info(self):
parts.append(self.description)
if self.exception is not None:
parts.append(f"{self.exception.__class__.__qualname__}: {self.exception}")
if self.cmd_status:
parts += get_cmd_status_text(self.cmd_status)
if self.has_manual_remediation:
parts.append(f"Remediation: {self.manual_remediation}")
parts.append(f"Remediation:\n{self.manual_remediation}")
return "\n".join(parts) or None


def get_cmd_status_text(cmd_status: CompletedProcess) -> List[str]:
parts = []
if cmd_status.args:
parts.append(f"Command: {' '.join(cmd_status.args)}")
if cmd_status.stdout:
parts.append(f"stdout:\n{cmd_status.stdout}")
if cmd_status.stderr:
parts.append(f"stderr:\n {cmd_status.stderr}")
return parts

0 comments on commit 3b22667

Please sign in to comment.