Skip to content

Commit 6d0106a

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

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-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: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package models
1616

1717
import (
18+
"fmt"
1819
"net/url"
1920
"time"
2021

@@ -133,6 +134,11 @@ func (ve *VersionEndpoint) IsServing() bool {
133134
return ve.Status == EndpointServing
134135
}
135136

137+
func (ve *VersionEndpoint) IsPending() bool {
138+
fmt.Println("status of the version endpoint is", ve.Status)
139+
return ve.Status == EndpointPending
140+
}
141+
136142
func (ve *VersionEndpoint) IsModelMonitoringEnabled() bool {
137143
if ve.ModelObservability == nil {
138144
return ve.EnableModelObservability

0 commit comments

Comments
 (0)