Use executor type as a delimiter to prevent deploy name conflict (#1009)

This commit is contained in:
Ta-Ching Chen
2018-11-30 13:04:44 +08:00
committed by GitHub
parent 19b52938c3
commit 72faa927de
2 changed files with 10 additions and 5 deletions
+5 -3
View File
@@ -25,7 +25,6 @@ import (
"strings"
"time"
"github.com/dchest/uniuri"
"github.com/pkg/errors"
apiv1 "k8s.io/api/core/v1"
"k8s.io/api/extensions/v1beta1"
@@ -548,8 +547,11 @@ func (deploy *NewDeploy) fnDelete(fn *crd.Function) (*fscache.FuncSvc, error) {
}
func (deploy *NewDeploy) getObjName(fn *crd.Function) string {
return strings.ToLower(fmt.Sprintf("newdeploy-%v-%v-%v",
fn.Metadata.Name, fn.Metadata.Namespace, uniuri.NewLen(8)))
// Use executor type as delimiter between function name and namespace to prevent deployment name conflict.
// For example:
// 1. fn-name: a-b fn-namespace: c => a-b-newdeploy-c
// 2. fn-name: a fn-namespace: b-c => a-newdeploy-b-c
return strings.ToLower(fmt.Sprintf("%v-newdeploy-%v", fn.Metadata.Name, fn.Metadata.Namespace))
}
func (deploy *NewDeploy) getDeployLabels(fn *crd.Function, env *crd.Environment) map[string]string {
+5 -2
View File
@@ -462,8 +462,11 @@ func (gp *GenericPool) specializePod(pod *apiv1.Pod, metadata *metav1.ObjectMeta
}
func (gp *GenericPool) getPoolName() string {
return strings.ToLower(fmt.Sprintf("poolmgr-%v-%v-%v",
gp.env.Metadata.Name, gp.env.Metadata.Namespace, uniuri.NewLen(8)))
// Use executor type as delimiter between function name and namespace to prevent deployment name conflict.
// For example:
// 1. fn-name: a-b fn-namespace: c => a-b-poolmgr-c
// 2. fn-name: a fn-namespace: b-c => a-poolmgr-b-c
return strings.ToLower(fmt.Sprintf("%v-poolmgr-%v", gp.env.Metadata.Name, gp.env.Metadata.Namespace))
}
// A pool is a deployment of generic containers for an env. This