Skip to content
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

Merged
merged 2 commits into from
Jan 30, 2024
Merged

feat: added the gitlab cleanup code #1689

merged 2 commits into from
Jan 30, 2024

Conversation

emamihe
Copy link
Collaborator

@emamihe emamihe commented Jan 19, 2024

this golang code will cleanup the github stalled runners

@emamihe emamihe self-assigned this Jan 19, 2024
Copy link
Contributor

@l0r1s l0r1s left a 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 👍

Comment on lines 17 to 18
fmt.Printf("Error creating in-cluster config: %s\n", err)
os.Exit(1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fmt.Printf("Error creating in-cluster config: %s\n", err)
os.Exit(1)
log.Fatalf("Error creating in-cluster config: %s\n", err)

Comment on lines 23 to 24
fmt.Printf("Error creating clientset: %s\n", err)
os.Exit(1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fmt.Printf("Error creating clientset: %s\n", err)
os.Exit(1)
log.Fatalf("Error creating clientset: %s\n", err)

Comment on lines 31 to 32
fmt.Printf("Error listing pods: %s\n", err)
os.Exit(1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fmt.Printf("Error listing pods: %s\n", err)
os.Exit(1)
log.Fatalf("Error listing pods: %s\n", err)

}

for _, pod := range pods.Items {
if time.Since(pod.CreationTimestamp.Time).Hours() > 12 {
Copy link
Contributor

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 ?

Copy link
Collaborator

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.

@emamihe emamihe changed the title added the gitlab cleanup code feat: added the gitlab cleanup code Jan 30, 2024
Comment on lines +28 to +33
podAgeThresholdHours := 12 // default
if envVal, exists := os.LookupEnv("POD_AGE_THRESHOLD_HOURS"); exists {
if val, err := strconv.Atoi(envVal); err == nil {
podAgeThresholdHours = val
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@l0r1s l0r1s merged commit 62e165e into main Jan 30, 2024
17 of 23 checks passed
@l0r1s l0r1s deleted the gitlab-cleaner branch January 30, 2024 23:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants