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

Change design of tasks #149

Open
nuwang opened this issue May 21, 2018 · 0 comments
Open

Change design of tasks #149

nuwang opened this issue May 21, 2018 · 0 comments

Comments

@nuwang
Copy link
Member

nuwang commented May 21, 2018

Currently, our tasks are modelled as an enum of simple tasks (e.g. LAUNCH, RESTART, HEALTH_CHECK), and do not have any parameterization, other than initial parameterization when creating a deployment. That is, tasks can return a result (status, result, traceback), but cannot be parameterized with a config. This means that we have a hard time modelling actions like configuration changes, or even tracking what the configuration changes are.

Instead, we could possibly allow tasks to be parameterized by a config, with the deployment tracking the final, most up-to-date config.

e.g.

class DeploymentTaskSerializer(serializers.ModelSerializer):
    celery_id = serializers.CharField(read_only=True)
    action = serializers.CharField() # an arbitrary app defined string
    parameters = serializers.StoredJSONField() # arbitrary parameters for executing tasks
    status = serializers.CharField(read_only=True)
    result = serializers.DictField(read_only=True)
    traceback = serializers.CharField(read_only=True)

When modelled this way, the deployment will only contain a final, cached config reflecting the latest state. Any changes to the config must be done through tasks, and each task records what its parameters are. This gives us the ability to track/audit each configuration change, from LAUNCH to DELETE. (essentially, the command pattern)

In addition, the AppPlugin interface also becomes simpler. It will only contain CRUD methods (no special purpose methods like restart, health_check etc). Performing a restart will be a new task that perform an AppPlugin.update(), parameterised by the task name/config. Appliances can freely implement the update method as they see fit.

Not a priority for now, but something we can implement in future?

@afgane @machristie Thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant