Make NewDeployment specialization timeout configurable (#1260)
* Add specializationtimeout flag to function create/update * Set specialization timeout of 120 seconds if not present * Add default newdeploy timeout for rest of the test cases * Comment out specialization timeout in validations for compatibility * Add warning if specializationtimeout is lower than default value
This commit is contained in:
committed by
Ta-Ching Chen
parent
88b5343775
commit
80910562b3
@@ -38,14 +38,16 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
DeploymentKind = "Deployment"
|
||||
DeploymentVersion = "extensions/v1beta1"
|
||||
DeploymentKind = "Deployment"
|
||||
DeploymentVersion = "extensions/v1beta1"
|
||||
DEFAULT_SPECIALIZATION_TIMEOUT = 120
|
||||
)
|
||||
|
||||
func (deploy *NewDeploy) createOrGetDeployment(fn *fv1.Function, env *fv1.Environment,
|
||||
deployName string, deployLabels map[string]string, deployNamespace string, firstcreate bool) (*v1beta1.Deployment, error) {
|
||||
|
||||
minScale := int32(fn.Spec.InvokeStrategy.ExecutionStrategy.MinScale)
|
||||
specializationTimeout := int(fn.Spec.InvokeStrategy.ExecutionStrategy.SpecializationTimeout)
|
||||
|
||||
// If it's not the first time creation and minscale is 0 means that all pods for function were recycled,
|
||||
// in such cases we need set minscale to 1 for router to serve requests.
|
||||
@@ -65,7 +67,7 @@ func (deploy *NewDeploy) createOrGetDeployment(fn *fv1.Function, env *fv1.Enviro
|
||||
}
|
||||
|
||||
if existingDepl.Status.AvailableReplicas < minScale {
|
||||
existingDepl, err = deploy.waitForDeploy(existingDepl, minScale)
|
||||
existingDepl, err = deploy.waitForDeploy(existingDepl, minScale, specializationTimeout)
|
||||
}
|
||||
}
|
||||
return existingDepl, err
|
||||
@@ -93,7 +95,7 @@ func (deploy *NewDeploy) createOrGetDeployment(fn *fv1.Function, env *fv1.Enviro
|
||||
}
|
||||
|
||||
if waitForDeploy {
|
||||
depl, err = deploy.waitForDeploy(depl, minScale)
|
||||
depl, err = deploy.waitForDeploy(depl, minScale, specializationTimeout)
|
||||
}
|
||||
|
||||
return depl, err
|
||||
@@ -414,8 +416,13 @@ func (deploy *NewDeploy) deleteSvc(ns string, name string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (deploy *NewDeploy) waitForDeploy(depl *v1beta1.Deployment, replicas int32) (*v1beta1.Deployment, error) {
|
||||
for i := 0; i < 120; i++ {
|
||||
func (deploy *NewDeploy) waitForDeploy(depl *v1beta1.Deployment, replicas int32, specializationTimeout int) (*v1beta1.Deployment, error) {
|
||||
// if no specializationTimeout is set, use default value
|
||||
if specializationTimeout < DEFAULT_SPECIALIZATION_TIMEOUT {
|
||||
specializationTimeout = DEFAULT_SPECIALIZATION_TIMEOUT
|
||||
}
|
||||
|
||||
for i := 0; i < specializationTimeout; i++ {
|
||||
latestDepl, err := deploy.kubernetesClient.ExtensionsV1beta1().Deployments(depl.ObjectMeta.Namespace).Get(depl.Name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -428,7 +435,10 @@ func (deploy *NewDeploy) waitForDeploy(depl *v1beta1.Deployment, replicas int32)
|
||||
}
|
||||
time.Sleep(time.Second)
|
||||
}
|
||||
return nil, errors.New("failed to create deployment within timeout window")
|
||||
|
||||
// this error appears in the executor pod logs
|
||||
timeoutError := fmt.Errorf("failed to create deployment within the timeout window of %d seconds", specializationTimeout)
|
||||
return nil, timeoutError
|
||||
}
|
||||
|
||||
// cleanupNewdeploy cleans all kubernetes objects related to function
|
||||
|
||||
Reference in New Issue
Block a user