Skip to content

Commit

Permalink
fix(rule): must reload topo when rule start
Browse files Browse the repository at this point in the history
Fix the problem when rule stops by error, topo is not refreshed at starting

Signed-off-by: Jiyong Huang <[email protected]>
  • Loading branch information
ngjaying committed Jan 13, 2023
1 parent 72d0f56 commit 4d4fcf8
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions internal/topo/rule/ruleState.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022 EMQ Technologies Co., Ltd.
// Copyright 2022-2023 EMQ Technologies Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -219,14 +219,18 @@ func (rs *RuleState) Start() error {
if rs.triggered == -1 {
return fmt.Errorf("rule %s is already deleted", rs.RuleId)
}
if rs.Topology == nil {
if rs.triggered != 1 {
// If the rule has been stopped due to error, the topology is not nil
if rs.Topology != nil {
rs.Topology.Cancel()
}
if tp, err := planner.Plan(rs.Rule); err != nil {
return err
} else {
rs.Topology = tp
}
} // else start after create
rs.triggered = 1
rs.triggered = 1
}
rs.ActionCh <- ActionSignalStart
return nil
}
Expand Down

0 comments on commit 4d4fcf8

Please sign in to comment.