Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
vimystic committed Apr 3, 2024
1 parent eb36aaf commit 9540577
Showing 1 changed file with 29 additions and 12 deletions.
41 changes: 29 additions & 12 deletions internal/fullnode/stuck_detection.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,37 @@ func (d StuckPodDetection) StuckPods(ctx context.Context, crd *cosmosv1.CosmosFu

pods := d.collector.Collect(ctx, client.ObjectKeyFromObject(crd)).Synced().Pods()

fmt.Println(pods[0])
for i, pod := range pods {

config, err := rest.InClusterConfig()
if err != nil {
panic(err.Error())
}
config, err := rest.InClusterConfig()
if err != nil {
panic(err.Error())
}

clientset, err := kubernetes.NewForConfig(config)
if err != nil {
panic(err.Error())
}
clientset, err := kubernetes.NewForConfig(config)
if err != nil {
panic(err.Error())
}

testString := getPodLogsLastLine(clientset, pod)
fmt.Println(testString)
podIsStuck := isPodStuck(testString)

testString := getPodLogsLastLine(clientset, pods[0])
fmt.Println(testString)
//MORE TODO HERE
if podIsStuck {
pods = removeElement(pods, i)
}

//MORE TODO HERE
}

return []*corev1.Pod{}
}


func isPodStuck(testString string) bool {
return strings.Contains(inputString, "SignerListener: Connected")
}

func getPodLogsLastLine(clientset *kubernetes.Clientset, pod *corev1.Pod) string {
podLogOpts := corev1.PodLogOptions{}
logRequest := clientset.CoreV1().Pods(pod.Namespace).GetLogs(pod.Name, &podLogOpts)
Expand All @@ -78,3 +89,9 @@ func getPodLogsLastLine(clientset *kubernetes.Clientset, pod *corev1.Pod) string
}
return ""
}

}

func removeElement(slice []*corev1.Pod, index int) []*corev1.Pod {
return append(slice[:index], slice[index+1:]...)
}

0 comments on commit 9540577

Please sign in to comment.