Skip to content

Commit 3803738

Browse files
committed
feat: clean up failed clones (#316):
* remove clone with the FATAL status during idleness check * correctly count a number of clones related to snapshot
1 parent 1a178a3 commit 3803738

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Diff for: internal/cloning/base.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ func (c *Base) CreateClone(cloneRequest *types.CloneCreateRequest) (*models.Clon
181181
AvailableDB: cloneRequest.DB.DBName,
182182
}
183183

184+
c.incrementCloneNumber(clone.Snapshot.ID)
185+
184186
go func() {
185187
session, err := c.provision.StartSession(clone.Snapshot.ID, ephemeralUser, cloneRequest.ExtraConf)
186188
if err != nil {
@@ -216,7 +218,6 @@ func (c *Base) fillCloneSession(cloneID string, session *resources.Session) {
216218

217219
w.Session = session
218220
w.TimeStartedAt = time.Now()
219-
c.incrementCloneNumber(w.Clone.Snapshot.ID)
220221

221222
clone := w.Clone
222223
clone.Status = models.Status{
@@ -621,8 +622,11 @@ func (c *Base) isIdleClone(wrapper *CloneWrapper) (bool, error) {
621622

622623
session := wrapper.Session
623624

624-
// TODO(akartasov): Remove wrappers without session.
625625
if session == nil {
626+
if wrapper.Clone.Status.Code == models.StatusFatal {
627+
return true, nil
628+
}
629+
626630
return false, errors.New("failed to get clone session")
627631
}
628632

0 commit comments

Comments
 (0)