Comments (7)
Well... my mind is kinda blown right now... Apparently the cron library is using the first value as seconds
instead of minutes...
package main
import (
"fmt"
"github.com/robfig/cron"
)
func printNext(s string) {
schedule := cron.New()
schedule.AddFunc(s, func() {})
schedule.Start()
entry := schedule.Entries()[0]
fmt.Println(entry.Next.String())
}
func main() {
printNext("1 2 3 4 5")
}
Results in:
2020-05-04 03:02:01 -0500 CDT
And given that the (documentation)[https://godoc.org/github.com/robfig/cron#hdr-Alternative_Formats] says...
Alternative Cron expression formats support other fields like seconds. You can implement that by creating a custom Parser as follows.
And given that I definitely didn't do that (here)[https://github.com/target/pod-reaper/blob/master/reaper/reaper.go#L98] I'm going to have to dig deeper on this one.
For an ultra quick fix, based on what's currently out there, adding a zero to this perplexing "seconds" value should get you going 0 0 20 * * *
func main() {
printNext("0 20 * * *")
printNext("0 0 20 * * *")
}
Results in:
2020-03-27 07:20:00 -0500 CDT
2020-03-27 20:00:00 -0500 CDT
More to come on this...
from pod-reaper.
Well... turns out the version of the library that I've been using has a surprise (to me anyway)
var defaultParser = NewParser(
Second | Minute | Hour | Dom | Month | DowOptional | Descriptor,
)
Also, the defaultParser
was removed entirely in (this commit)[https://github.com/robfig/cron/commit/1f8ec97c87338ef2c06af340dcf4289c691c6f95#diff-f615844d3497ff38db57e459d6ef657b]
So now that I know what's going on, it seems like it's just a matter of updating the dependency... just with one small note: I'd like to make sure I don't break anyone currently using that seconds field.
I think that means my best bet forward would be to actually use a customer parser using the optionalSeconds
flag provided in the library. My hope is that it will function like this:
- got 6 fields? great, we'll assume you're starting with seconds
- got 5 fields? great, we'll assume you're starting with minutes
from pod-reaper.
Sounds like a plan.
I don't know much about go, but I guess you could pin the version of the cron library to avoid future breaking changes.
Thank you very much for your quick response!
from pod-reaper.
The newest version of that cron dependency has this.
var standardParser = NewParser(
Minute | Hour | Dom | Month | Dow | Descriptor,
)
I don't really see a way to NOT break this without leaving the seconds value... because (of all things) that previous version had an optional Day of Week
value. That's extremely ugly...
Honestly, I think that means that I need need to bite this and get it to where I want it.
PR incoming in not too long.
from pod-reaper.
Guess this helps explain #39 huh? 😄
edit: formatting
from pod-reaper.
from pod-reaper.
docker images with this:
target/pod-reaper:latest
target/pod-reaper:2.6.0
from pod-reaper.
Related Issues (20)
- Easier local development HOT 4
- Allow default configuration override with annotations HOT 14
- Log messages not parsed by Stackdriver HOT 4
- Explicit rule enable
- Setup CI/CD outside of docker
- Deployment bug HOT 2
- Dry run mode HOT 2
- Update Dependencies to use Go Modules HOT 3
- Helm chart HOT 5
- Does pod-reaper act on 1 pod at a time? or all pods simultaneously HOT 10
- Pod status rule is misleading HOT 3
- Upgrade docker base image to use golang 1.15 HOT 3
- In nonprod, reduce resouces: Reap pod/apps so they don't consume resources on weekend HOT 1
- Docker builds no longer happening automatically HOT 5
- v1beta1 ClusterRole is deprecated in v1.17+, unavailable in v1.22+; Use v1 ClusterRole
- MAX_DURATION option does not count the Pod Status Start time HOT 3
- Split the helm chart into a new repo or Equate the the Helm chart version with the pod-reaper version HOT 19
- Pod reaping strategy HOT 5
- Improve dry run log accuracy
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pod-reaper.