Skip to content

Commit

Permalink
Merge pull request #990 from weichou1229/issue-987
Browse files Browse the repository at this point in the history
fix: Fix device service update failed when startup
  • Loading branch information
cloudxxx8 authored Jun 25, 2021
2 parents 5b9873f + 5669c30 commit 785b4de
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/service/manageddevices.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ func (s *DeviceService) UpdateDevice(device models.Device) error {

s.LoggingClient.Debugf("Updating managed Device %s", device.Name)
req := requests.NewUpdateDeviceRequest(dtos.FromDeviceModelToUpdateDTO(device))
req.Device.Id = nil
ctx := context.WithValue(context.Background(), common.CorrelationHeader, uuid.NewString())
_, err := s.edgexClients.DeviceClient.Update(ctx, []requests.UpdateDeviceRequest{req})
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions pkg/service/managedwatchers.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ func (s *DeviceService) UpdateProvisionWatcher(watcher models.ProvisionWatcher)

s.LoggingClient.Debugf("Updating managed ProvisionWatcher: %s", watcher.Name)
req := requests.NewUpdateProvisionWatcherRequest(dtos.FromProvisionWatcherModelToUpdateDTO(watcher))
req.ProvisionWatcher.Id = nil
ctx := context.WithValue(context.Background(), common.CorrelationHeader, uuid.NewString())
_, err := s.edgexClients.ProvisionWatcherClient.Update(ctx, []requests.UpdateProvisionWatcherRequest{req})
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions pkg/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ func (s *DeviceService) selfRegister() errors.EdgeX {
} else {
s.LoggingClient.Infof("device service %s exists, updating it", s.ServiceName)
req := requests.NewUpdateDeviceServiceRequest(dtos.FromDeviceServiceModelToUpdateDTO(localDeviceService))
req.Service.Id = nil
_, err = s.edgexClients.DeviceServiceClient.Update(ctx, []requests.UpdateDeviceServiceRequest{req})
if err != nil {
s.LoggingClient.Errorf("failed to update device service %s with local config: %v", localDeviceService.Name, err)
Expand Down

0 comments on commit 785b4de

Please sign in to comment.