-
Notifications
You must be signed in to change notification settings - Fork 130
Add a command to restart a deployment #687
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
base: master
Are you sure you want to change the base?
Add a command to restart a deployment #687
Conversation
coffee-cup
left a comment
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.
Sorry for the delay here. This mostly looks good. Would love to merge soon!
| .ok_or_else(|| anyhow!("The service specified doesn't exist in the current environment"))?; | ||
|
|
||
| if let Some(ref latest) = service_in_env.node.latest_deployment { | ||
| if latest.can_redeploy { |
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.
We don't need this check for restarting
| // Wait for healthchecks via latest deployment status | ||
| let max_wait = Duration::from_secs(300); | ||
| let poll_interval = Duration::from_secs(2); | ||
| let start = std::time::Instant::now(); | ||
| loop { | ||
| if start.elapsed() > max_wait { | ||
| spinner.finish_and_clear(); | ||
| bail!("Timed out waiting for health checks after restart"); | ||
| } | ||
|
|
||
| let resp = post_graphql::<queries::LatestDeployment, _>( | ||
| &client, | ||
| configs.get_backboard(), | ||
| queries::latest_deployment::Variables { | ||
| service_id: service.node.id.clone(), | ||
| environment_id: linked_project.environment.clone(), | ||
| }, | ||
| ) | ||
| .await?; | ||
|
|
||
| let si = resp.service_instance; | ||
| if let Some(ld) = si.latest_deployment { | ||
| match ld.status { | ||
| queries::latest_deployment::DeploymentStatus::SUCCESS => { | ||
| spinner.finish_with_message(format!( | ||
| "Restart successful for service {}", | ||
| service.node.name.green() | ||
| )); | ||
| return Ok(()); | ||
| } | ||
| queries::latest_deployment::DeploymentStatus::FAILED | ||
| | queries::latest_deployment::DeploymentStatus::CRASHED => { | ||
| spinner.finish_and_clear(); | ||
| bail!("Restart completed but health checks failed"); | ||
| } | ||
| _ => {} | ||
| } | ||
| } | ||
|
|
||
| tokio::time::sleep(poll_interval).await; | ||
| } | ||
| } |
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.
Is this intended to be here? Deployment restarts don't perform a healthcheck, so this is not relevant
Implements
railway restartwhich restarts a deployment. This has been tested.Resolves #616.
Also resolves
cargo clippyerrors.