Skip to content

Commit

Permalink
Merge pull request kubeedge#5523 from tangming1996/bugfix/device
Browse files Browse the repository at this point in the history
fix device mapper data collecting cycle calculation error
  • Loading branch information
kubeedge-bot authored Jul 17, 2024
2 parents 53265dd + 7ea7a53 commit c5bf2a4
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions docs/proposals/device-crd-v1beta1.md
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,8 @@ spec:
nodeName: worker-node1
properties:
- name: temp
collectCycle: 2000
reportCycle: 2000
collectCycle: 2000 # 2000 stands for 2000 milliseconds (2 seconds)
reportCycle: 2000 # 2000 stands for 2000 milliseconds (2 seconds)
desired:
value: "30"
reportToCloud: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"time"

"k8s.io/klog/v2"

"github.com/kubeedge/Template/driver"
"github.com/kubeedge/mapper-framework/pkg/common"
)
Expand All @@ -37,7 +36,7 @@ func DataHandler(ctx context.Context, twin *common.Twin, client *driver.Customiz
klog.Errorf("init database client err: %v", err)
return
}
reportCycle := time.Duration(twin.Property.ReportCycle)
reportCycle := time.Millisecond * time.Duration(twin.Property.ReportCycle)
if reportCycle == 0 {
reportCycle = common.DefaultReportCycle
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func DataHandler(ctx context.Context, twin *common.Twin, client *driver.Customiz
klog.Errorf("init redis database client err: %v", err)
return
}
reportCycle := time.Duration(twin.Property.ReportCycle)
reportCycle := time.Millisecond * time.Duration(twin.Property.ReportCycle)
if reportCycle == 0 {
reportCycle = common.DefaultReportCycle
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func DataHandler(ctx context.Context, twin *common.Twin, client *driver.Customiz
klog.Errorf("init database client err: %v", err)
return
}
reportCycle := time.Duration(twin.Property.ReportCycle)
reportCycle := time.Millisecond * time.Duration(twin.Property.ReportCycle)
if reportCycle == 0 {
reportCycle = common.DefaultReportCycle
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func dataHandler(ctx context.Context, dev *driver.CustomizedDev) {
ObservedDesired: twin.ObservedDesired,
VisitorConfig: &visitorConfig,
Topic: fmt.Sprintf(common.TopicTwinUpdate, dev.Instance.ID),
CollectCycle: time.Duration(twin.Property.CollectCycle),
CollectCycle: time.Millisecond * time.Duration(twin.Property.CollectCycle),
ReportToCloud: twin.Property.ReportToCloud,
}
go twinData.Run(ctx)
Expand Down Expand Up @@ -196,7 +196,7 @@ func pushHandler(ctx context.Context, twin *common.Twin, client *driver.Customiz
klog.Errorf("init publish method err: %v", err)
return
}
reportCycle := time.Duration(twin.Property.ReportCycle)
reportCycle := time.Millisecond * time.Duration(twin.Property.ReportCycle)
if reportCycle == 0 {
reportCycle = common.DefaultReportCycle
}
Expand Down

0 comments on commit c5bf2a4

Please sign in to comment.