GetInstancePods gets all the pods belonging to a given cluster returns an array with all the instances, the primary instance and any error encountered.
(ctx context.Context, clusterName string)
| 54 | // GetInstancePods gets all the pods belonging to a given cluster |
| 55 | // returns an array with all the instances, the primary instance and any error encountered. |
| 56 | func GetInstancePods(ctx context.Context, clusterName string) ([]corev1.Pod, corev1.Pod, error) { |
| 57 | var pods corev1.PodList |
| 58 | if err := plugin.Client.List(ctx, &pods, client.InNamespace(plugin.Namespace)); err != nil { |
| 59 | return nil, corev1.Pod{}, err |
| 60 | } |
| 61 | |
| 62 | var managedPods []corev1.Pod |
| 63 | var primaryPod corev1.Pod |
| 64 | for idx := range pods.Items { |
| 65 | for _, owner := range pods.Items[idx].OwnerReferences { |
| 66 | if owner.Kind == apiv1.ClusterKind && owner.Name == clusterName { |
| 67 | managedPods = append(managedPods, pods.Items[idx]) |
| 68 | if specs.IsPodPrimary(pods.Items[idx]) { |
| 69 | primaryPod = pods.Items[idx] |
| 70 | } |
| 71 | } |
| 72 | } |
| 73 | } |
| 74 | return managedPods, primaryPod, nil |
| 75 | } |
| 76 | |
| 77 | // ExtractInstancesStatus extracts the instance status from the given pod list |
| 78 | func ExtractInstancesStatus( |
no test coverage detected