Skip to content

Commit

Permalink
chore: fix linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
moshloop committed Aug 22, 2024
1 parent eed3181 commit 303cb0d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
6 changes: 4 additions & 2 deletions context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,10 @@ func (k *Context) Kubernetes() kubernetes.Interface {
}

func (k *Context) KubernetesRestConfig() *rest.Config {
v, _ := k.Value("kubernetes-rest").((*rest.Config))
return v
if v, ok := k.Value("kubernetes-rest").(*rest.Config); ok {
return v
}
return nil
}

func (k *Context) KubernetesDynamicClient() *dutyKubernetes.DynamicClient {
Expand Down
16 changes: 8 additions & 8 deletions job/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,18 +364,18 @@ func (j *Job) Run() {
time.Sleep(jitterDuration)
}

for i, l := range j.Semaphores {
ctx.Logger.V(9).Infof("[%s] acquiring sempahore [%d/%d]", j.ID, i+1, len(j.Semaphores))
if err := l.Acquire(ctx, 1); err != nil {
for i, lock := range j.Semaphores {
ctx.Logger.V(6).Infof("[%s] acquiring sempahore [%d/%d]", j.ID, i+1, len(j.Semaphores))
if err := lock.Acquire(ctx, 1); err != nil {
r.Failf("too many concurrent jobs, skipping")
return
}
ctx.Logger.V(9).Infof("[%s] acquired sempahore [%d/%d]", j.ID, i+1, len(j.Semaphores))
ctx.Logger.V(7).Infof("[%s] acquired sempahore [%d/%d]", j.ID, i+1, len(j.Semaphores))

defer func() {
l.Release(1)
ctx.Logger.V(9).Infof("[%s] released sempahore [%d/%d]", j.ID, i+1, len(j.Semaphores))
}()
defer func(s *semaphore.Weighted, msg string) {
s.Release(1)
ctx.Logger.V(6).Infof(msg)
}(lock, fmt.Sprintf("[%s] released sempahore [%d/%d]", j.ID, i+1, len(j.Semaphores)))
}

if j.Timeout > 0 {
Expand Down

0 comments on commit 303cb0d

Please sign in to comment.