Commit 6a192874 authored by Artyom Kartasov's avatar Artyom Kartasov

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 !87
parents f1cb1ee9 3c9a49be
Pipeline #122752385 passed with stages
in 6 minutes and 16 seconds
......@@ -62,6 +62,6 @@ cloning:
# Auto-delete clones after the specified minutes of inactivity.
# 0 - disable automatic deletion.
idleTime: 0
maxIdleMinutes: 120
debug: true
......@@ -112,6 +112,10 @@ func (c *Client) CreateClone(ctx context.Context, cloneRequest types.CloneCreate
return nil, errors.Wrap(err, "failed to watch the clone status")
}
if clone.Status.Code != models.StatusOK {
return nil, errors.Errorf("failed to create clone, unexpected status given: %v", clone.Status.Code)
}
return clone, nil
}
......
......@@ -31,9 +31,9 @@ const (
// Config contains a cloning configuration.
type Config struct {
Mode string `yaml:"mode"`
IdleTime uint `yaml:"idleTime"` // Minutes.
AccessHost string `yaml:"accessHost"`
Mode string `yaml:"mode"`
MaxIdleMinutes uint `yaml:"maxIdleMinutes"`
AccessHost string `yaml:"accessHost"`
}
type cloning struct {
......
......@@ -183,7 +183,7 @@ func (c *baseCloning) CreateClone(cloneRequest *types.CloneCreateRequest) (*mode
clone.Metadata = &models.CloneMetadata{
CloneSize: cloneSize,
CloningTime: w.timeStartedAt.Sub(w.timeCreatedAt).Seconds(),
MaxIdleMinutes: c.Config.IdleTime,
MaxIdleMinutes: c.Config.MaxIdleMinutes,
}
}()
......@@ -481,7 +481,7 @@ func (c *baseCloning) getSnapshotByID(snapshotID string) (models.Snapshot, error
}
func (c *baseCloning) runIdleCheck(ctx context.Context) {
if c.Config.IdleTime == 0 {
if c.Config.MaxIdleMinutes == 0 {
return
}
......@@ -528,7 +528,7 @@ func (c *baseCloning) destroyIdleClones(ctx context.Context) {
func (c *baseCloning) isIdleClone(wrapper *CloneWrapper) (bool, error) {
currentTime := time.Now()
idleDuration := time.Duration(c.Config.IdleTime) * time.Minute
idleDuration := time.Duration(c.Config.MaxIdleMinutes) * time.Minute
availableIdleTime := wrapper.timeStartedAt.Add(idleDuration)
if wrapper.clone.Protected || availableIdleTime.After(currentTime) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment