Skip to content

internal API for fetching MgsUpdateDriver status does not work#8475

Merged
davepacheco merged 4 commits intomainfrom
dap/pending-mgs-serialize-bug
Jun 30, 2025
Merged

internal API for fetching MgsUpdateDriver status does not work#8475
davepacheco merged 4 commits intomainfrom
dap/pending-mgs-serialize-bug

Conversation

@davepacheco
Copy link
Copy Markdown
Collaborator

While debugging #8466, I tried to fetch the status from the MgsUpdateDriver, but it returned a 500 error. The Nexus log showed:

00:12:13.903Z INFO bea4cc1e-0758-4643-a4b4-669f67689c6c (dropshot_internal): request completed
    error_message_external = Internal Server Error
    error_message_internal = key must be a string
    file = /home/build/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/dropshot-0.16.2/src/server.rs:855
    latency_us = 6461
    local_addr = [fd00:1122:3344:102::4]:12221
    method = GET
    remote_addr = [fd00:1122:3344:103::2]:47733
    req_id = 3c6fc474-7d95-4eb1-ae18-da944fb176ff
    response_code = 500
    uri = /mgs-updates

This is a serde serialization error being reported when dropshot tries to serialize the return value. The problem is that this structures has a BTreeMap whose key is a BaseboardId, which does not itself serialize to a string. Elsewhere when we needed this, we switched to an IdMap anyway. That serializes to an array of objects, which avoids this problem. Here, I've switched it to an iddqd::IdOrdMap.

This PR currently has two commits:

  • The first one adds a test that shows that the serialization of MgsUpdateDriverStatus doesn't work.
  • The second one fixes it by fixing the structure to use an IdOrdMap instead.

@davepacheco davepacheco requested a review from sunshowers June 27, 2025 23:18
Copy link
Copy Markdown
Contributor

@sunshowers sunshowers left a comment

Choose a reason for hiding this comment

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

looks good, thanks!

},
);
})
.unwrap();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

add expect here?

}

impl IdOrdItem for WaitingStatus {
type Key<'a> = &'a Arc<BaseboardId>;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can just be &'a BaseboardId I think

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

(I think the Arc was added to allow cheap cloning for keys in IdMaps. Since iddqd can work with borrowed forms, it shouldn't really be necessary
to have Arc at all once all users have moved over)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I'm not positive but I don't think so. I'm assuming that would make these structs borrow from somewhere else, but they get sent over a watch channel so I'm not sure how that would work. Also, I think the source of these is MgsUpdateDriver, which also keeps these as Arc, and shares them with the inventory collection that they originally were found in.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hmm, that wouldn't stop this specific spot from being &'a BaseboardId I think?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I see now -- done in #8477.

@davepacheco davepacheco enabled auto-merge (squash) June 30, 2025 13:48
@davepacheco
Copy link
Copy Markdown
Collaborator Author

Thanks for the review!

@davepacheco davepacheco merged commit 31c8803 into main Jun 30, 2025
18 checks passed
@davepacheco davepacheco deleted the dap/pending-mgs-serialize-bug branch June 30, 2025 15:18
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