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

Some improvements in my opinion for kubernetes #40

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

promzeus
Copy link

@promzeus promzeus commented May 5, 2023

No description provided.

@promzeus
Copy link
Author

promzeus commented May 5, 2023

Some improvements in my opinion for kubernetes

runner.go Show resolved Hide resolved
@@ -34,7 +34,7 @@ func NewRunner() *Runner {
func (r *Runner) Add(cronjob CrontabEntry) error {
_, err := r.cron.AddFunc(cronjob.Spec, r.cmdFunc(cronjob, func(execCmd *exec.Cmd) bool {
// before exec callback
log.WithFields(LogCronjobToFields(cronjob)).Infof("executing")
// log.WithFields(LogCronjobToFields(cronjob)).Infof("executing")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why disabled?

@@ -156,9 +163,11 @@ func (r *Runner) cmdFunc(cronjob CrontabEntry, cmdCallback func(*exec.Cmd) bool)
logFields["result"] = "success"
}

log.WithFields(logFields).Info("finished")
// log.WithFields(logFields).Info("finished")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why disabled?

@promzeus
Copy link
Author

I think the separate line executing and finished is a garbage message.
Instead of a separate start line, I added logFields["started_at"] = start.Format(time.RFC3339) to the finish line
that is, we received the executed command in one json line, where we got the start time, finish time and how long the task took to complete.
The output of many commands looks like this:
{"command":"php artisan app:expire-mutes","crontab":"/etc/cron/cron.conf","elapsed_s":0.646084692,"level":"info","msg":"text","pid":11573,"result":"success","shell":"sh","spec":"* * * * *","started_at":"2023-05-11T13:20:00Z","time":"2023-05-11T13:20:00Z","user":"root"} {"command":"php artisan app:process-side-notifications","crontab":"/etc/cron/cron.conf","elapsed_s":0.650212608,"level":"info","msg":"Command has finished executing without any output to stdout.","pid":11567,"result":"success","shell":"sh","spec":"* * * * *","started_at":"2023-05-11T13:20:00Z","time":"2023-05-11T13:20:00Z","user":"root"} {"command":"php artisan app:archive","crontab":"/etc/cron/cron.conf","elapsed_s":0.653136418,"level":"info","msg":"text","pid":11587,"result":"success","shell":"sh","spec":"* * * * *","started_at":"2023-05-11T13:20:00Z","time":"2023-05-11T13:20:00Z","user":"root"} {"command":"php artisan app:ab-testing:experiment-status-monitor","crontab":"/etc/cron/cron.conf","elapsed_s":0.656003109,"level":"info","msg":"text","pid":11566,"result":"success","shell":"sh","spec":"* * * * *","started_at":"2023-05-11T13:20:00Z","time":"2023-05-11T13:20:00Z","user":"root"} {"command":"php artisan app:expire-bans","crontab":"/etc/cron/cron.conf","elapsed_s":0.6609906,"level":"info","msg":"text","pid":11582,"result":"success","shell":"sh","spec":"* * * * *","started_at":"2023-05-11T13:20:00Z","time":"2023-05-11T13:20:00Z","user":"root"} {"command":"php artisan app:games:single-choice-hunt-schedule","crontab":"/etc/cron/cron.conf","elapsed_s":0.698673296,"level":"info","msg":"Command has finished executing without any output to stdout.","pid":11592,"result":"success","shell":"sh","spec":"* * * * *","started_at":"2023-05-11T13:20:00Z","time":"2023-05-11T13:20:00Z","user":"root"} {"command":"php artisan app:tle:status-update","crontab":"/etc/cron/cron.conf","elapsed_s":0.739153263,"level":"info","msg":"Command has finished executing without any output to stdout.","pid":11569,"result":"success","shell":"sh","spec":"* * * * *","started_at":"2023-05-11T13:20:00Z","time":"2023-05-11T13:20:00Z","user":"root"} {"command":"php artisan horizon:snapshot","crontab":"/etc/cron/cron.conf","elapsed_s":0.743576053,"level":"info","msg":"Metrics snapshot stored successfully.\n","pid":11589,"result":"success","shell":"sh","spec":"*/5 * * * *","started_at":"2023-05-11T13:20:00Z","time":"2023-05-11T13:20:00Z","user":"root"} {"command":"php artisan app:update-levels","crontab":"/etc/cron/cron.conf","elapsed_s":0.744559418,"level":"info","msg":"text","pid":11597,"result":"success","shell":"sh","spec":"20 * * * *","started_at":"2023-05-11T13:20:00Z","time":"2023-05-11T13:20:00Z","user":"root"} {"command":"php artisan decoy-token:sync-token-state","crontab":"/etc/cron/cron.conf","elapsed_s":0.963715653,"level":"info","msg":"text","pid":11571,"result":"error","shell":"sh","spec":"* * * * *","started_at":"2023-05-11T13:20:00Z","time":"2023-05-11T13:20:00Z","user":"root"} {"command":"php artisan app:games:single-choice-hunt-schedule","crontab":"/etc/cron/cron.conf","elapsed_s":0.46856026,"level":"info","msg":"Command has finished executing without any output to stdout.","pid":11634,"result":"success","shell":"sh","spec":"* * * * *","started_at":"2023-05-11T13:21:00Z","time":"2023-05-11T13:21:00Z","user":"root"} {"command":"php artisan app:archive","crontab":"/etc/cron/cron.conf","elapsed_s":0.493647749,"level":"info","msg":"Archive is not writable. Terminating...\n","pid":11643,"result":"success","shell":"sh","spec":"* * * * *","started_at":"2023-05-11T13:21:00Z","time":"2023-05-11T13:21:00Z","user":"root"} {"command":"php artisan app:ab-testing:experiment-status-monitor","crontab":"/etc/cron/cron.conf","elapsed_s":0.50054996,"level":"info","msg":"text","pid":11647,"result":"success","shell":"sh","spec":"* * * * *","started_at":"2023-05-11T13:21:00Z","time":"2023-05-11T13:21:00Z","user":"root"} {"command":"php artisan app:handle-periodical-awards","crontab":"/etc/cron/cron.conf","elapsed_s":0.532604097,"level":"info","msg":"Command has finished executing without any output to stdout.","pid":11638,"result":"success","shell":"sh","spec":"* * * * *","started_at":"2023-05-11T13:21:00Z","time":"2023-05-11T13:21:00Z","user":"root"} {"command":"php artisan app:tle:status-update","crontab":"/etc/cron/cron.conf","elapsed_s":0.540661165,"level":"info","msg":"Command has finished executing without any output to stdout.","pid":11631,"result":"success","shell":"sh","spec":"* * * * *","started_at":"2023-05-11T13:21:00Z","time":"2023-05-11T13:21:00Z","user":"root"}

@promzeus
Copy link
Author

If you mix the start and finish separately in the logs. Then we get a lot of garbage messages and we will have to compare by PID where exactly this team started and where exactly it finished, and the debug message to which start it belongs.
But in my version, I got everything in one message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants