debug multiple

This commit is contained in:
mr 2024-08-20 16:14:10 +02:00
parent c5d15d32da
commit 826650487b
4 changed files with 18 additions and 10 deletions

View File

@ -12,6 +12,7 @@ type LocalMonitor struct {
LokiURL string
KubeURL string
WorkflowName string
Duration int
Logger zerolog.Logger
}
@ -29,7 +30,11 @@ func (lm *LocalMonitor) LaunchLocalMonitor() {
}
func (lm *LocalMonitor) execLocalKube() {
cmd := exec.Command(conf.GetConfig().MonitorPath, "-w", lm.WorkflowName, "-u", lm.LokiURL, "-m", conf.GetConfig().MongoUrl, "-d", conf.GetConfig().DBName)
args := []string{"-w", lm.WorkflowName, "-u", lm.LokiURL, "-m", conf.GetConfig().MongoUrl, "-d", conf.GetConfig().DBName}
if lm.Duration > 0 {
args = append(args, "-t", fmt.Sprintf("%d", lm.Duration))
}
cmd := exec.Command(conf.GetConfig().MonitorPath, args...)
fmt.Println("CMD", cmd)
err := cmd.Start()
if err != nil {

View File

@ -43,9 +43,15 @@ func (em *ExecutionManager) executeBooking(booking Booking) {
logger.Error().Msg("TODO : executing oc-monitor in a k8s")
} else {
logger.Debug().Msg("Executing oc-monitor localy")
duration := 0
if booking.Stop != nil && booking.Start != nil {
duration = int(booking.Stop.Sub(*booking.Start).Seconds())
}
monitor := LocalMonitor{
Logger: logger,
LokiURL: conf.GetConfig().LokiUrl, KubeURL: "localhost",
Duration: duration,
LokiURL: conf.GetConfig().LokiUrl,
KubeURL: "localhost",
WorkflowName: booking.Workflow,
}
monitor.LaunchLocalMonitor()

View File

@ -23,8 +23,7 @@ type Booking struct {
}
func (s Booking) Equals(other Booking) bool {
fmt.Println(s, other)
return s.Workflow == other.Workflow && s.Start == other.Start && s.Stop == other.Stop
return s.Workflow == other.Workflow && s.Start == other.Start
}
func (b *Booking) String() string {
@ -111,11 +110,9 @@ func retrieveMapFromSub(message []byte) (result_map map[string]string) {
func (s *ScheduleManager) SchedulePolling() {
var sleep_time float64 = 1
for {
s.getNextScheduledWorkflows(3)
s.Logger.Info().Msg("Current list of schedules")
fmt.Println(Bookings.Bookings)
s.getNextScheduledWorkflows(1)
s.Logger.Info().Msg("Current list of schedules -------> " + fmt.Sprintf("%v", len(Bookings.Bookings)))
time.Sleep(time.Minute * time.Duration(sleep_time))
}
}
@ -142,8 +139,8 @@ func (s *ScheduleManager) getWorfklowExecution(from time.Time, to time.Time) (ex
func (s *ScheduleManager) getNextScheduledWorkflows(minutes float64) {
start := time.Now().UTC()
end := start.Add(time.Minute * time.Duration(minutes+1)).UTC()
end := start.Add(time.Minute * time.Duration(minutes)).UTC()
start = start.Add(time.Second * time.Duration(-1)).UTC()
fmt.Printf("Getting workflows execution from %s to %s \n", start.String(), end.String())
next_wf_exec, err := s.getWorfklowExecution(start, end)

Binary file not shown.