func()

in pkg/clusters/nodepools.go [125:161]


func (m *nodePoolMigrator) upgrade(ctx context.Context) error {
	npp := m.ResourcePath()
	req := &container.UpdateNodePoolRequest{
		Name:        npp,
		NodeVersion: m.resolvedDesiredNodeVersion,
	}

	op, err := m.clients.Container.UpdateNodePool(ctx, req)
	if err != nil {
		return fmt.Errorf("error upgrading NodePool %s: %w", npp, err)
	}

	opPath := pkg.PathRegex.FindString(op.SelfLink)
	log.Infof("Upgrade in progress for NodePool %s; operation: %s", npp, opPath)

	w := &ContainerOperation{
		ProjectID: m.projectID,
		Path:      opPath,
		Client:    m.clients.Container,
	}
	if err := m.handler.Wait(ctx, w); err != nil {
		return fmt.Errorf("error waiting on Operation %s: %w", opPath, err)
	}

	log.Infof("NodePool %s upgraded. ", npp)

	required, err := m.isUpgradeRequired(ctx)
	if err != nil {
		return fmt.Errorf("unable to verify post-upgrade state for NodePool %s: %w", m.ResourcePath(), err)
	}
	if required {
		// This should not happen, as the cluster must first be successfully migrated.
		return fmt.Errorf("state was not patched for NodePool %s", m.ResourcePath())
	}

	return nil
}