Adds default resources for fetcher pod (#500)

The fetcher needs a relatively smaller set of resources and does not have to be same as the function container/defaults. This change adds defaults for fetcher containers in function pods.
This commit is contained in:
Vishal
2018-02-24 01:07:02 +05:30
committed by GitHub
parent 245506efe3
commit e5b137fe24
3 changed files with 70 additions and 2 deletions
+13 -2
View File
@@ -34,6 +34,7 @@ import (
"github.com/fission/fission"
"github.com/fission/fission/crd"
"github.com/fission/fission/environments/fetcher"
"github.com/fission/fission/executor/util"
)
const (
@@ -87,6 +88,12 @@ func (deploy *NewDeploy) createOrGetDeployment(fn *crd.Function, env *crd.Enviro
return nil, err
}
fetcherResources, err := util.GetFetcherResources()
if err != nil {
log.Printf("Error while parsing fetcher resources: %v", err)
return nil, err
}
deployment := &v1beta1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Labels: deployLabels,
@@ -148,7 +155,7 @@ func (deploy *NewDeploy) createOrGetDeployment(fn *crd.Function, env *crd.Enviro
},
},
// TBD Use smaller default resources, for now needed to make HPA work
Resources: env.Spec.Resources,
Resources: fetcherResources,
ReadinessProbe: &apiv1.Probe{
Handler: apiv1.Handler{
Exec: &apiv1.ExecAction{
@@ -182,7 +189,7 @@ func (deploy *NewDeploy) createOrGetDeployment(fn *crd.Function, env *crd.Enviro
}
time.Sleep(time.Second)
}
return nil, errors.New("Failed to create deployment within timeout window")
return nil, errors.New("failed to create deployment within timeout window")
}
return nil, err
@@ -214,6 +221,10 @@ func (deploy *NewDeploy) createOrGetHpa(hpaName string, execStrategy *fission.Ex
return existingHpa, err
}
if depl == nil {
return nil, errors.New("failed to create HPA, found empty deployment")
}
if err != nil && k8s_err.IsNotFound(err) {
hpa := asv1.HorizontalPodAutoscaler{
ObjectMeta: metav1.ObjectMeta{