Check length of instance name before truncating

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
This commit is contained in:
Davanum Srinivas 2024-03-03 18:49:57 -05:00
parent d45d803ac4
commit c61b2a3975
No known key found for this signature in database
GPG Key ID: 80D83A796103BF59

View File

@ -646,7 +646,10 @@ func (g *GCERunner) imageToInstanceName(imageConfig *internalGCEImage) string {
// different machine types with the same image in parallel
name := imageConfig.machine + "-" + imageConfig.image + "-" + uuid.New().String()[:8]
// Sometimes the image is too long, we need instance names to have a max length of 63
return name[:63]
if len(name) > 63 {
return name[:63]
}
return name
}
func (g *GCERunner) registerGceHostIP(host string) error {