func()

in internal/deployers/eksapi/cluster.go [98:128]


func (m *ClusterManager) waitForClusterActive(clusterName string, timeout time.Duration) (*Cluster, error) {
	klog.Infof("waiting for cluster to be active: %s", clusterName)
	out, err := eks.NewClusterActiveWaiter(m.clients.EKS()).WaitForOutput(context.TODO(), &eks.DescribeClusterInput{
		Name: aws.String(clusterName),
	}, timeout)
	// log when possible, whether there was an error or not
	if out != nil {
		klog.Infof("cluster details: %+v", out.Cluster)
	}
	if err != nil {
		return nil, fmt.Errorf("failed waiting for cluster be active: %v", err)
	}
	klog.Infof("cluster is active: %s", *out.Cluster.Arn)
	var cidr string
	switch out.Cluster.KubernetesNetworkConfig.IpFamily {
	case ekstypes.IpFamilyIpv4:
		cidr = *out.Cluster.KubernetesNetworkConfig.ServiceIpv4Cidr
	case ekstypes.IpFamilyIpv6:
		cidr = *out.Cluster.KubernetesNetworkConfig.ServiceIpv6Cidr
	default:
		return nil, fmt.Errorf("unknown cluster IP family: '%v'", out.Cluster.KubernetesNetworkConfig.IpFamily)
	}
	return &Cluster{
		arn:                      *out.Cluster.Arn,
		certificateAuthorityData: *out.Cluster.CertificateAuthority.Data,
		cidr:                     cidr,
		endpoint:                 *out.Cluster.Endpoint,
		name:                     *out.Cluster.Name,
		securityGroupId:          *out.Cluster.ResourcesVpcConfig.ClusterSecurityGroupId,
	}, nil
}