Skip to content
This repository was archived by the owner on May 24, 2025. It is now read-only.
Merged
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
10 changes: 10 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ var dovecotDirectorLabels string
var namespace string
var kubeconf *rest.Config

var initialDovecotPodCount int

func main() {
clientset, err := InClusterAuth()

Expand All @@ -39,6 +41,9 @@ func main() {
dovecotLabels = os.Getenv("DOVECOT_LABELS")
namespace = os.Getenv("DOVECOT_NAMESPACE")

dovecotPods := GetPodsByLabel(clientset, namespace, dovecotLabels)
initialDovecotPodCount = len(dovecotPods.Items)

StartWatcher(clientset, namespace)
}

Expand Down Expand Up @@ -95,6 +100,11 @@ func ExecuteCommand(command string, podname string, namespace string, clientset
}

func handleEvent(pod *v1.Pod, clientset *kubernetes.Clientset) {
if initialDovecotPodCount > 1 {
initialDovecotPodCount--
return
}

switch pod.Status.Phase {
case v1.PodFailed, v1.PodSucceeded:
case v1.PodRunning:
Expand Down