From b6de6bad6c668f16e986e9c9d44613b7a72dff02 Mon Sep 17 00:00:00 2001 From: Serapheim Dimitropoulos Date: Tue, 17 Jan 2023 10:36:49 -0800 Subject: [PATCH] DLPX-84315 Fix savedump test regressions Get rid of depracated actions and fix pylint errors. --- .github/workflows/sync-with-master.yml | 21 ----------------- .github/workflows/sync-with-upstream.yml | 18 -------------- savedump/savedump.py | 30 ++++++++++++------------ 3 files changed, 15 insertions(+), 54 deletions(-) delete mode 100644 .github/workflows/sync-with-master.yml delete mode 100644 .github/workflows/sync-with-upstream.yml diff --git a/.github/workflows/sync-with-master.yml b/.github/workflows/sync-with-master.yml deleted file mode 100644 index a6a7a44..0000000 --- a/.github/workflows/sync-with-master.yml +++ /dev/null @@ -1,21 +0,0 @@ -on: - push: - branches: - - master - schedule: - - cron: '0 0 * * *' - -jobs: - sync: - strategy: - matrix: - branch: - - 6.0/stage - runs-on: ubuntu-18.04 - steps: - - uses: actions/checkout@v2 - - uses: delphix/actions/sync-with-master@master - with: - branch-to-sync: ${{ matrix.branch }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/sync-with-upstream.yml b/.github/workflows/sync-with-upstream.yml deleted file mode 100644 index 6ec3384..0000000 --- a/.github/workflows/sync-with-upstream.yml +++ /dev/null @@ -1,18 +0,0 @@ -on: - schedule: - - cron: '0 * * * *' - -jobs: - sync: - runs-on: ubuntu-18.04 - steps: - - uses: actions/checkout@v2 - with: - token: ${{ secrets.DEVOPS_AUTOMATION_TOKEN }} - - uses: delphix/actions/sync-with-upstream@master - with: - upstream-repository: https://github.com/sdimitro/savedump.git - upstream-branch: master - downstream-branch: master - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/savedump/savedump.py b/savedump/savedump.py index 8943fd4..9cfeee5 100644 --- a/savedump/savedump.py +++ b/savedump/savedump.py @@ -39,18 +39,18 @@ def shell_cmd(cmd_and_args: List[str]) -> Tuple[bool, str]: if not shutil.which(cmd): return False, f"could not find program: {cmd}" - proc = subprocess.Popen(cmd_and_args, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - out, err = proc.communicate() - retcode = proc.wait() - if retcode != 0: - return False, f"{cmd} exited with code: {retcode} - msg: {str(err)}" - if err: - print(f"{cmd} stderr start ---") - print(f"{str(err, 'utf-8')}") - print(f"{cmd} stderr end ---") - return True, str(out, 'utf-8') + with subprocess.Popen(cmd_and_args, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) as proc: + out, err = proc.communicate() + retcode = proc.wait() + if retcode != 0: + return False, f"{cmd} exited with code: {retcode} - msg: {str(err)}" + if err: + print(f"{cmd} stderr start ---") + print(f"{str(err, 'utf-8')}") + print(f"{cmd} stderr end ---") + return True, str(out, 'utf-8') def copy_from_root(src: str, dest: str) -> None: @@ -237,7 +237,7 @@ def archive_kernel_dump(path: str) -> None: # Generate run-sdb.sh. # run_sdb_path = f"{archive_dir}/run-sdb.sh" - with open(run_sdb_path, "w") as sdb_script: + with open(run_sdb_path, "w", encoding="utf-8") as sdb_script: print(RUN_CRASH_SDB_CONTENTS.format(os.path.basename(vmlinux_path), dumpname), file=sdb_script) @@ -247,7 +247,7 @@ def archive_kernel_dump(path: str) -> None: # Generate run-pycrash.sh. # run_pycrash_path = f"{archive_dir}/run-pycrash.sh" - with open(run_pycrash_path, "w") as pycrash_script: + with open(run_pycrash_path, "w", encoding="utf-8") as pycrash_script: print(RUN_PYCRASH_CONTENTS.format(os.path.basename(vmlinux_path), dumpname), file=pycrash_script) @@ -535,7 +535,7 @@ def archive_userland_core_dump(path: str) -> None: # Generate run-gdb.sh. # run_gdb_path = f"{archive_dir}/run-gdb.sh" - with open(run_gdb_path, "w") as gdb_script: + with open(run_gdb_path, "w", encoding="utf-8") as gdb_script: print(RUN_GDB_CONTENTS.format(bin_path, dumpname), file=gdb_script) os.chmod(run_gdb_path, 0o755)