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

Fix for configoptions, remove check for isset() #71089

Merged
merged 10 commits into from
May 21, 2024
Merged

Conversation

kneeyo1
Copy link
Contributor

@kneeyo1 kneeyo1 commented May 17, 2024

We only need check the last_updated_by,

if the option is already unset (removed from db), last_updated_by will be None. All other channels we can write as drift.

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label May 17, 2024
Copy link

codecov bot commented May 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.91%. Comparing base (2cf3c5e) to head (410c6a4).
Report is 4 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #71089   +/-   ##
=======================================
  Coverage   77.91%   77.91%           
=======================================
  Files        6528     6528           
  Lines      290912   290912           
  Branches    50340    50340           
=======================================
  Hits       226654   226654           
+ Misses      58036    58035    -1     
- Partials     6222     6223    +1     
Files Coverage Δ
src/sentry/options/manager.py 97.42% <ø> (ø)

... and 4 files with indirect coverage changes

src/sentry/options/manager.py Outdated Show resolved Hide resolved
Comment on lines 282 to 284
# isset() will pull from local cache, which gets updated with every get() call.
# configoptions is only concerned with removing the option from the db.
elif not options.set_on_db(opt.name):
Copy link
Member

Choose a reason for hiding this comment

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

We could also change isset() so that it behaves correctly. Currently the docstring for isset claims

Check if a key has been set to a value and not inheriting from its default.

Which doesn't match its current behavior. We could have isset compare the value from the store to the option default. If the store value and default are the same, the option is not 'set'.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I originally wanted to do that but serveral other files and methods use issset(), worried I could break their functionality

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The other issue is that if this is what we use to compare options, configoptions would never actually remove options from the DB if the DB value is just the default value.

Copy link
Member

Choose a reason for hiding this comment

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

I originally wanted to do that but serveral other files and methods use issset(), worried I could break their functionality

We could review those callsites and see if their behaviour would change.

The other issue is that if this is what we use to compare options, configoptions would never actually remove options from the DB if the DB value is just the default value.

If the value is set in the store and equal to the default, wouldn't we still be able to check the option's update channel?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Spoke with @markstory and decided that fixing isset() is the better course of action.

Co-authored-by: Mark Story <mark@mark-story.com>

rv = self.invoke(
"-f",
"tests/sentry/runner/commands/unsetsync.yaml",
Copy link
Member

Choose a reason for hiding this comment

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

You could put this yaml file with other test data in fixtures. It could be helpful to have an options directory for this and other test fixture files.

@kneeyo1 kneeyo1 requested a review from markstory May 17, 2024 20:36
@kneeyo1 kneeyo1 changed the title Fix for configoptions to properly pull from db Fix for configoptions, remove check for isset() May 17, 2024
@kneeyo1 kneeyo1 requested a review from markstory May 21, 2024 15:36
Copy link
Member

@markstory markstory 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. Options that were automated and have been removed from the options data will now be removed if the option's last update was through automator. other states that aren't default/disk values will result in drift 👍

@kneeyo1 kneeyo1 merged commit f413f1b into master May 21, 2024
49 checks passed
@kneeyo1 kneeyo1 deleted the fix/configoptions branch May 21, 2024 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants