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

Notify user if deployment will not be cancelled when terminating. #875

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

jordanstephens
Copy link
Member

Description

We have been printing a message Detached. The process will keep running if the deployment process was terminated after the tail began, but this left a small window of time (between the deployment request being sent and the tail being initiated) where termination of the process would fail to cancel the deployment and we would not notify the user. This change covers that gap by sharing a cancellable context for both sending the deployment request and the tail.

Linked Issues

Checklist

  • I have performed a self-review of my code
  • I have added appropriate tests
  • I have updated the Defang CLI docs and/or README to reflect my changes, if necessary

go func() {
<-ctx.Done()

if errors.Is(ctx.Err(), context.Canceled) || errors.Is(ctx.Err(), context.DeadlineExceeded) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not enough to exclude the natural cancellation of the context from success :(

defang up
 * Using Defang Playground provider from stored preference
 * Packaging the project files for app at /Users/jordan/wk/samples/samples/nodejs-http/app
 * Uploading the project files for app
 * Monitor your services' status in the defang portal
   - https://portal.defang.dev/service/app
 * Tailing logs for deployment ID qqut567fztmx ; press Ctrl+C to detach:
 * Showing only build logs and runtime errors. Press V to toggle verbose mode.
2024-11-19T15:52:44.499-08:00 cd Update started for stack jordanstephens-prod1
2024-11-19T15:52:48.671-08:00 cd  ** Building image for "app"...
2024-11-19T15:52:51.878-08:00 cd  ** Build succeeded for "app"
2024-11-19T15:52:52.356-08:00 cd  ** Updated service "app" to revision 50
2024-11-19T15:52:56.752-08:00 cd Update succeeded in 12.284256189s ; provisioning...
2024-11-19T15:53:39.389-08:00 app Server running at http://127.0.0.1:3000/
errCompleted
 ! Deployment will not be cancelled.
 * Service app is in state DEPLOYMENT_COMPLETED and will be available at:
   - https://jordanstephens-app--3000.prod1a.defang.dev
 * Done.
For help with warnings, check our FAQ at https://docs.defang.io/docs/faq

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So does that mean this PR is not ready to be merged? I wouldn't want the happy path to show "Deployment will not be cancelled".

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right this PR is not ready to merge. It's still in draft.

Comment on lines -160 to -163
if errors.Is(context.Cause(tailCtx), context.Canceled) {
// Tail was canceled by the user before deployment completion/failure; show a warning and exit with an error
term.Warn("Deployment is not finished. Service(s) might not be running.")
return err
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this removed?

go func() {
<-ctx.Done()

if errors.Is(ctx.Err(), context.Canceled) || errors.Is(ctx.Err(), context.DeadlineExceeded) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So does that mean this PR is not ready to be merged? I wouldn't want the happy path to show "Deployment will not be cancelled".

<-ctx.Done()

if errors.Is(ctx.Err(), context.Canceled) || errors.Is(ctx.Err(), context.DeadlineExceeded) {
term.Warn("Deployment will not be cancelled.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This message could be less curt.

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

Successfully merging this pull request may close these issues.

2 participants