-
Notifications
You must be signed in to change notification settings - Fork 654
Give better feedback on synchronous zipdeploy #2641
Give better feedback on synchronous zipdeploy #2641
Conversation
@nickwalkmsft can you review this change to zip push deploy? |
response.Content = new StringContent("Succeeded"); | ||
break; | ||
case FetchDeploymentRequestResult.RanSynchronouslyFailed: | ||
response.StatusCode = HttpStatusCode.OK; |
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.
Seems like this should be BadRequest or something similar?
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.
Along with error text?
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 changed FetchDeploymentRequestResult
to include a StatusText and renamed the enum. Don't know if you approve of the pattern, let me know. Changed to BadRequest, agree it's better.
@@ -118,6 +118,7 @@ public class FetchHandler : HttpTaskAsyncHandler | |||
context.ApplicationInstance.CompleteRequest(); | |||
break; | |||
case FetchDeploymentRequestResult.RanSynchronously: | |||
case FetchDeploymentRequestResult.RanSynchronouslyFailed: |
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.
This is actually the reason I left the feature in question out of Zipdeploy - because synchronous fetch deployment didn't do it. I didn't just want to add it and change the expected behavior, and it made more sense (to me, at the time) to keep the behavior the same between fetch and zip/push, so I did. @davidebbo what's your take on 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.
So is the /api/zip behavior today that if something goes wrong on the server, the request doesn't fail? If so, that doesn't seem good, and I wouldn't make push zip behave the same way (ideally we'd fix both).
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 changed fetch to act the same way as push on RanSynchronously, but I'm not 100% sure of the consequences here so feedback is appreciated. Tests seems to run fine at least 💯
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.
Not /api/zip, but /deploy (fetch deployment), which zipdeploy has the most in common with (a zip deployment just pushes the zip to the server and then does a "fetch" deployment with a custom fetch action that unzips the local file and sets the deployment source to the extract directory).
In DeploymentManager.Build(), the call to builder.Build() (which does most of the actual work of the deployment) is wrapped in a try/catch that doesn't rethrow. See https://github.com/projectkudu/kudu/blob/master/Kudu.Core/Deployment/DeploymentManager.cs#L651-L675. Everything further up the call stack relies on exceptions and doesn't actually check the status, so the caller gets a 200 back if an exception occurs there, even though the deployment failed. It's always been this way.
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.
Ah I see. I guess the reason is that in those scenarios, the http call normally comes from GitHub/BitBucket, and the error is less relevant. Instead, the deployment status shows it. But for Zip, I can see how not having an error becomes more quirky.
Okey doke - overall I think this is a good idea and would like to merge it. Could you make a couple of revisions? I am adding a couple comments now. Thanks for the contrib! |
context.Response.StatusCode = (int)HttpStatusCode.Conflict; | ||
context.Response.Write(Resources.Error_DeploymentInProgress); | ||
context.ApplicationInstance.CompleteRequest(); | ||
break; | ||
case FetchDeploymentRequestResult.RanSynchronously: | ||
case FetchDeploymentRequestResultStatus.RanSynchronously: |
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.
This new behavior is good for PushDeploymentController since it's new and likely to be used interactively, but here for FetchHandler, please put this bit back how it was (have RanSynchronously fall through to the default case), and have RanSynchronouslyFailed fall through to the default case as well. I'm hesitant to change the behavior here, since this is generally called by webhooks from many different CI services and I don't want to break expectations related to how they react to the response. A short comment to acknowledge the RanSynchronouslyFailed case and explaining that we're avoiding a behavior change would be good also.
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.
Reverted to default case
response.StatusCode = HttpStatusCode.OK; | ||
break; | ||
case FetchDeploymentRequestResult.ConflictDeploymentInProgress: | ||
case FetchDeploymentRequestResultStatus.RanSynchronouslyFailed: | ||
response.StatusCode = HttpStatusCode.BadRequest; |
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 misspoke on this earlier; it should probably be a 500 instead of a 400.
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.
Fixed
} | ||
|
||
await PerformDeployment(deployInfo); | ||
return FetchDeploymentRequestResult.RanSynchronously; | ||
var result = _deploymentManager.GetResults().FirstOrDefault(); |
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.
GetResults() is not a good idea here (it hits the filesystem to enumerate all the existing results, does locking stuff, and has the side effect of purging old deployment records, none of which I want to incur here) but unfortunately there's no other option the way things are factored now.
DeploymentManager.DeployAsync() currently doesn't return anything. Given the functionality it would make sense to return the DeployResult, and in turn that could be returned up through PerformDeployment() and checked here. Please give that a go; if it's not looking great let me know and I'll take a swing at it or something similar.
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.
Now using GetResult(id)
to return the DeployResult from DeployAsync
. Does that solve the lockingissues?
@@ -274,6 +274,8 @@ public void Delete(string id) | |||
{ | |||
throw new DeploymentFailedException(exception); | |||
} | |||
|
|||
return GetResult(id); |
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 safe?
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, I'll get to this soon...
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.
Bump! Don't wanna nag, but thought I'd remind you about this in case it's been forgotten ⏳
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.
Thanks @nikolaia, have been working on other priorities but will get to this as soon as I can, it's still on my radar.
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.
Any updates here? :)
de572eb
to
f32d0f0
Compare
when isAsync=true,could return the deploy id ? |
I'm gonna close this. Ended up just using the Azure CLI to deploy. (Example: https://github.com/nikolaia/weather-in-harstad/blob/master/provision.fsx#L82) |
As mentioned in #2630 it would be nice to know if the deployment succeeded or failed when running a synchronous zipdeploy