Skip to content

Commit

Permalink
Merge pull request #1614 from cloudxxx8/issue-1613
Browse files Browse the repository at this point in the history
fix: Don't run auto events for empty profile
  • Loading branch information
jinlinGuan authored Aug 19, 2024
2 parents 53be428 + f35974c commit 55ceb93
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion internal/autoevent/manager.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// -*- Mode: Go; indent-tabs-mode: t -*-
//
// Copyright (C) 2019-2020 IOTech Ltd
// Copyright (C) 2019-2024 IOTech Ltd
//
// SPDX-License-Identifier: Apache-2.0

Expand Down Expand Up @@ -69,6 +69,10 @@ func (m *manager) StartAutoEvents() {
defer m.mutex.Unlock()

for _, d := range cache.Devices().All() {
if len(d.ProfileName) == 0 || d.AdminState == models.Locked {
// don't run the auto event if the device doesn't define the profile, or it is locked
continue
}
if _, ok := m.executorMap[d.Name]; !ok {
executors := m.triggerExecutors(d.Name, d.AutoEvents, m.dic)
m.executorMap[d.Name] = executors
Expand Down Expand Up @@ -102,6 +106,11 @@ func (m *manager) RestartForDevice(deviceName string) {
lc.Errorf("failed to find device %s in cache to start AutoEvent", deviceName)
}

if len(d.ProfileName) == 0 || d.AdminState == models.Locked {
// don't run the auto event if the device doesn't define the profile, or it is locked
return
}

m.mutex.Lock()
defer m.mutex.Unlock()
executors := m.triggerExecutors(deviceName, d.AutoEvents, m.dic)
Expand Down

0 comments on commit 55ceb93

Please sign in to comment.