in tpu-provisioner/internal/cloud/gke.go [267:288]
func (g *GKE) checkExistingNodePool(ctx context.Context, desired *containerv1beta1.NodePool) (nodePoolState, error) {
existing, err := g.NodePools.Get(ctx, desired.Name)
if err == nil {
match, err := nodePoolHashesMatch(desired, existing)
if err != nil {
return nodePoolStateUnknown, fmt.Errorf("comparing node pools: %w", err)
}
if match {
return nodePoolStateExistsAndMatches, nil
} else {
return nodePoolStateExistsAndNotMatches, nil
}
}
if gerr, ok := err.(*googleapi.Error); ok && gerr.Code == http.StatusNotFound {
return nodePoolStateNotExists, nil
}
if existing.Status == "STOPPING" {
return nodePoolStateExistsAndStopping, nil
}
return nodePoolStateUnknown, err
}