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(orc8r): Update gateway device information during registration #12022
Conversation
Thanks for opening a PR! 💯
Howto
More infoPlease take a moment to read through the Magma project's
If this is your first Magma PR, also consider reading
|
951ddb4
to
4a3c2e9
Compare
4a3c2e9
to
cc9780c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! 2 small things
ent, err := configurator.LoadEntity( | ||
ctx, | ||
networkID, orc8r.MagmadGatewayType, gatewayID, | ||
configurator.EntityLoadCriteria{}, | ||
serdes.Entity, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's a "load entity by physical ID" func
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the func LoadEntityForPhysicalID
gets the entity by the physical ID, but since the gateway is not yet registered to a physical ID, idt it would work... unless there is some load entity by physical ID func u are referencing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh true you're right, I misread "gateway ID" as meaning "hardware ID" -- a +1 for why functions with large # of arguments is an anti-pattern 🙂
status, err := wrappers.GetGatewayStatus(ctx, networkID, ent.PhysicalID) | ||
if err != nil && err != merrors.ErrNotFound { | ||
return err | ||
} | ||
gw := (&models.MagmadGateway{}).FromBackendModels(ent, device, status) | ||
|
||
_, err = configurator.UpdateEntities(ctx, networkID, gw.ToEntityUpdateCriteria(ent), serdes.Entity) | ||
if err != nil { | ||
return err | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be able to do this with the "mutable" version of the gateway object -- i.e. without having to pull/integrate gateway state
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was referencing how the update gateway handlers does it here https://github.com/christinewang5/magma/blob/cc9780ca2f8bef44d42a034ac744af07b7a445aa/orc8r/cloud/go/services/orchestrator/obsidian/handlers/gateway_handlers.go#L340-L362
But I was searching for the mutable version and it seems like there are only models for specific gateway types like cwf, lte, fed, etc. Lmk if there is a way to get the mutable version just for a generic gateway?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah true weird that there isn't a mutable version of the magmad gateway. So let's still do it this way, except -- we can pass in the "status" as nil, since we don't care about that when we update the ent
cc9780c
to
e7d641b
Compare
e7d641b
to
384ef7d
Compare
384ef7d
to
6b96be7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm, just fix the 1 thing where we don't need to read in the gw status
5f36696
to
be6642f
Compare
Signed-off-by: Christine Wang <christinewang@fb.com>
be6642f
to
7c89fc1
Compare
Previously, the gateway was registered to the device service but the gateway itself did not have the updated device info (i.e. hardware id and challenge key, etc.). This caused checkin_cli.py to fail bc the gateway was half registered.
Fixed so that the device field is updated upon calling register.py
Tested by spinning up orc8r, this was after running the register.py script