From 50e7c19b5f89a3e48831b39dc06aa6298bded2be Mon Sep 17 00:00:00 2001 From: chentao1596 Date: Thu, 30 Mar 2017 15:44:11 +0800 Subject: [PATCH] add judgement about truncate for 'NameBelongsToCluster' --- controllers/gce/utils/utils.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/controllers/gce/utils/utils.go b/controllers/gce/utils/utils.go index 3b628ef6c..5d4e60996 100644 --- a/controllers/gce/utils/utils.go +++ b/controllers/gce/utils/utils.go @@ -206,7 +206,13 @@ func (n *Namer) NameBelongsToCluster(name string) bool { glog.Warningf("Too many parts to name %v, ignoring", name) return false } - return parts[1] == clusterName + + if len(name) > nameLenLimit { + glog.V(4).Infof("%s has been truncated", name) + return strings.HasPrefix(clusterName, strings.TrimSuffix(parts[1], alphaNumericChar)) + }else{ + return parts[1] == clusterName + } } // BeName constructs the name for a backend.