Changing Config and Shape Safely

Lesson 1 of 4

Apply Config Live

Estimated time: 10 minutes

A config change that needs a restart makes every small fix wait for a risky window, and throws the running state away each time. Hot reload reads the config again while the agent keeps running, which is only safe if the new values are checked before any of them apply.

The order matters more than the mechanism. Read the new values, check each one against its allowed range, apply only the keys that changed, and keep the previous values so a bad change is one step back. A check that runs after the value is live is not a check.

def reload(current, proposed, ranges):
    applied, rejected = {}, {}
    for key, value in proposed.items():
        if value in ranges[key]:
            applied[key] = value
        else:
            rejected[key] = value
    return {**current, **applied}, rejected

Watch the agent on the new values before calling the change done, and keep a separate path that returns to the previous values without a restart.