Skip to content

Commit

Permalink
fix problem of inconsistency between task quantity and reserved quantity
Browse files Browse the repository at this point in the history
  • Loading branch information
liangzai006 committed Nov 30, 2023
1 parent a563f14 commit 3eca3e7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/release_dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
with:
context: .
file: build/apiserver/Dockerfile
platforms: linux/amd64,linux/arm64
platforms: linux/amd64
push: true
tags: jw008/kubeeye-apiserver:${{ github.ref_name }}

Expand Down Expand Up @@ -57,7 +57,7 @@ jobs:
with:
context: .
file: build/controller/Dockerfile
platforms: linux/amd64,linux/arm64
platforms: linux/amd64
push: true
tags: jw008/kubeeye-controller:${{ github.ref_name }}

Expand Down Expand Up @@ -85,7 +85,7 @@ jobs:
with:
context: .
file: build/job/Dockerfile
platforms: linux/amd64,linux/arm64
platforms: linux/amd64
push: true
tags: jw008/kubeeye-job:${{ github.ref_name }}

Expand Down
4 changes: 2 additions & 2 deletions pkg/controllers/inspectplan_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ func nextScheduledTimeDuration(sched cron.Schedule, now *metav1.Time) *time.Dura

func (r *InspectPlanReconciler) createInspectTask(plan *kubeeyev1alpha2.InspectPlan, ctx context.Context) (string, error) {
ownerController := true
r.removeTask(ctx, plan)
inspectTask := kubeeyev1alpha2.InspectTask{
ObjectMeta: metav1.ObjectMeta{
Name: fmt.Sprintf("%s-%s", plan.Name, time.Now().Format("20060102-15-04")),
Expand Down Expand Up @@ -257,6 +256,7 @@ func (r *InspectPlanReconciler) createInspectTask(plan *kubeeyev1alpha2.InspectP
return "", err
}
klog.Info("create a new inspect task.", inspectTask.Name)
r.removeTask(ctx, plan)
return inspectTask.Name, nil
}

Expand All @@ -266,7 +266,7 @@ func (r *InspectPlanReconciler) removeTask(ctx context.Context, plan *kubeeyev1a
if err != nil {
klog.Error("Failed to get inspect task for label", err)
}
if len(tasks) > plan.Spec.MaxTasks {
if len(tasks) >= plan.Spec.MaxTasks {
for _, task := range tasks[:len(tasks)-plan.Spec.MaxTasks] {
err = r.K8sClient.VersionClientSet.KubeeyeV1alpha2().InspectTasks().Delete(ctx, task.Name, metav1.DeleteOptions{})
if err == nil || kubeErr.IsNotFound(err) {
Expand Down

0 comments on commit 3eca3e7

Please sign in to comment.