Skip to content

Conversation

@ryanyuan
Copy link
Contributor

@ryanyuan ryanyuan commented Feb 15, 2019

Add the SSH command logging back to SSHOperator

Make sure you have checked all steps below.

Jira

  • My PR addresses the following Airflow-3896 issues and references them in the PR title.

Description

  • Here are some details about my PR, including screenshots of any UI changes:

Until v1.8.2, the SSHExecuteOperator was able to log the running bash command.

But since v1.9.0, that logging code has been removed from SSHOperator.

Commits

  • My commits all reference Jira issues in their subject lines, and I have squashed multiple commits if they address the same issue. In addition, my commits follow the guidelines from "How to write a good git commit message":
    1. Subject is separated from body by a blank line
    2. Subject is limited to 50 characters (not including Jira issue reference)
    3. Subject does not end with a period
    4. Subject uses the imperative mood ("add", not "adding")
    5. Body wraps at 72 characters
    6. Body explains "what" and "why", not "how"

Code Quality

  • Passes flake8

Add the SSH command logging back to SSHOperator
if self.command.startswith('sudo'):
get_pty = True

self.logger.info("Running command: {0}".format(self.command))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.logger is deprecated in favour of self.log.

Also, with "".format() Python constructs the string beforehand so with logging this form is preferred: self.log.info("Running command: %s", self.command) which constructs a string only when this statement is evaluated.

@codecov-io
Copy link

codecov-io commented Feb 16, 2019

Codecov Report

Merging #4716 into master will increase coverage by <.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4716      +/-   ##
==========================================
+ Coverage   74.65%   74.65%   +<.01%     
==========================================
  Files         430      430              
  Lines       27978    27975       -3     
==========================================
- Hits        20886    20885       -1     
+ Misses       7092     7090       -2
Impacted Files Coverage Δ
airflow/contrib/operators/ssh_operator.py 82.27% <ø> (-1.48%) ⬇️
airflow/operators/bash_operator.py 91.22% <0%> (-1.76%) ⬇️
...rflow/contrib/operators/kubernetes_pod_operator.py 98.66% <0%> (-1.34%) ⬇️
...low/contrib/operators/datastore_import_operator.py 0% <0%> (ø) ⬆️
airflow/operators/http_operator.py 93.54% <0%> (ø) ⬆️
...low/contrib/operators/datastore_export_operator.py 0% <0%> (ø) ⬆️
airflow/contrib/operators/winrm_operator.py 0% <0%> (ø) ⬆️
airflow/operators/docker_operator.py 97.7% <0%> (+0.02%) ⬆️
airflow/models/__init__.py 92.84% <0%> (+0.05%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 72fe43b...37f0673. Read the comment docs.

@feng-tao
Copy link
Member

lgtm

@feng-tao feng-tao merged commit 36b38d8 into apache:master Feb 23, 2019
antonimaciej pushed a commit to PolideaInternal/airflow that referenced this pull request Feb 26, 2019
…e#4716)

* [AIRFLOW-3896] Add running command logging back to SSHOperator

Add the SSH command logging back to SSHOperator

* [AIRFLOW-3896] Add running command logging back to SSHOperator

Change self.logger to self.log
wmorris75 pushed a commit to modmed-external/incubator-airflow that referenced this pull request Jul 29, 2019
…e#4716)

* [AIRFLOW-3896] Add running command logging back to SSHOperator

Add the SSH command logging back to SSHOperator

* [AIRFLOW-3896] Add running command logging back to SSHOperator

Change self.logger to self.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants