-
Notifications
You must be signed in to change notification settings - Fork 19
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
refactor: start dashmate services depending on status #503
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are the possible values for service_status
other than up
and stopped
? Will the value still be stopped
if we are on the initial run, the dashmate start
command has never run yet and the containers don't exist? Should we add a fallback in case the status command crashes, or should deploy tool just exit in that case?
(core_service_status != 'up' and core_service_status != 'stopped') or | ||
(tenderdash_service_status != 'up' and tenderdash_service_status != 'stopped') | ||
|
||
# start platform when (core is up and platform is down) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we need to restart Core as well? What if dashmate code is updated or config is changed?
We can do restart logic smarter:
- Images are changes: restart core if core image changed and restart platform if platform images are changed
- dashmate config is changed
- dashmate is changed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, yesterday I had difficulty updating from Platform 0.24.2 to 0.24.4 because docker compose restart
does not pull and use newer images, docker compose up -d
is necessary for this. We definitely need a way of ensuring the necessary containers are restarted (or stopped, updated and started) when config changes. But changing the dashmate version probably shouldn't cause core to restart - this usually changes at the same time as the platform version only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
docker compose restart does not pull and use newer images
it's not, that's why we have dashmate update
above
But changing the dashmate version probably shouldn't cause core to restart
We should because docker compose config could be changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about this logic:
- check services status
- core is running
- drive is running
- start ALL when (core is down and platform is down)
- start platform when (core is up and platform is down)
- determine what's need to be restarted:
- any of platform images are updated: platform
- core / sentinel images are updated: all
- dashmate is changed: all
- dashmate config is changed: all
- restart platform (platform is not down and platform needs to be restarted)
- restart all (all needs to be restarted)
- name: Get service status | ||
ansible.builtin.set_fact: | ||
core_service_status: "{{ dashmate_status.stdout | from_json | json_query('core.serviceStatus') }}" | ||
tenderdash_service_status: "{{ dashmate_status.stdout | from_json | json_query('platform.tenderdash.serviceStatus') }}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems we need to get all platform service statuses otherwise it will be inconsistency and conflict with the check in dashmate https://github.com/dashpay/platform/blob/2e984df0302fa94bdf187bd893328ec58f390aa0/packages/dashmate/src/docker/DockerCompose.js#L75
We using this function in start and restart commands I believe
This looks really good, lots of useful changes here. Does it currently depend on a minimum version of dashmate for the restart platform commands to work properly? Or do we need to do a release still? |
No, required things are already included in the last release (v0.24.14). We still could have some idempotency defects in rare cases, but they will be resolved once this dashpay/platform#1181 is done. |
|
||
- name: Get service status | ||
ansible.builtin.set_fact: | ||
core_docker_status: "{{ dashmate_status.stdout | from_json | json_query('core.dockerStatus') }}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if tenderdash is stopped it Drive or DAPI is started?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean? Should I rather check by drive container?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check if one of them started?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm worried that it will add more fragility to the code. We actually don't have them stopped separately from each other. Tenderdash container will be either in not_started
state or running
. If there are any issues happening, it will remain in restarting
, exited
, or any other states, and tasks will be skipped
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What will happen if tenderdash is stopped but any of platform services is running? DAPI for example?
@@ -1,5 +1,5 @@ | |||
{ | |||
"configFormatVersion": "{{ dashmate_version | default('999.0.0') }}", | |||
"configFormatVersion": "{{ dashmate_version | default(dashmate_config_version | default('999.0.0')) }}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you we want to configure this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because when we install from branch, we don't have dashmate_version available and it will back off to 999.0.0
which will break template idempotency. On the first dashmate run, config version will be overwritten with the package default version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. Yes you right. Would it be better to get dashmate version form dashmate itself (dashmate --version
or package.json
) so you won't need to configure it manually. 999.0.0
workaround won't be necessary as well.
|
||
- name: Get service status | ||
ansible.builtin.set_fact: | ||
core_docker_status: "{{ dashmate_status.stdout | from_json | json_query('core.dockerStatus') }}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What will happen if tenderdash is stopped but any of platform services is running? DAPI for example?
It will try to start platform services |
Issue being fixed or feature implemented
Start or restart dashmate services depending on the dashmate status and dashmate update command.
#513
What was done?
How Has This Been Tested?
On devnet
Breaking Changes
None
Checklist:
For repository code-owners and collaborators only