Fix newdeploy fail to update HPA, deployment of a function after function update (#862)
This commit is contained in:
@@ -425,9 +425,9 @@ func (deploy *NewDeploy) createOrGetHpa(hpaName string, execStrategy *fission.Ex
|
||||
|
||||
}
|
||||
|
||||
func (deploy *NewDeploy) getHpa(fn *crd.Function) (*asv1.HorizontalPodAutoscaler, error) {
|
||||
func (deploy *NewDeploy) getHpa(ns string, fn *crd.Function) (*asv1.HorizontalPodAutoscaler, error) {
|
||||
hpaName := deploy.getObjName(fn)
|
||||
return deploy.kubernetesClient.AutoscalingV1().HorizontalPodAutoscalers(fn.Metadata.Namespace).Get(hpaName, metav1.GetOptions{})
|
||||
return deploy.kubernetesClient.AutoscalingV1().HorizontalPodAutoscalers(ns).Get(hpaName, metav1.GetOptions{})
|
||||
}
|
||||
|
||||
func (deploy *NewDeploy) updateHpa(hpa *asv1.HorizontalPodAutoscaler) error {
|
||||
|
||||
@@ -397,7 +397,14 @@ func (deploy *NewDeploy) fnUpdate(oldFn *crd.Function, newFn *crd.Function) {
|
||||
return
|
||||
}
|
||||
|
||||
hpa, err := deploy.getHpa(newFn)
|
||||
// to support backward compatibility, if the function was created in default ns, we fall back to creating the
|
||||
// deployment of the function in fission-function ns, so cleaning up resources there
|
||||
ns := deploy.namespace
|
||||
if newFn.Metadata.Namespace != metav1.NamespaceDefault {
|
||||
ns = newFn.Metadata.Namespace
|
||||
}
|
||||
|
||||
hpa, err := deploy.getHpa(ns, newFn)
|
||||
if err != nil {
|
||||
updateStatus(oldFn, err, "error getting HPA while updating function")
|
||||
return
|
||||
@@ -469,7 +476,7 @@ func (deploy *NewDeploy) fnUpdate(oldFn *crd.Function, newFn *crd.Function) {
|
||||
}
|
||||
deployName := deploy.getObjName(oldFn)
|
||||
deployLabels := deploy.getDeployLabels(oldFn, env)
|
||||
log.Printf("updating deployment due to function update")
|
||||
log.Printf("updating %v deployment due to function %v update", deployName, newFn.Metadata.Name)
|
||||
newDeployment, err := deploy.getDeploymentSpec(newFn, env, deployName, deployLabels)
|
||||
if err != nil {
|
||||
updateStatus(oldFn, err, "failed to get new deployment spec while updating function")
|
||||
@@ -580,7 +587,7 @@ func (deploy *NewDeploy) updateKubeObjRefRV(fsvc *fscache.FuncSvc, objKind strin
|
||||
// updateStatus is a function which updates status of update.
|
||||
// Current implementation only logs messages, in future it will update function status
|
||||
func updateStatus(fn *crd.Function, err error, message string) {
|
||||
log.Printf(message, err)
|
||||
log.Println(message, fn, err)
|
||||
}
|
||||
|
||||
// IsValidService does a get on the service address to ensure it's a valid service. returns true if it is, else false.
|
||||
|
||||
Reference in New Issue
Block a user