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(hatchery): killAwolWorkerInterval as conf option #6662

Merged
merged 2 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion engine/cmd_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ var configEditCmd = &cobra.Command{
}

for _, vk := range args[1:] {
t := strings.Split(vk, "=")
t := strings.SplitN(vk, "=", 2)
if len(t) != 2 {
sdk.Exit("Invalid key=value: %v", vk)
}
Expand Down
9 changes: 9 additions & 0 deletions engine/hatchery/kubernetes/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,14 @@ func (h *HatcheryKubernetes) routines(ctx context.Context) {
tickerSecrets := time.NewTicker(deleteSecretsInterval)
defer tickerSecrets.Stop()

killAwolWorkersInterval := 10 * time.Second
if h.Config.KillAwolWorkersInterval > 0 {
killAwolWorkersInterval = time.Duration(h.Config.KillAwolWorkersInterval) * time.Second
}

tickerKillAwolWorkers := time.NewTicker(killAwolWorkersInterval)
defer tickerKillAwolWorkers.Stop()

for {
select {
case <-ticker.C:
Expand All @@ -513,6 +521,7 @@ func (h *HatcheryKubernetes) routines(ctx context.Context) {
}
})

case <-tickerKillAwolWorkers.C:
h.GoRoutines.Exec(ctx, "killAwolWorker", func(ctx context.Context) {
if err := h.killAwolWorkers(ctx); err != nil {
log.ErrorWithStackTrace(ctx, sdk.WrapError(err, "cannot delete awol worker"))
Expand Down
2 changes: 2 additions & 0 deletions engine/hatchery/kubernetes/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ type HatcheryConfiguration struct {
CustomAnnotations []CustomAnnotation `mapstructure:"customAnnotations" toml:"customAnnotations" default:"" commented:"true" comment:"CustomAnnotations that will be added to pods spawned by the hatchery" json:"-"`
// DeleteSecretsInterval used by deleteSecrets to clean secrets not used
DeleteSecretsInterval int `mapstructure:"deleteSecretsInterval" toml:"deleteSecretsInterval" commented:"true" comment:"Delete kubernetes worker secrets not used (seconds)" json:"deleteSecretsInterval"`
// KillAwolWorkersInterval used by killAwolWorkers to remove unused workers
KillAwolWorkersInterval int `mapstructure:"killAwolWorkersInterval" toml:"killAwolWorkersInterval" commented:"true" comment:"Kill awol worker interval (seconds)" json:"killAwolWorkersInterval"`
}

type CustomAnnotation struct {
Expand Down
2 changes: 1 addition & 1 deletion tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ minio_start: $(MINIO_RC)
$(info $(MINIO_CONFIG))

minio_reset_bucket:
@docker run --rm --link minio1:minio --entrypoint sh minio/mc -c "\
@docker run --rm --link minio1:minio --entrypoint sh minio/mc:RELEASE.2023-10-14T01-57-03Z -c "\
microdnf update --nodocs; microdnf install nc --nodocs; \
while ! nc -z minio 9000; do echo 'Wait minio to startup...' && sleep 0.1; done; \
sleep 5 && \
Expand Down