Skip to content

Commit

Permalink
Merge pull request #607 from rohitsardesai83/automated-cherry-pick-of…
Browse files Browse the repository at this point in the history
…-#563-upstream-release-0.3

Automated cherry pick of #563: Handled the case of invalid action in scheduler module
  • Loading branch information
kubeedge-bot committed May 29, 2019
2 parents 8a2bff7 + 3ffab91 commit ed0f102
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions device/bluetooth_mapper/scheduler/scheduler.go
Expand Up @@ -78,9 +78,11 @@ func (schedule *Schedule) ExecuteSchedule(actionManager []actionmanager.Action,
// performScheduleOperation is responsible for performing the operations associated with the schedule
func (schedule *Schedule) performScheduleOperation(actionManager []actionmanager.Action, dataConverter dataconverter.DataRead, deviceID string) {
var scheduleResult ScheduleResult
actionExists := false
for _, actionName := range schedule.Actions {
for _, action := range actionManager {
if strings.ToUpper(action.Name) == strings.ToUpper(actionName) {
actionExists = true
glog.Infof("Performing scheduled operation: %s", action.Name)
action.PerformOperation(dataConverter)
scheduleResult.EventName = actionName
Expand All @@ -92,6 +94,10 @@ func (schedule *Schedule) performScheduleOperation(actionManager []actionmanager
if schedule.Interval == 0 {
schedule.Interval = defaultEventFrequency
}
if !actionExists {
glog.Error("Action %s does not exist. Exiting from schedule !!!", actionName)
break
}
time.Sleep(time.Duration(time.Duration(schedule.Interval) * time.Millisecond))
}
}
Expand Down

0 comments on commit ed0f102

Please sign in to comment.