Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions extensions/clusters/clusters.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const (

// GetV1ProvisioningClusterByName is a helper function that returns the cluster ID by name
func GetV1ProvisioningClusterByName(client *rancher.Client, clusterName string) (string, error) {
clusterList, err := client.Steve.SteveType(ProvisioningSteveResourceType).List(nil)
clusterList, err := client.Steve.SteveType(ProvisioningSteveResourceType).ListAll(nil)
if err != nil {
return "", err
}
Expand All @@ -59,7 +59,7 @@ func GetV1ProvisioningClusterByName(client *rancher.Client, clusterName string)

// GetClusterIDByName is a helper function that returns the cluster ID by name
func GetClusterIDByName(client *rancher.Client, clusterName string) (string, error) {
clusterList, err := client.Management.Cluster.List(&types.ListOpts{})
clusterList, err := client.Management.Cluster.ListAll(&types.ListOpts{})
if err != nil {
return "", err
}
Expand All @@ -75,7 +75,7 @@ func GetClusterIDByName(client *rancher.Client, clusterName string) (string, err

// GetClusterNameByID is a helper function that returns the cluster ID by name
func GetClusterNameByID(client *rancher.Client, clusterID string) (string, error) {
clusterList, err := client.Management.Cluster.List(&types.ListOpts{})
clusterList, err := client.Management.Cluster.ListAll(&types.ListOpts{})
if err != nil {
return "", err
}
Expand All @@ -98,6 +98,7 @@ func IsProvisioningClusterReady(event watch.Event) (ready bool, err error) {
for _, condition := range cluster.Status.Conditions {
if condition.Type == "Updated" && condition.Status == corev1.ConditionTrue {
updated = true
logrus.Infof("[%s/%s] Cluster status is active!", cluster.Namespace, cluster.Name)
}
}

Expand All @@ -115,7 +116,7 @@ func IsHostedProvisioningClusterReady(event watch.Event) (ready bool, err error)
}
for _, cond := range cluster.Status.Conditions {
if cond.Type == "Ready" && cond.Status == "True" {
logrus.Infof("Cluster status is active!")
logrus.Infof("[%s/%s] Cluster status is active!", cluster.Namespace, cluster.Name)
return true, nil
}
}
Expand Down Expand Up @@ -143,7 +144,6 @@ func CreateRKE1Cluster(client *rancher.Client, rke1Cluster *management.Cluster)
}
return true, nil
})

if err != nil {
return nil, err
}
Expand Down Expand Up @@ -212,7 +212,6 @@ func CreateK3SRKE2Cluster(client *rancher.Client, rke2Cluster *apisV1.Cluster) (

return true, nil
})

if err != nil {
return nil, err
}
Expand All @@ -232,7 +231,6 @@ func CreateK3SRKE2Cluster(client *rancher.Client, rke2Cluster *apisV1.Cluster) (
FieldSelector: "metadata.name=" + cluster.ObjectMeta.Name,
TimeoutSeconds: &defaults.WatchTimeoutSeconds,
})

if err != nil {
return err
}
Expand Down Expand Up @@ -288,6 +286,7 @@ func DeleteK3SRKE2Cluster(client *rancher.Client, clusterID string) error {
return err
}

logrus.Infof("[%s/%s] Deleting cluster...", cluster.ObjectMeta.Namespace, cluster.ObjectMeta.Name)
err = client.Steve.SteveType(stevetypes.Provisioning).Delete(cluster)
if err != nil {
return err
Expand Down Expand Up @@ -337,7 +336,7 @@ func UpdateK3SRKE2Cluster(client *rancher.Client, cluster *v1.SteveAPIObject, up

updatedCluster.ObjectMeta.ResourceVersion = updateCluster.ObjectMeta.ResourceVersion

logrus.Infof("Updating cluster...")
logrus.Infof("[%s/%s] Updating cluster...", updateCluster.ObjectMeta.Namespace, updateCluster.ObjectMeta.Name)
cluster, err = client.Steve.SteveType(ProvisioningSteveResourceType).Update(cluster, updatedCluster)
if err != nil {
return nil, err
Expand Down Expand Up @@ -366,19 +365,18 @@ func UpdateK3SRKE2Cluster(client *rancher.Client, cluster *v1.SteveAPIObject, up
return false, err
}

_, err = proxyClient.SteveType(pods.PodResourceSteveType).List(nil)
_, err = proxyClient.SteveType(pods.PodResourceSteveType).ListAll(nil)
if err != nil {
return false, nil
}

logrus.Infof("Cluster has been successfully updated!")
logrus.Infof("[%s/%s] Cluster has been successfully updated!, cluster", updatedCluster.Namespace, updatedCluster.Name)

return true, nil
}

return false, nil
})

if err != nil {
return nil, err
}
Expand Down Expand Up @@ -461,7 +459,6 @@ func WaitClusterUntilUpgrade(client *rancher.Client, clusterID string) (err erro
return false, nil
} else if summarizedCluster.Error && !isClusterInaccessible(summarizedCluster.Message, acceptableErrorMessages) {
return false, errors.Wrap(err, clusterErrorStateMessage)

}

return false, nil
Expand Down
Loading