Skip to content

Conversation

@jonavellecuerdo
Copy link
Contributor

@jonavellecuerdo jonavellecuerdo commented Sep 20, 2023

What does this PR do?

A few sentences describing the overall goals of the pull request's commits.
Why are we making these changes? Is there more work to be done to fully
achieve these goals?

How can a reviewer manually see the effects of these changes?

For IN-923 Raise exceptions for failed connection tests:

  1. Check the CloudWatch for successful connection tests: log
    • To produce this log, I ran the Docker image with the code as-is, which should run successfully as it uses the appropriate credentials and does not include a forced ZeroDivisionError.
image
  1. Check the CloudWatch log for failed connection test for Data Warehouse (tests lines 114-117 of database.py):
    • To produce this log, I created a temporary Docker image where I added 1 / 0 after line 113 of carbon.database.DatabaseEngine.run_connection_test() to force a raised exception: log
image
  1. Check the CloudWatch log for failed connection test for Symplectic Elements FTP server (tests lines 242-247 of app.py):
    • To produce this log, I created a temporary Docker image where I added 1 / 0 after line 241 of carbon.app.DatabaseToFtpPipe.run_connection_test() to force a raised exception: log
image

For IN-925 Add Makefile commands for running 'people' and 'articles' feed as an ECS task:

Check 'people' feed run:

  1. Check the CloudWatch log for successful 'people' feed run: log
    • Note: You may see an error message (shown below), but if you check the Elements FTP server, you should see that an XML file still gets uploaded.
  2. See screenshot below showing that HRDataFeed.xml is uploaded to the Elements FTP server (with today's date 9/20):
    image

Check 'articles' feed run:

  1. Check the CloudWatch log for successful 'articles' feed run: log

  2. See screenshot below showing that AA_articles.xml is uploaded to the Elements FTP server (with today's date 9/20):
    image

Note: If you are interested in accessing the Elements FTP server, please refer to the instructions in this Confluence document: Carbon | Developer Guide | How to access files uploaded to the Elements FTP server.


Includes new or updated dependencies?

NO

Developer

  • README is updated to reflect all changes as needed
  • All related Jira tickets are linked in commit message(s)

Code Reviewer

  • The commit message is clear and follows our guidelines
    (not just this pull request message)
  • There are appropriate tests covering any new functionality
  • The documentation has been updated to reflect all changes or is not needed
  • The changes have been verified
  • New dependencies are appropriate or there were no changes

Why these changes are being introduced:
* Raising exceptions for any failed connection tests stops the application
from proceeding with the workflow once a connection test fails.
This logic makes sense as the (1) a successful connection to the Data Warehouse
is required for any Carbon run and (2) a successful connection
to the Elements FTP server is required for any run Carbon run that involves FTP.

How this addresses that need:
* Exceptions are raised in the connection test functions of
carbon.database.DatabaseEngine and
carbon.app.DatabaseToFtpPipe.
* CLI tests for failed connection tests are properly configured.

Side effects of this change:
* None

Relevant ticket(s):
* https://mitlibraries.atlassian.net/browse/IN-923
@jonavellecuerdo jonavellecuerdo self-assigned this Sep 20, 2023
@jonavellecuerdo jonavellecuerdo changed the title IN-923 Raise exceptions for failed connection tests IN-923 Raise exceptions for failed connection tests / IN-925 Add Makefile commands to run Carbon feeds Sep 20, 2023
Why these changes are being introduced:
* Provide an easy way to execute runs of the 'people' and 'articles'
feed as an ECS task.

How this addresses that need:
* Add Makefile commands to run 'people' and 'articles' feed

Side effects of this change:
* None

Relevant ticket(s):
* https://mitlibraries.atlassian.net/browse/IN-925
@jonavellecuerdo jonavellecuerdo marked this pull request as ready for review September 20, 2023 19:07
@ghukill
Copy link
Contributor

ghukill commented Sep 21, 2023

Just a couple quick comments as I'm working through the PR:

  1. It'd be helpful to know that your "How can a reviewer manually see the effects of these changes?" section does not require running it per say, but just looking at pre-existing logs.
  2. It'd be helpful to know which environment (e.g. stage) this occurs in! AWS links are often the same across environments, it was only the log group name that indicated it was stage and not dev1.

I was able to quickly piece these together, and can totally see how lost in the shuffle of PR-ing, but just a comment on the PR process of helping the reviewer along for the ride.

That said, the direct cloudwatch log links are helpful, and could see the results.

I think it may come down to a matter of preference, but if the "How can a reviewer manually see the effects..." section is not actually running code, but just observing the output of something somewhat complex to setup, I might propose a 1) link to the lines of code that are getting tested, and 2) screenshot or log snippet of the output. This would avoid the 2 week window and could make the PR process a bit easier. But again, just a thought, and this works as-is.

UPDATE: ...much like you did for the 2nd part of the PR! At a glance, can see from the screenshots that XML files exist. And, with the excellent confluence documentation, can go look at the files myself if needed.

Copy link
Contributor

@ghukill ghukill left a comment

Choose a reason for hiding this comment

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

Looks good to me!

I left a PR process comment in the PR, that is unrelated from the actual code changes.

I wasn't sure if this was the place to address it, so filed an issue, but I do wonder if the FTP upload error, accompanying a successful upload, may be some kind of hanging file handler and/or open connection? Given the timeout, it feels like it could be something like that.

f"Failed to connect to the Symplectic Elements FTP server: {error}"
)
logger.exception(error_message)
raise
Copy link
Contributor

Choose a reason for hiding this comment

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

+1 - think it's good that application bails given a connection error, as it cannot really do its work without it

except Exception as error:
error_message = f"Failed to connect to the Data Warehouse: {error}"
logger.exception(error_message)
raise
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here.

Comment on lines +191 to +197
def test_cli_database_connection_test_fails(caplog, nonfunctional_engine, runner):
with patch("carbon.cli.DatabaseEngine") as mocked_engine:
mocked_engine.return_value = nonfunctional_engine
result = runner.invoke(main, ["--run_connection_tests"])
assert result.exit_code == 1

assert "Failed to connect to the Data Warehouse" in caplog.text
Copy link
Contributor

Choose a reason for hiding this comment

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

To me, this is a nice test. The fixture nonfunctional_engine is clearly worded, indicating that it's doomed from the get-go, and the test confirms it.

@jonavellecuerdo
Copy link
Contributor Author

@ghukill I updated the description on the PR above to address your comments (for future reference)! I appreciate your feedback. Regarding the 'non-errors', thank you for looking into it. I will take your thoughts into consideration for the next story which will focus on resolving this issue: [IN-924 Investigate error with custom method for running FTP file transfer](Investigate error with custom method for running FTP file transfer).

@ghukill ghukill self-requested a review September 21, 2023 14:31
Copy link
Contributor

@ghukill ghukill left a comment

Choose a reason for hiding this comment

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

Looks good! Thanks for the PR updates.

@jonavellecuerdo jonavellecuerdo merged commit b639b20 into main Sep 21, 2023
@jonavellecuerdo jonavellecuerdo deleted the IN-923-925-raise-exceptions-and-add-make-commands branch September 21, 2023 14:36
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.

2 participants