Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.

Submit on FM startup #119

Merged
merged 3 commits into from
Mar 30, 2021
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion services/fluxmonitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ func NewFluxMonitor(config FluxMonitorConfig, triggerJobRun chan subscriber.Even
}

fm.canSubmitUpdated()

// make an initial sumbission on startup
fm.checkAndSendJob(false)
go fm.eventListener(FAEvents)

return &fm, nil
Expand Down Expand Up @@ -214,6 +215,15 @@ func (fm *FluxMonitor) checkAndSendJob(initiate bool) error {
return err
}

if fm.latestResult.IsZero() {
logger.Warn("Polling because result is zero")
err := fm.poll()
if err != nil {
logger.Error("cannot retrieve result from polling")
return err
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

This shouldn't be necessary, since we're checking the age of the result just below this (L227). If this hasn't been set - it's always going to trigger a new poll.

Copy link
Author

Choose a reason for hiding this comment

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

True + it will start having an actual functionality :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep 👍

// If latestResult is an old value for some reason, try to fetch new
if time.Since(fm.latestResultTimestamp) > fm.config.PollInterval+fm.config.AdapterTimeout {
logger.Warn("Polling again because result is old")
Expand Down