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

feat: store reconciliation errors in redis #153

Merged
merged 2 commits into from
Aug 9, 2024

Conversation

mfiedorowicz
Copy link
Member

@mfiedorowicz mfiedorowicz commented Aug 9, 2024

Store reconciliation and any other errors occurred when processing ingested data in redis. This will allow us to retrieve ingestion logs and display meaningful details regarding failures.

Example:

{
    "data_type": "dcim.device",
    "entity": {
        "Device": {
            "name": "Conference_Room_AP_02",
            "device_type": {
                "model": "Cisco Aironet 3802",
                "manufacturer": {
                    "name": "Cisco"
                }
            },
            "role": {
                "name": "Wireless_AP"
            },
            "serial": "PQR456789012",
            "site": {
                "name": "HQ"
            },
            "asset_tag": ""
        }
    },
    "error": {
        "Message": "failed to apply change set",
        "Code": 400,
        "Details": {
            "change_set_id": "7667cf0a-6499-4312-ba39-e45118282e7f",
            "result": "failed",
            "errors": [
                {
                    "asset_tag": "asset_tag: Device with this Asset tag already exists.",
                    "change_id": "be011399-17a9-47e8-ac25-16fdd35514f1"
                }
            ]
        }
    },
    "ingestion_ts": 1723191515569084347,
    "producer_app_name": "csv-parser",
    "producer_app_version": "0.0.1",
    "request_id": "328491ce-b2c4-48d9-b8eb-9793ff9f32ef",
    "sdk_name": "diode-sdk-python",
    "sdk_version": "0.0.1",
    "state": 2
}

Also improve logging:

{
    "time": "2024-08-09T08:18:36.24933293Z",
    "level": "WARN",
    "msg": "failed to handle ingest request",
    "errors": [
        "msg: failed to apply change set, code: 400, change set id: a4b65636-19fc-4001-ab4c-e2b582f48d47, result: failed, errors: [{\"asset_tag\":\"asset_tag: Device with this Asset tag already exists.\",\"change_id\":\"78cadf30-b75d-4c58-8f00-e4dc2bdb178b\"}]",
        "msg: failed to apply change set, code: 400, change set id: a8ce7d8e-20fb-4a52-873c-2c071ce5996b, result: failed, errors: [{\"asset_tag\":\"asset_tag: Device with this Asset tag already exists.\",\"change_id\":\"7646dbb9-511a-48da-9d2e-73eb8cae5a80\"}]",
        "msg: failed to apply change set, code: 400, change set id: 7a154db7-3ac8-4194-848d-bab64ed19089, result: failed, errors: [{\"asset_tag\":\"asset_tag: Device with this Asset tag already exists.\",\"change_id\":\"916cf2b9-0273-40c5-87ab-cdb3d8ee8bbe\"}]",
        "msg: failed to apply change set, code: 400, change set id: adccf83a-a651-48b8-81ec-3e3e574d7c59, result: failed, errors: [{\"asset_tag\":\"asset_tag: Device with this Asset tag already exists.\",\"change_id\":\"bcf5dca9-303b-493b-a098-4061bd670b2a\"}]",
        "msg: failed to apply change set, code: 400, change set id: 7667cf0a-6499-4312-ba39-e45118282e7f, result: failed, errors: [{\"asset_tag\":\"asset_tag: Device with this Asset tag already exists.\",\"change_id\":\"be011399-17a9-47e8-ac25-16fdd35514f1\"}]"
    ]
}

Signed-off-by: Michal Fiedorowicz <mfiedorowicz@netboxlabs.com>
Signed-off-by: Michal Fiedorowicz <mfiedorowicz@netboxlabs.com>
Copy link

github-actions bot commented Aug 9, 2024

Go test coverage

STATUS ELAPSED PACKAGE COVER PASS FAIL SKIP
🟢 PASS 1.20s github.com/netboxlabs/diode/diode-server/ingester 6.7% 9 0 0
🟢 PASS 0.01s github.com/netboxlabs/diode/diode-server/netbox 0.0% 0 0 0
🟢 PASS 1.41s github.com/netboxlabs/diode/diode-server/netboxdiodeplugin 9.9% 34 0 0
🟢 PASS 1.38s github.com/netboxlabs/diode/diode-server/reconciler 11.2% 27 0 0
🟢 PASS 1.28s github.com/netboxlabs/diode/diode-server/reconciler/changeset 81.7% 58 0 0
🟢 PASS 1.02s github.com/netboxlabs/diode/diode-server/server 85.7% 14 0 0
🟢 PASS 1.01s github.com/netboxlabs/diode/diode-server/version 100.0% 1 0 0

Total coverage: 83.7%

Copy link
Contributor

@leoparente leoparente left a comment

Choose a reason for hiding this comment

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

LGTM

@mfiedorowicz mfiedorowicz merged commit a3316e5 into develop Aug 9, 2024
6 checks passed
@mfiedorowicz mfiedorowicz deleted the feat/store-reconciliation-errors branch August 9, 2024 11:00
@orb-ci
Copy link

orb-ci commented Sep 5, 2024

🎉 This PR is included in version 0.5.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@orb-ci orb-ci added the released label Sep 5, 2024
@orb-ci
Copy link

orb-ci commented Sep 5, 2024

🎉 This PR is included in version 0.5.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants