Skip to content

Commit 5946640

Browse files
committed
disallow undeploy and redeploy if version endpoint is pending deployemnt
1 parent 75ead87 commit 5946640

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

api/api/version_endpoints_api.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,10 @@ func (c *EndpointsController) UpdateEndpoint(r *http.Request, vars map[string]st
205205
return InternalServerError(fmt.Sprintf("Error getting endpoint: %v", err))
206206
}
207207

208+
if endpoint.IsPending() {
209+
return BadRequest(fmt.Sprintf("Version Endpoint %s is still pending and cannot be redeployed", endpointID))
210+
}
211+
208212
newEndpoint, ok := body.(*models.VersionEndpoint)
209213
if !ok {
210214
return BadRequest("Unable to parse body as version endpoint resource")
@@ -313,6 +317,10 @@ func (c *EndpointsController) DeleteEndpoint(r *http.Request, vars map[string]st
313317
return BadRequest(fmt.Sprintf("Version Endpoints %s is still serving traffic. Please route the traffic to another model version first", rawEndpointID))
314318
}
315319

320+
if endpoint.IsPending() {
321+
return BadRequest(fmt.Sprintf("Version Endpoint %s is still pending and cannot be undeployed", rawEndpointID))
322+
}
323+
316324
_, err = c.EndpointsService.UndeployEndpoint(ctx, env, model, version, endpoint)
317325
if err != nil {
318326
return InternalServerError(fmt.Sprintf("Unable to undeploy version endpoint %s: %v", rawEndpointID, err))

api/models/version_endpoint.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ func (ve *VersionEndpoint) IsServing() bool {
133133
return ve.Status == EndpointServing
134134
}
135135

136+
func (ve *VersionEndpoint) IsPending() bool {
137+
return ve.Status == EndpointPending
138+
}
139+
136140
func (ve *VersionEndpoint) IsModelMonitoringEnabled() bool {
137141
if ve.ModelObservability == nil {
138142
return ve.EnableModelObservability

0 commit comments

Comments
 (0)