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

Feature flag to make inventory reports sysadmin only. (PP-1329) #1898

Merged
merged 8 commits into from
Jun 12, 2024

Conversation

tdilauro
Copy link
Contributor

@tdilauro tdilauro commented Jun 12, 2024

Description

  • Adds an Admin UI feature flag to restrict inventory reports to sysadmins (default: true = restrict)
  • Adds a settings mechanism that can selectively restrict override from the environment.

Motivation and Context

Need ability to restrict inventory report requests from non-sysadmins until we've been able to test that functionality.

There were two things I was trying to accomplish:

  • Have one home for configuration of feature flags; and
  • Avoid accidentally overriding configuration that we have decided is fixed (see the hard-coded values I pulled back into the feature flags object).

Being able to prevent override by the environment variables preserves the existing behavior of those pre-existing feature flags (i.e., they could not be overridden by the environment -- they were fixed).

I believe the main use case for this is to avoid accidentally reconfiguring some functionality that we have decided is now 'fixed' into the system. I think should mostly apply only to functionality that is in transition. That said, we haven't gone back to the admin UI and removed these fixed feature flags. I'm not sure if that's because we want them there or because we just haven't done anything about them.

I made a separate class for this primarily to make updates to the feature flags a little clearer and less cluttered.

[Jira PP-1329]

How Has This Been Tested?

  • Manually tested locally via API requests.
  • All tests pass locally.
  • CI tests pass.

Checklist

  • N/A - I have updated the documentation accordingly.
  • All new and existing tests passed.

@tdilauro tdilauro requested a review from jonathangreen June 12, 2024 13:33
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure that this is the best place for this, but it cannot go in the same file with ServiceConfiguration because of an import loop due to LoggerMixin.

Copy link

codecov bot commented Jun 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.15%. Comparing base (3b27a67) to head (6626f10).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1898      +/-   ##
==========================================
+ Coverage   90.13%   90.15%   +0.01%     
==========================================
  Files         323      325       +2     
  Lines       39629    39692      +63     
  Branches     8630     8644      +14     
==========================================
+ Hits        35720    35784      +64     
  Misses       2602     2602              
+ Partials     1307     1306       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@jonathangreen jonathangreen left a comment

Choose a reason for hiding this comment

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

Added a couple minor comments, but the code here looks good to me.

One question I have though, reading though this is what is the use case for flags that we can't override with environment variables? Why not just use ServiceConfiguration and allow enable_auto_list and show_circ_events_download to be overridden if desired?

# We always have local_analytics
show_circ_events_download = True
# # We always have local_analytics
# show_circ_events_download = True
Copy link
Member

Choose a reason for hiding this comment

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

Minor: Should be able to remove this comment.

Copy link
Contributor Author

@tdilauro tdilauro Jun 12, 2024

Choose a reason for hiding this comment

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

There were two things I was trying to accomplish:

  • Have one home for configuration of feature flags; and
  • Avoid accidentally overriding configuration that we have decided is fixed (see the hard-coded values I pulled back into the feature flags object).

Being able to prevent override by the environment variables preserves the existing behavior of those pre-existing feature flags (i.e., they could not be overridden by the environment -- they were fixed).

I believe the main use case for this is to avoid accidentally reconfiguring some functionality that we have decided is now 'fixed' into the system. I think should mostly apply only to functionality that is in transition. That said, we haven't gone back to the admin UI and removed these fixed feature flags. I'm not sure if that's because we want them there or because we just haven't done anything about them.

I made a separate class for this primarily to make updates to the feature flags a little clearer and less cluttered.

Copy link
Member

Choose a reason for hiding this comment

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

I'm fine with this going in as is, so feel free either way.

My opinion on this though is that we should allow the feature flags to be overridden by env vars and any of the flags we want to be set as fixed, we can put in tickets to remove the flag and clean up the config in the admin ui and CM.

from palace.manager.util.log import LoggerMixin


class ServiceConfigurationWithLimitedEnvOverride(ServiceConfiguration, LoggerMixin):
Copy link
Member

Choose a reason for hiding this comment

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

Would it make sense for this to live in palace.manager.service.configuration with the parent ServiceConfiguration class. Rather then in palace.manager.util.settings?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah. Probably. I wasn't entirely sure where to put it, but that makes sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Though, as I noted above, it cannot live in the same file:

Not sure that this is the best place for this, but it cannot go in the same file with ServiceConfiguration because of an import loop due to LoggerMixin.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe we could move palace.manager.service.configuration.ServiceConfiguration to palace.manager.service.configuration.base.ServiceConfiguration and put this in the palace.manager.service.configuration package. We can just leave it where it is for now as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jonathangreen I didn't see this before I moved them. I put both of them in palace.manager.service.configuration package directory. I can move them, though, if you'd prefer.

Copy link
Member

Choose a reason for hiding this comment

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

No whats here looks good to me.

@tdilauro tdilauro merged commit d0c6e21 into main Jun 12, 2024
20 checks passed
@tdilauro tdilauro deleted the feature/flag-inv-reports-sysadmin-only branch June 12, 2024 16:47
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