diff options
| author | luomengY <2938893385@qq.com> | 2024-01-26 21:22:59 +0800 |
|---|---|---|
| committer | luomengY <2938893385@qq.com> | 2024-04-16 13:33:39 +0800 |
| commit | 5266379f8dc2b81f8a1a8e1f96352f7db87574b2 (patch) | |
| tree | 82cf8d1ff53690c3da79764d04d52000c0dc5180 /edge | |
| parent | Merge pull request #5494 from Shelley-BaoYue/automated-cherry-pick-of-#5493-u... (diff) | |
| download | kubeedge-5266379f8dc2b81f8a1a8e1f96352f7db87574b2.tar.gz | |
fix device status problem with device's namespace in kubeege v1.16.0
Signed-off-by: luomengY <2938893385@qq.com>
Diffstat (limited to 'edge')
| -rw-r--r-- | edge/pkg/devicetwin/process.go | 6 | ||||
| -rw-r--r-- | edge/pkg/devicetwin/process_test.go | 2 | ||||
| -rw-r--r-- | edge/pkg/eventbus/mqtt/client.go | 4 | ||||
| -rw-r--r-- | edge/test/integration/utils/helpers/helpers.go | 2 |
4 files changed, 9 insertions, 5 deletions
diff --git a/edge/pkg/devicetwin/process.go b/edge/pkg/devicetwin/process.go index 05178e569..b4f808a7e 100644 --- a/edge/pkg/devicetwin/process.go +++ b/edge/pkg/devicetwin/process.go @@ -214,7 +214,11 @@ func classifyMsg(message *dttype.DTMessage) bool { } else { identity = splitString[idLoc] loc := strings.Index(topic, identity) - nextLoc := loc + len(identity) + var nextLoc int + if strings.Contains(topic, dtcommon.DeviceETPrefix) { + identity = identity + "/" + splitString[idLoc+1] + } + nextLoc = loc + len(identity) prefix := topic[0:loc] suffix := topic[nextLoc:] klog.Infof("%s %s", prefix, suffix) diff --git a/edge/pkg/devicetwin/process_test.go b/edge/pkg/devicetwin/process_test.go index 6d35fde38..50ab9392f 100644 --- a/edge/pkg/devicetwin/process_test.go +++ b/edge/pkg/devicetwin/process_test.go @@ -397,7 +397,7 @@ func Test_classifyMsg(t *testing.T) { otherTopic := "/membership/detail/result" otherEncodedTopic := base64.URLEncoding.EncodeToString([]byte(otherTopic)) //Encoded eventbus resource - eventbusTopic := "$hw/events/device/+/state/update" + eventbusTopic := "$hw/events/device/+/+/state/update" eventbusResource := base64.URLEncoding.EncodeToString([]byte(eventbusTopic)) content := testutil.GenerateAddDevicePalyloadMsg(t) diff --git a/edge/pkg/eventbus/mqtt/client.go b/edge/pkg/eventbus/mqtt/client.go index 760380076..898b952be 100644 --- a/edge/pkg/eventbus/mqtt/client.go +++ b/edge/pkg/eventbus/mqtt/client.go @@ -42,8 +42,8 @@ var ( // SubTopics which edge-client should be sub SubTopics = []string{ "$hw/events/upload/#", - "$hw/events/device/+/state/update", - "$hw/events/device/+/twin/+", + "$hw/events/device/+/+/state/update", + "$hw/events/device/+/+/twin/+", "$hw/events/node/+/membership/get", UploadTopic, "+/user/#", diff --git a/edge/test/integration/utils/helpers/helpers.go b/edge/test/integration/utils/helpers/helpers.go index 48ec24181..fb8e1590e 100644 --- a/edge/test/integration/utils/helpers/helpers.go +++ b/edge/test/integration/utils/helpers/helpers.go @@ -82,7 +82,7 @@ type TwinAttribute struct { } func GenerateDeviceID(deviceSuffix string) string { - return deviceSuffix + edge.GetRandomString(10) + return "default/" + deviceSuffix + edge.GetRandomString(10) } // Function to Generate Device |
