Skip to content

MEN-9997: Fix inconsistencies in deviceauth status handlers - #2138

Open
alfrunes wants to merge 13 commits into
mendersoftware:mainfrom
alfrunes:MEN-9997
Open

MEN-9997: Fix inconsistencies in deviceauth status handlers#2138
alfrunes wants to merge 13 commits into
mendersoftware:mainfrom
alfrunes:MEN-9997

Conversation

@alfrunes

@alfrunes alfrunes commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Fixes inconsistencies and removes duplicated lookups and adds race protection for status updates.
It also expands the webhook context for status update events.
Implementation note:

  • I have purposely avoid changing the inputs of the provision_device workflow to avoid breaking changes / creating a new workflow.
  • The inventory "Provision Device" internal API is now unused and can be removed in a future version in favor of the internal status update API.
  • provision_device workflow is now a superset of update_device_status workflow and now triggers both provision and status update event in iot-manager (therefore only one of the workflow is called on status changes).

Please follow the commits while reviewing as they also provide more context.

Signed-off-by: Alf-Rune Siqveland <alf.rune@northern.tech>
Test was passing due to flawed error handling.

Signed-off-by: Alf-Rune Siqveland <alf.rune@northern.tech>
@mender-test-bot

Copy link
Copy Markdown
Contributor

Merging these commits will result in the following changelog entries:

Changelogs

mender-server (MEN-9997)

New changes in mender-server since main:

Features
  • device-status-changed webhook event contains auth set

    Only decommission events does not carry auth sets.

@alfrunes
alfrunes force-pushed the MEN-9997 branch 3 times, most recently from a0be37a to 6f1e1a6 Compare August 5, 2026 08:50
@codecov

codecov Bot commented Aug 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.88525% with 24 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
backend/services/deviceauth/devauth/devauth.go 84.86% 14 Missing and 9 partials ⚠️
backend/services/deviceauth/model/device.go 94.11% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@alfrunes alfrunes changed the title MEN-9997: Fix inconsistencies in deviceauth status handlers 🚧 MEN-9997: Fix inconsistencies in deviceauth status handlers Aug 5, 2026
@alfrunes
alfrunes force-pushed the MEN-9997 branch 2 times, most recently from e110c6d to b4f649a Compare August 5, 2026 11:46
Most caller contexts already fetched the device. Changed signature to
accept device instead of deviceID and "currentStatus".

Signed-off-by: Alf-Rune Siqveland <alf.rune@northern.tech>
Refactoring made more use of the mocked data which caused several tests
to fail due to lack of data in the return arguments.

Signed-off-by: Alf-Rune Siqveland <alf.rune@northern.tech>
Signed-off-by: Alf-Rune Siqveland <alf.rune@northern.tech>
…atus

Lower cyclomatic complexity and improve readability.

Signed-off-by: Alf-Rune Siqveland <alf.rune@northern.tech>
Only update the device status and trigger the event if device has the
correct revision (entity tag) in the database.

Ticket: MEN-9997
Signed-off-by: Alf-Rune Siqveland <alf.rune@northern.tech>
@alfrunes
alfrunes force-pushed the MEN-9997 branch 3 times, most recently from 3df2f0b to 074e40c Compare August 6, 2026 12:28
Only decommission events does not carry auth sets.

Changelog: Commit
Signed-off-by: Alf-Rune Siqveland <alf.rune@northern.tech>
Updated provision device to use status endpoint instead of POST /devices
API since the former uses the revision to protect concurrent updates.
Removed the duplicate code paths for updating device statuses.

Signed-off-by: Alf-Rune Siqveland <alf.rune@northern.tech>
Signed-off-by: Alf-Rune Siqveland <alf.rune@northern.tech>
Signed-off-by: Alf-Rune Siqveland <alf.rune@northern.tech>
The test would bail out early due to the mock always returning the same
status.

Signed-off-by: Alf-Rune Siqveland <alf.rune@northern.tech>
Signed-off-by: Alf-Rune Siqveland <alf.rune@northern.tech>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants