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

control for loading configurations from settings.yaml before each chaos run #10

Open
venkivijay opened this issue Nov 10, 2022 · 0 comments

Comments

@venkivijay
Copy link

venkivijay commented Nov 10, 2022

I am not sure if there is any standard way for defining configurations that would be used by multiple chaos experiments. For example, the aws chaos extension requires to define aws_region in each experiment. I wanted this value to be dynamic so I defined it in the configuration block of each experiment. Now that the number of experiments is growing, it is getting real difficult to manage this parameter on the experiment level. I came up with a solution by writing a control which would load the configurations defined on the settings.yaml file before each chaos run.

  • Few things to note
    • Variable that is defined on the settings.yaml file will be used by default
    • Variable defined in experiment top level will override the settings.yaml variable
    • Variable passed from the command line argument chaos run --var key=value will override the experiment defined variable
def configure_control(configuration: Configuration = None,
                      secrets: Secrets = None, settings: Settings = None,
                      experiment: Experiment = None):
    """
    Load configuration values from settings file
    Settings value can be overwritten by defining it in the experiment
    Usage: On settings file
        controls:
        global_values:
            provider:
            type: python
            module: custommodule.utils.control
    """
    settings_config = settings['configuration']
    for (setting_key, setting_value) in settings_config.items():
        if (configuration.get(setting_key)):
            logger.info("Using %s:%s from local experiment",setting_key,setting_value)
        else:
            logger.info("Using %s:%s from settings file",setting_key,setting_value)
            configuration[setting_key] = setting_value
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

No branches or pull requests

1 participant