Просмотр исходного кода

Merge branch 'develop' into fix/eks-spot-pricing

Mark 3 лет назад
Родитель
Сommit
a176b45a74
1 измененных файлов с 9 добавлено и 7 удалено
  1. 9 7
      pkg/cloud/gcpprovider.go

+ 9 - 7
pkg/cloud/gcpprovider.go

@@ -426,13 +426,15 @@ func (gcp *GCP) isDiskOrphaned(disk *compute.Disk) (bool, error) {
 
 	// Do not consider disk orphaned if it was used within the last hour
 	threshold := time.Now().Add(time.Duration(-1) * time.Hour)
-	lastUsed, err := time.Parse(time.RFC3339, disk.LastDetachTimestamp)
-	if err != nil {
-		// This can return false since errors are checked before the bool
-		return false, fmt.Errorf("error parsing time: %s", err)
-	}
-	if threshold.Before(lastUsed) {
-		return false, nil
+	if disk.LastDetachTimestamp != "" {
+		lastUsed, err := time.Parse(time.RFC3339, disk.LastDetachTimestamp)
+		if err != nil {
+			// This can return false since errors are checked before the bool
+			return false, fmt.Errorf("error parsing time: %s", err)
+		}
+		if threshold.Before(lastUsed) {
+			return false, nil
+		}
 	}
 	return true, nil
 }