kubesphere / kubeeye

KubeEye aims to find various problems on Kubernetes, such as application misconfiguration, unhealthy cluster components and node problems.
https://kubesphere.io
Apache License 2.0
810 stars 126 forks source link

Fix: avoid trigger at wrong time by missed schedule #296

Closed dkeven closed 1 year ago

dkeven commented 1 year ago

What type of PR is this?

What this PR does / Why we need it:

If controller has not reconciled for a long time, e.g. the pod failed to start, a missed schedule might trigger an immediate run at the wrong time, because of the simple comparison in the current implementation: schedule.Next(lastScheduleTime).Before(time.Now())

For example, if a plan is scheduled at the start of every hour (9:00, 10:00...), if the controller has been down for more than 1 hour, an audit task will be created immediately as the controller comes back, no matter what time it is.

A missed schedule check is added in this PR, and if the last schedule is missed for too long, it will be skipped.

dkeven commented 1 year ago

/cc @stoneshi-yunify @pixiake

ks-ci-bot commented 1 year ago

@dkeven: GitHub didn't allow me to request PR reviews from the following users: stoneshi-yunify.

Note that only kubesphere members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to [this](https://github.com/kubesphere/kubeeye/pull/296#issuecomment-1552849799): >/cc @stoneshi-yunify @pixiake Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
dkeven commented 1 year ago

/cc @stoneshi-yunify

ks-ci-bot commented 1 year ago

@dkeven: GitHub didn't allow me to request PR reviews from the following users: stoneshi-yunify.

Note that only kubesphere members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to [this](https://github.com/kubesphere/kubeeye/pull/296#issuecomment-1552853929): >/cc @stoneshi-yunify Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
ks-ci-bot commented 1 year ago

@stoneshi-yunify: changing LGTM is restricted to collaborators

In response to [this](https://github.com/kubesphere/kubeeye/pull/296#pullrequestreview-1433636903): >/lgtm Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
pixiake commented 1 year ago

/lgtm /approve

ks-ci-bot commented 1 year ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dkeven, pixiake, stoneshi-yunify

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files: - ~~[OWNERS](https://github.com/kubesphere/kubeeye/blob/experiment/OWNERS)~~ [pixiake] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment