Skip to content

Commit

Permalink
Revert ssh2-python submodule
Browse files Browse the repository at this point in the history
This change reverts those introduced to add submodule-based inclusion of
the ssh2-python dependency.
Additionally, I added a attempt to reconnect to dead sessions (when
servers reboot).
  • Loading branch information
JacobCallahan committed Mar 12, 2024
1 parent d1599b7 commit 8485942
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 17 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
Expand All @@ -50,7 +48,6 @@ jobs:
- name: Unit Tests
env:
BROKER_DIRECTORY: "${{ github.workspace }}/broker_dir"
PWD: "${{ github.workspace }}"
run: |
pip install uv
uv venv
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,12 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Setup and Build
env:
PWD: "${{ github.workspace }}"
run: |
pip install uv
uv venv
Expand Down
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

7 changes: 3 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
FROM fedora
MAINTAINER https://github.com/SatelliteQE

ENV PWD /root/broker

RUN dnf -y install make cmake gcc-c++ zlib-devel \
openssl-devel git python3-pip python3-devel which\
&& dnf clean all


WORKDIR $PWD
COPY . $PWD
WORKDIR /root/broker
COPY . /root/broker

RUN pip install uv
RUN uv venv && source .venv/bin/activate
RUN uv pip install -e .

ENTRYPOINT ["broker"]
Expand Down
10 changes: 9 additions & 1 deletion broker/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

try:
from ssh2 import sftp as ssh2_sftp
from ssh2.exceptions import SocketSendError
from ssh2.session import Session as ssh2_Session

SFTP_MODE = (
Expand Down Expand Up @@ -160,7 +161,14 @@ def _read(channel):
def run(self, command, timeout=0):
"""Run a command on the host and return the results."""
self.session.set_timeout(helpers.translate_timeout(timeout))
channel = self.session.open_session()
try:
channel = self.session.open_session()
except SocketSendError as err:
logger.warning(
f"Encountered connection issue. Attempting to reconnect and retry.\n{err}"
)
del self._session
channel = self.session.open_session()
channel.execute(
command,
)
Expand Down
1 change: 0 additions & 1 deletion broker/vendored/ssh2-python
Submodule ssh2-python deleted from abbbf8
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ dependencies = [
"packaging",
"pyyaml",
"setuptools",
"ssh2-python @ file://${PWD}/broker/vendored/ssh2-python",
"ssh2-python@git+https://github.com/jacobcallahan/ssh2-python.git",
]
dynamic = ["version"] # dynamic fields to update on build - version via setuptools_scm

Expand Down Expand Up @@ -152,6 +152,7 @@ ignore = [
"D213", # Multi-line docstring summary should start at the second line
"D406", # Section name should end with a newline
"D407", # Section name underlining
"D413", # Missing blank line after last section
"E501", # line too long
"E731", # do not assign a lambda expression, use a def
"PLR0913", # Too many arguments to function call ({c_args} > {max_args})
Expand Down

0 comments on commit 8485942

Please sign in to comment.