Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: log sync errors #509

Merged
merged 1 commit into from
Feb 27, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions internal/netbox/inventory/add_items.go
Original file line number Diff line number Diff line change
Expand Up @@ -1171,6 +1171,7 @@ func (nbi *NetboxInventory) AddVM(ctx context.Context, newVM *objects.VM) (*obje
)
patchedVM, err := service.Patch[objects.VM](ctx, nbi.NetboxAPI, oldVM.ID, diffMap)
if err != nil {
nbi.Logger.Errorf(ctx, "Error while patching %s : %s", newVM.Name, err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should rather be:

if err != nil {
  return nil, fmt.Errorf("error patching %s: %s", newVM.Name, err)
} 

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can give it a try but I'm afraid it won't solve my issue which is I only have 1 error reported by cluster :

2025/02/26 20:01:30 main.go:117         ERROR   (cluster0.corp): failed to sync vmware VM foo.bar: unexpected status code: 400: {"disk":["The specified disk size (135000) must match the aggregate size of assigned virtual disks (135659)."]}
2025/02/26 20:01:30 main.go:117         ERROR   (cluster1.corp): failed to sync vmware VM foo.bar: unexpected status code: 400: {"disk":["The specified disk size (844000) must match the aggregate size of assigned virtual disks (844711)."]}
2025/02/26 20:01:30 main.go:117         ERROR   (cluster2.corp): failed to sync vmware VM foo.bar: unexpected status code: 400: {"disk":["The specified disk size (844000) must match the aggregate size of assigned virtual disks (844711)."]}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this is because the sync of an external source fails on the first error.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the solution for this whole problem is that, netbox-ssot takes care of vm disks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this is because the sync of an external source fails on the first error.

I'm not sure this is the case. In the logs I have :

2025/02/26 22:45:47 add_items.go:1174   ERROR   (cluster2.corp): Error while patching foo.bar : unexpected status code: 400: {"disk":["The specified disk size (844000) must match the aggregate size of assigned virtual disks (844711)."]}
2025/02/26 22:46:01 add_items.go:1174   ERROR   (cluster1.corp): Error while patching foo.bar : unexpected status code: 400: {"disk":["The specified disk size (844000) must match the aggregate size of assigned virtual disks (844711)."]}
2025/02/26 22:46:04 add_items.go:1174   ERROR   (cluster0.corp): Error while patching foo.bar : unexpected status code: 400: {"disk":["The specified disk size (69000) must match the aggregate size of assigned virtual disks (69062)."]}
2025/02/26 22:46:11 add_items.go:1174   ERROR   (cluster0.corp): Error while patching foo.bar : unexpected status code: 400: {"disk":["The specified disk size (39000) must match the aggregate size of assigned virtual disks (39062)."]}
2025/02/26 22:46:12 add_items.go:1174   ERROR   (cluster0.corp): Error while patching foo.bar : unexpected status code: 400: {"disk":["The specified disk size (239000) must match the aggregate size of assigned virtual disks (239062)."]}
2025/02/26 22:46:12 add_items.go:1174   ERROR   (cluster0.corp): Error while patching foo.bar : unexpected status code: 400: {"disk":["The specified disk size (149000) must match the aggregate size of assigned virtual disks (149062)."]}
2025/02/26 22:46:14 add_items.go:1174   ERROR   (cluster0.corp): Error while patching foo.bar : unexpected status code: 400: {"disk":["The specified disk size (39000) must match the aggregate size of assigned virtual disks (39062)."]}
2025/02/26 22:46:15 add_items.go:1174   ERROR   (cluster0.corp): Error while patching foo.bar : unexpected status code: 400: {"disk":["The specified disk size (141000) must match the aggregate size of assigned virtual disks (141062)."]}
2025/02/26 22:46:16 add_items.go:1174   ERROR   (cluster0.corp): Error while patching foo.bar : unexpected status code: 400: {"disk":["The specified disk size (208000) must match the aggregate size of assigned virtual disks (208490)."]}
2025/02/26 22:46:17 add_items.go:1174   ERROR   (cluster0.corp): Error while patching foo.bar : unexpected status code: 400: {"disk":["The specified disk size (825000) must match the aggregate size of assigned virtual disks (25000)."]}
2025/02/26 22:46:19 main.go:117         ERROR   (cluster2.corp): failed to sync vmware VM foo.bar: error patching foo.bar: unexpected status code: 400: {"disk":["The specified disk size (844000) must match the aggregate size of assigned virtual disks (844711)."]}
2025/02/26 22:46:19 add_items.go:1174   ERROR   (cluster0.corp): Error while patching foo.bar : unexpected status code: 400: {"disk":["The specified disk size (278000) must match the aggregate size of assigned virtual disks (278828)."]}
2025/02/26 22:46:19 add_items.go:1174   ERROR   (cluster0.corp): Error while patching foo.bar : unexpected status code: 400: {"disk":["The specified disk size (239000) must match the aggregate size of assigned virtual disks (239062)."]}
2025/02/26 22:46:20 add_items.go:1174   ERROR   (cluster0.corp): Error while patching foo.bar : unexpected status code: 400: {"disk":["The specified disk size (239000) must match the aggregate size of assigned virtual disks (239062)."]}
2025/02/26 22:46:21 add_items.go:1174   ERROR   (cluster0.corp): Error while patching foo.bar : unexpected status code: 400: {"disk":["The specified disk size (39000) must match the aggregate size of assigned virtual disks (39062)."]}
2025/02/26 22:46:21 add_items.go:1174   ERROR   (cluster0.corp): Error while patching foo.bar : unexpected status code: 400: {"disk":["The specified disk size (239000) must match the aggregate size of assigned virtual disks (239062)."]}
2025/02/26 22:46:25 add_items.go:1174   ERROR   (cluster0.corp): Error while patching foo.bar : unexpected status code: 400: {"disk":["The specified disk size (539000) must match the aggregate size of assigned virtual disks (539062)."]}
2025/02/26 22:46:26 add_items.go:1174   ERROR   (cluster0.corp): Error while patching foo.bar : unexpected status code: 400: {"disk":["The specified disk size (135000) must match the aggregate size of assigned virtual disks (135659)."]}
2025/02/26 22:46:26 add_items.go:1174   ERROR   (cluster0.corp): Error while patching foo.bar : unexpected status code: 400: {"disk":["The specified disk size (439000) must match the aggregate size of assigned virtual disks (439062)."]}
2025/02/26 22:46:31 add_items.go:1174   ERROR   (cluster0.corp): Error while patching foo.bar : unexpected status code: 400: {"disk":["The specified disk size (89000) must match the aggregate size of assigned virtual disks (89062)."]}
2025/02/26 22:46:31 add_items.go:1174   ERROR   (cluster0.corp): Error while patching foo.bar : unexpected status code: 400: {"disk":["The specified disk size (239000) must match the aggregate size of assigned virtual disks (239062)."]}
2025/02/26 22:46:32 main.go:117         ERROR   (cluster1.corp): failed to sync vmware VM foo.bar: error patching foo.bar: unexpected status code: 400: {"disk":["The specified disk size (844000) must match the aggregate size of assigned virtual disks (844711)."]}
2025/02/26 22:46:36 add_items.go:1174   ERROR   (cluster0.corp): Error while patching foo.bar : unexpected status code: 400: {"disk":["The specified disk size (239000) must match the aggregate size of assigned virtual disks (239062)."]}
2025/02/26 22:46:37 add_items.go:1174   ERROR   (cluster0.corp): Error while patching foo.bar : unexpected status code: 400: {"disk":["The specified disk size (39000) must match the aggregate size of assigned virtual disks (39062)."]}
2025/02/26 22:46:38 add_items.go:1174   ERROR   (cluster0.corp): Error while patching foo.bar : unexpected status code: 400: {"disk":["The specified disk size (105000) must match the aggregate size of assigned virtual disks (105062)."]}
2025/02/26 22:46:40 add_items.go:1174   ERROR   (cluster0.corp): Error while patching foo.bar : unexpected status code: 400: {"disk":["The specified disk size (141000) must match the aggregate size of assigned virtual disks (141062)."]}
2025/02/26 22:46:41 add_items.go:1174   ERROR   (cluster0.corp): Error while patching foo.bar : unexpected status code: 400: {"disk":["The specified disk size (1249000) must match the aggregate size of assigned virtual disks (1249062)."]}
2025/02/26 22:46:43 add_items.go:1174   ERROR   (cluster0.corp): Error while patching foo.bar : unexpected status code: 400: {"disk":["The specified disk size (239000) must match the aggregate size of assigned virtual disks (239062)."]}
2025/02/26 22:46:45 add_items.go:1174   ERROR   (cluster0.corp): Error while patching foo.bar : unexpected status code: 400: {"disk":["The specified disk size (105000) must match the aggregate size of assigned virtual disks (105062)."]}
2025/02/26 22:46:46 add_items.go:1174   ERROR   (cluster0.corp): Error while patching foo.bar : unexpected status code: 400: {"disk":["The specified disk size (439000) must match the aggregate size of assigned virtual disks (439062)."]}
2025/02/26 22:46:48 add_items.go:1174   ERROR   (cluster0.corp): Error while patching foo.bar : unexpected status code: 400: {"disk":["The specified disk size (249000) must match the aggregate size of assigned virtual disks (249062)."]}
2025/02/26 22:46:53 add_items.go:1174   ERROR   (cluster0.corp): Error while patching foo.bar : unexpected status code: 400: {"disk":["The specified disk size (135000) must match the aggregate size of assigned virtual disks (135062)."]}
2025/02/26 22:46:54 add_items.go:1174   ERROR   (cluster0.corp): Error while patching foo.bar : unexpected status code: 400: {"disk":["The specified disk size (1039000) must match the aggregate size of assigned virtual disks (1039062)."]}
2025/02/26 22:46:54 add_items.go:1174   ERROR   (cluster0.corp): Error while patching foo.bar : unexpected status code: 400: {"disk":["The specified disk size (539000) must match the aggregate size of assigned virtual disks (539062)."]}
2025/02/26 22:47:01 add_items.go:1174   ERROR   (cluster0.corp): Error while patching foo.bar : unexpected status code: 400: {"disk":["The specified disk size (319000) must match the aggregate size of assigned virtual disks (319688)."]}
2025/02/26 22:47:04 main.go:117         ERROR   (cluster0.corp): failed to sync vmware VM foo.bar: error patching dev-data01.mar02: unexpected status code: 400: {"disk":["The specified disk size (69000) must match the aggregate size of assigned virtual disks (69062)."]}

return nil, err
}
nbi.vmsIndexByNameAndClusterID[newVM.Name][newVMClusterID] = patchedVM
Expand Down
Loading