Skip to content
This repository has been archived by the owner on Mar 28, 2023. It is now read-only.

YUPANA-42 - transform bios UUID field to omit invalid value #350

Merged

Conversation

kgaikwad
Copy link
Contributor

@kgaikwad kgaikwad commented Jun 14, 2021

@kgaikwad kgaikwad requested a review from apuntamb June 14, 2021 11:46
@kgaikwad kgaikwad force-pushed the YUPANA-42-drop_invalid_bios_uuid branch 2 times, most recently from 0919c19 to 0cf69fa Compare June 14, 2021 12:04
@codecov-commenter
Copy link

codecov-commenter commented Jun 14, 2021

Codecov Report

Merging #350 (0cf69fa) into master (f7bece3) will increase coverage by 0.06%.
The diff coverage is 100.00%.

❗ Current head 0cf69fa differs from pull request most recent head 67e80c8. Consider uploading reports for the commit 67e80c8 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master     #350      +/-   ##
==========================================
+ Coverage   94.07%   94.13%   +0.06%     
==========================================
  Files          20       20              
  Lines        1434     1450      +16     
  Branches      166      168       +2     
==========================================
+ Hits         1349     1365      +16     
  Misses         60       60              
  Partials       25       25              
Impacted Files Coverage Δ
yupana/processor/report_slice_processor.py 94.98% <100.00%> (+0.33%) ⬆️

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 f7bece3...67e80c8. Read the comment docs.

except ValueError:
return False

return str(uuid_obj) == uuid

Choose a reason for hiding this comment

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

I think this can filter out uppercase-lowercase differences in the string:

00000000-AAAA-AAAA-0000-000000000000 is valid, but not equal to 00000000-aaaa-aaaa-0000-000000000000

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @ShimShtein for review. Fixed it and added test case.

@kgaikwad kgaikwad force-pushed the YUPANA-42-drop_invalid_bios_uuid branch from 0cf69fa to 7130191 Compare June 16, 2021 14:35
@ShimShtein
Copy link

ACK from me, not tested though

Copy link
Contributor

@apuntamb apuntamb left a comment

Choose a reason for hiding this comment

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

LGTM!

@kgaikwad kgaikwad force-pushed the YUPANA-42-drop_invalid_bios_uuid branch from 7130191 to 67e80c8 Compare June 17, 2021 08:27
@kgaikwad kgaikwad force-pushed the YUPANA-42-drop_invalid_bios_uuid branch from 67e80c8 to bae8fa4 Compare June 29, 2021 10:19
@apuntamb apuntamb merged commit 944e4fa into quipucords:master Jul 5, 2021
@apuntamb
Copy link
Contributor

apuntamb commented Jul 5, 2021

Merged, thanks @kgaikwad !!

"""Remove invalid bios UUID."""
uuid = host.get('bios_uuid')
if not isinstance(uuid, str):
return host
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hello @ShimShtein,
Here I am returning host object when value is not a string type.
For testing, QE tried passing values of type None/boolean/number to bios_uuid field, it will return host as it is which results into host rejection from inventory service.
What do you think - do I need to handle above scenarios & omit this field?

Choose a reason for hiding this comment

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

For completeness sake you are correct. I am quite sure that in production we won't have values that are not strings here, but we can never know.
I suppose we can be more specific and short circuit only if the field is not present at all, something like

if uuid is None
  return host

Everything else should fall into the next if not self.is_valid_uuid: statement

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fix in separate pull-request - #359
Adding you and @apuntamb into loop for review.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants