in pkg/clusters/clusters.go [128:167]
func (m *clusterMigrator) upgradeControlPlane(ctx context.Context) error {
if m.cluster.Subnetwork != "" {
log.Infof("Cluster %s does not require control plane upgrade.", m.ResourcePath())
return nil
}
req := &container.UpdateMasterRequest{
Name: m.ResourcePath(),
MasterVersion: m.resolvedDesiredControlPlaneVersion,
}
log.Infof("Upgrading control plane for Cluster %q to version %q", req.Name, req.MasterVersion)
op, err := m.clients.Container.UpdateMaster(ctx, req)
if err != nil {
return fmt.Errorf("error upgrading control plane for Cluster %s: %w", m.ResourcePath(), err)
}
path := pkg.PathRegex.FindString(op.SelfLink)
w := &ContainerOperation{
ProjectID: m.projectID,
Path: path,
Client: m.clients.Container,
}
if err := m.handler.Wait(ctx, w); err != nil {
return fmt.Errorf("error waiting on Operation %s: %w", path, err)
}
log.Infof("Upgraded control plane for Cluster %q to version %q", req.Name, req.MasterVersion)
resp, err := m.clients.Container.GetCluster(ctx, m.ResourcePath())
if err != nil {
return fmt.Errorf("unable to confirm subnetwork value for cluster %s: %w", m.ResourcePath(), err)
}
if resp.Subnetwork == "" {
return fmt.Errorf("subnetwork field is empty for cluster %s", m.ResourcePath())
}
return nil
}