Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6a19287

Browse filesBrowse files
committed
Merge branch 'fix-creation-clone-and-idle-timeout' into 'master'
fix: return an error on clone creation failing, update the idle timeout parameter See merge request postgres-ai/database-lab!87
2 parents f1cb1ee + 3c9a49b commit 6a19287
Copy full SHA for 6a19287

File tree

4 files changed

+11
-7
lines changed
Filter options

4 files changed

+11
-7
lines changed

‎configs/config.sample.yml

Copy file name to clipboardExpand all lines: configs/config.sample.yml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,6 @@ cloning:
6262

6363
# Auto-delete clones after the specified minutes of inactivity.
6464
# 0 - disable automatic deletion.
65-
idleTime: 0
65+
maxIdleMinutes: 120
6666

6767
debug: true

‎pkg/client/dblabapi/clone.go

Copy file name to clipboardExpand all lines: pkg/client/dblabapi/clone.go
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ func (c *Client) CreateClone(ctx context.Context, cloneRequest types.CloneCreate
112112
return nil, errors.Wrap(err, "failed to watch the clone status")
113113
}
114114

115+
if clone.Status.Code != models.StatusOK {
116+
return nil, errors.Errorf("failed to create clone, unexpected status given: %v", clone.Status.Code)
117+
}
118+
115119
return clone, nil
116120
}
117121

‎pkg/services/cloning/cloning.go

Copy file name to clipboardExpand all lines: pkg/services/cloning/cloning.go
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ const (
3131

3232
// Config contains a cloning configuration.
3333
type Config struct {
34-
Mode string `yaml:"mode"`
35-
IdleTime uint `yaml:"idleTime"` // Minutes.
36-
AccessHost string `yaml:"accessHost"`
34+
Mode string `yaml:"mode"`
35+
MaxIdleMinutes uint `yaml:"maxIdleMinutes"`
36+
AccessHost string `yaml:"accessHost"`
3737
}
3838

3939
type cloning struct {

‎pkg/services/cloning/mode_base.go

Copy file name to clipboardExpand all lines: pkg/services/cloning/mode_base.go
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ func (c *baseCloning) CreateClone(cloneRequest *types.CloneCreateRequest) (*mode
183183
clone.Metadata = &models.CloneMetadata{
184184
CloneSize: cloneSize,
185185
CloningTime: w.timeStartedAt.Sub(w.timeCreatedAt).Seconds(),
186-
MaxIdleMinutes: c.Config.IdleTime,
186+
MaxIdleMinutes: c.Config.MaxIdleMinutes,
187187
}
188188
}()
189189

@@ -481,7 +481,7 @@ func (c *baseCloning) getSnapshotByID(snapshotID string) (models.Snapshot, error
481481
}
482482

483483
func (c *baseCloning) runIdleCheck(ctx context.Context) {
484-
if c.Config.IdleTime == 0 {
484+
if c.Config.MaxIdleMinutes == 0 {
485485
return
486486
}
487487

@@ -528,7 +528,7 @@ func (c *baseCloning) destroyIdleClones(ctx context.Context) {
528528
func (c *baseCloning) isIdleClone(wrapper *CloneWrapper) (bool, error) {
529529
currentTime := time.Now()
530530

531-
idleDuration := time.Duration(c.Config.IdleTime) * time.Minute
531+
idleDuration := time.Duration(c.Config.MaxIdleMinutes) * time.Minute
532532

533533
availableIdleTime := wrapper.timeStartedAt.Add(idleDuration)
534534
if wrapper.clone.Protected || availableIdleTime.After(currentTime) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.