-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: added the gitlab cleanup code #1689
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few nits but looks good 👍
scripts/gitlab_cleanup/main.go
Outdated
fmt.Printf("Error creating in-cluster config: %s\n", err) | ||
os.Exit(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fmt.Printf("Error creating in-cluster config: %s\n", err) | |
os.Exit(1) | |
log.Fatalf("Error creating in-cluster config: %s\n", err) |
scripts/gitlab_cleanup/main.go
Outdated
fmt.Printf("Error creating clientset: %s\n", err) | ||
os.Exit(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fmt.Printf("Error creating clientset: %s\n", err) | |
os.Exit(1) | |
log.Fatalf("Error creating clientset: %s\n", err) |
scripts/gitlab_cleanup/main.go
Outdated
fmt.Printf("Error listing pods: %s\n", err) | ||
os.Exit(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fmt.Printf("Error listing pods: %s\n", err) | |
os.Exit(1) | |
log.Fatalf("Error listing pods: %s\n", err) |
scripts/gitlab_cleanup/main.go
Outdated
} | ||
|
||
for _, pod := range pods.Items { | ||
if time.Since(pod.CreationTimestamp.Time).Hours() > 12 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could probably extract a const, maybe having it in the env to make this configurable without having to change the code ? Wdyt ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think an env var with a default value could be better.
a02f246
to
41b0b16
Compare
podAgeThresholdHours := 12 // default | ||
if envVal, exists := os.LookupEnv("POD_AGE_THRESHOLD_HOURS"); exists { | ||
if val, err := strconv.Atoi(envVal); err == nil { | ||
podAgeThresholdHours = val | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
this golang code will cleanup the github stalled runners