Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: log multiple errors #14064

Merged
merged 4 commits into from
Mar 9, 2022

Conversation

eschutho
Copy link
Member

SUMMARY

The database create command can have multiple errors, but when they are logged, we only see the DatabaseInvalidError. This change passes all of the errors to the logger

TEST PLAN

unit test added

ADDITIONAL INFORMATION

  • Has associated issue:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@codecov
Copy link

codecov bot commented Apr 10, 2021

Codecov Report

Merging #14064 (910fa8b) into master (7e336d1) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #14064   +/-   ##
=======================================
  Coverage   66.40%   66.40%           
=======================================
  Files        1641     1641           
  Lines       63518    63520    +2     
  Branches     6422     6422           
=======================================
+ Hits        42176    42181    +5     
+ Misses      19681    19678    -3     
  Partials     1661     1661           
Flag Coverage Δ
hive 52.60% <50.00%> (-0.01%) ⬇️
mysql 81.84% <100.00%> (+0.01%) ⬆️
postgres 81.89% <100.00%> (+0.01%) ⬆️
presto 52.44% <50.00%> (-0.01%) ⬇️
python 82.33% <100.00%> (+0.01%) ⬆️
sqlite 81.64% <100.00%> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
superset/databases/commands/create.py 92.15% <ø> (+3.92%) ⬆️
superset/commands/exceptions.py 92.98% <100.00%> (+0.25%) ⬆️
superset/initialization/__init__.py 90.72% <0.00%> (ø)
superset/users/schemas.py
superset/users/api.py
superset/views/users/schemas.py 100.00% <0.00%> (ø)
superset/views/users/api.py 100.00% <0.00%> (ø)
superset/databases/commands/exceptions.py 96.00% <0.00%> (+2.00%) ⬆️

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 7e336d1...910fa8b. Read the comment docs.

@amitmiran137 amitmiran137 changed the title log multiple errors chore: log multiple errors Apr 11, 2021
action=f"db_connection_failed.{exception.__class__.__name__}"
action="db_connection_failed.{}.{}".format(
exception.__class__.__name__,
".".join(exception.get_list_classnames()),
Copy link
Member

Choose a reason for hiding this comment

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

Should we sort the list of class names, so that the exceptions with the same classes get grouped together?

Copy link
Member Author

Choose a reason for hiding this comment

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

sounds good.. is it more or less helpful to see both errors if they are identical? How about filtering out duplicates?

Copy link
Member

Choose a reason for hiding this comment

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

I think filtering duplicates make sense.

Suggested change
".".join(exception.get_list_classnames()),
".".join(sorted(exception.get_list_classnames())),

Copy link
Member Author

Choose a reason for hiding this comment

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

if we filter out duplicates, do we still need to sort?

Copy link
Member Author

Choose a reason for hiding this comment

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

Per discussion, I added the sort to the get_list_classnames method above.

@eschutho eschutho closed this Apr 16, 2021
@eschutho eschutho deleted the elizabeth/log-multiple-db-errors branch April 16, 2021 23:54
@eschutho eschutho restored the elizabeth/log-multiple-db-errors branch April 17, 2021 00:55
@eschutho eschutho reopened this Apr 17, 2021
Comment on lines 49 to 73
def get_list_classnames(self) -> List[str]:
return list(
dict.fromkeys([ex.__class__.__name__ for ex in self._invalid_exceptions])
)

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
def get_list_classnames(self) -> List[str]:
return list(
dict.fromkeys([ex.__class__.__name__ for ex in self._invalid_exceptions])
)
def get_list_classnames(self) -> List[str]:
return list(set(ex.__class__.__name__ for ex in self._invalid_exceptions))

Copy link
Member Author

Choose a reason for hiding this comment

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

will a set preserve ordering?

action=f"db_connection_failed.{exception.__class__.__name__}"
action="db_connection_failed.{}.{}".format(
exception.__class__.__name__,
".".join(exception.get_list_classnames()),
Copy link
Member

Choose a reason for hiding this comment

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

I think filtering duplicates make sense.

Suggested change
".".join(exception.get_list_classnames()),
".".join(sorted(exception.get_list_classnames())),

@eschutho eschutho closed this May 10, 2021
@eschutho eschutho deleted the elizabeth/log-multiple-db-errors branch May 10, 2021 15:57
@eschutho eschutho restored the elizabeth/log-multiple-db-errors branch May 10, 2021 15:57
@eschutho eschutho deleted the elizabeth/log-multiple-db-errors branch July 19, 2021 18:55
@eschutho eschutho restored the elizabeth/log-multiple-db-errors branch August 24, 2021 17:40
@eschutho eschutho reopened this Aug 24, 2021
@eschutho eschutho force-pushed the elizabeth/log-multiple-db-errors branch 2 times, most recently from bd41db0 to d5c6329 Compare September 23, 2021 21:29
@eschutho eschutho force-pushed the elizabeth/log-multiple-db-errors branch from d5c6329 to 1d29e9f Compare March 1, 2022 23:07
Copy link
Member

@betodealmeida betodealmeida left a comment

Choose a reason for hiding this comment

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

This PR was about to celebrate its first birthday! :)

@eschutho
Copy link
Member Author

eschutho commented Mar 1, 2022

This PR was about to celebrate its first birthday! :)

Oh my goodness.. haha. :)

@eschutho eschutho merged commit c143b37 into apache:master Mar 9, 2022
villebro pushed a commit that referenced this pull request Apr 3, 2022
* log all errors from db create

* return unique set of errors

* sort set for exceptions list

* run black

(cherry picked from commit c143b37)
@mistercrunch mistercrunch added 🍒 1.5.2 🍒 1.5.3 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 2.0.0 labels Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels lts-v1 preset-io size/M 🍒 1.5.0 🍒 1.5.1 🍒 1.5.2 🍒 1.5.3 🚢 2.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants