-
Notifications
You must be signed in to change notification settings - Fork 110
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
RSDK-8867 - Clear resources from resource collection #4398
Conversation
@@ -365,42 +364,43 @@ func (svc *webService) updateResources(resources map[resource.Name]resource.Reso | |||
groupedResources[n.API] = r | |||
} | |||
|
|||
apiRegs := resource.RegisteredAPIs() | |||
for a, v := range groupedResources { |
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.
definitely a chance for some existing resources to no longer exist and not appear in this list, preventing this function from updating the collection correctly
// TODO(RSDK-144): register new service if it doesn't currently exist | ||
// All known APIs have pre-registered resource collections, so loop through them. We want to empty out any collections if | ||
// there are no longer resources available in that API. | ||
for api, coll := range svc.services { |
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.
the logic here was messy because we allowed the possibility of having a group of resources that do not have a pre-existing resource collection. By removing that path (which was never used anyway), the logic can be generally simplified
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 I follow? Does this mean something like: a robot config hypothetically having a "fake motor" model that it's version of the rdk/viam-server is happy to create and configure. But there was no corresponding motor/server.go
file that registered the "motor API" and create its corresponding "motor resource collection"?
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.
yep - the case is usually for a custom api, and we're adding it to a collection that never gets used anyway
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.
Assuming my interpretations are on point, the new code looks correct/complete to me. Didn't take the time to find the bug in the old code. The new code is way*** more readable.
// TODO(RSDK-144): register new service if it doesn't currently exist | ||
// All known APIs have pre-registered resource collections, so loop through them. We want to empty out any collections if | ||
// there are no longer resources available in that API. | ||
for api, coll := range svc.services { |
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 I follow? Does this mean something like: a robot config hypothetically having a "fake motor" model that it's version of the rdk/viam-server is happy to create and configure. But there was no corresponding motor/server.go
file that registered the "motor API" and create its corresponding "motor resource collection"?
for n := range group { | ||
if !n.ContainsRemoteNames() { | ||
svc.logger.Warnw( | ||
"missing registration for api, resources with this API will be unreachable through a client", "api", n.API) |
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.
Could you explain in what scenario we hit this log?
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.
it may be possible if you added a resource without registering an api for it - I think the baseremotecontrol service for example would hit this
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! Thanks.
cc @michaellee1019 @randhid