Skip to content

Feature flags: unable to get configuration for non feature flags related configurations #653

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

Closed
ran-isenberg opened this issue Aug 25, 2021 · 5 comments
Assignees
Labels
bug Something isn't working p2

Comments

@ran-isenberg
Copy link
Contributor

In the first draft of the feature, it was possible to use the AppConfigStore class to get a JSOM configuration that included non feature flsgs configuration.
However, when using an envelope parameter to contain the feature flags parts of the configuration, it is impossible to get the full schema back due to an 'if' in the code. I'm unable to use the AppConfigStore and FeatureFlags as a way to combine my regular configuration and feature flags configuration.
I had to extend AppConfigStore with my own store and add a new get_full_configuration function which disregards the envelope parameter.

at AppConfigStore.get_configuration:
try:
# parse result conf as JSON, keep in cache for self.max_age seconds
config = cast(
dict,
self._conf_store.get(
name=self.name,
transform=TRANSFORM_TYPE,
max_age=self.cache_seconds,
),
)

        if self.envelope:
            config = jmespath_utils.extract_data_from_envelope(
                data=config, envelope=self.envelope, jmespath_options=self.jmespath_options
            )

        return config

This will always return the feature flags conf and wont allow me to use the other conf.
my conf looks like this:
{
'log_level': 'DEBUG',
'features': {
'my_fake_feature': {
'default': True
}
}

and i init AppConfigStore with envelope="features"
I want to be able to use the feature flags and also get back the entire json file which contains log_level. I then use Pydantic to parse only the log_level out of the json (it "throws" aways the features part).

There are two options:
Add an optional boolean to the get_configuration function which will cause it to disregard the envelope param (have it set to False by deault) or add a new function for getting "full" configuration.
What do you think?

@ran-isenberg ran-isenberg added bug Something isn't working triage Pending triage from maintainers labels Aug 25, 2021
@gwlester
Copy link
Contributor

Work around:
Create two configurations:

  1. features
  2. MyOtherConfigurationInfomation

Works great, that is what we do.

@ran-isenberg
Copy link
Contributor Author

ran-isenberg commented Oct 1, 2021

yeah, but it's an extra conf to deploy and then use an extra conf store instead of one. It's an easy fix.
That also means twice the runtime (2 polls) and extra cost.

@heitorlessa
Copy link
Contributor

heitorlessa commented Oct 1, 2021 via email

@heitorlessa heitorlessa self-assigned this Oct 1, 2021
@heitorlessa heitorlessa removed the triage Pending triage from maintainers label Oct 1, 2021
@heitorlessa
Copy link
Contributor

Pending final tests and merging shortly - this will be available in the next release (as early next week as I can)

UX for accessing the raw configuration fetched by the Store

from aws_lambda_powertools.utilities.feature_flags import FeatureFlags, AppConfigStore

app_config = AppConfigStore(
    environment="dev",
    application="product-catalogue",
    name="configuration",
    envelope = "feature_flags"
)

feature_flags = FeatureFlags(store=app_config)

config = app_config.get_raw_configuration

@heitorlessa heitorlessa added the pending-release Fix or implementation already in dev waiting to be released label Oct 1, 2021
@heitorlessa
Copy link
Contributor

This is now available as part of 1.21.0 - Thanks for flagging this Ran so we could do better ;)

https://github.com/awslabs/aws-lambda-powertools-python/releases/tag/v1.21.0

@heitorlessa heitorlessa removed the pending-release Fix or implementation already in dev waiting to be released label Oct 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working p2
Projects
None yet
Development

No branches or pull requests

3 participants