-
Notifications
You must be signed in to change notification settings - Fork 111
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-474 Save resource error when not started #1514
Conversation
@@ -554,7 +554,7 @@ func (r *localRobot) newResource(ctx context.Context, config config.Component) ( | |||
} | |||
|
|||
if err != nil { | |||
return nil, errors.Errorf("error building resource %s/%s/%s: %s", config.Model, rName.Subtype, config.Name, 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.
Do we really want to remove all the identifying descriptors here? I can imagine a case where these errors may be hard to debug especially if you have two components with same subtype and model.
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.
moved it to https://github.com/viamrobotics/rdk/pull/1514/files#diff-77fd7ff51c1b7804c67c4df0a9a672ea0e3842b4a54bbd8ef81af82ac95c4f22R368-R369 so all errors from that function gets the additional info
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.
Ohh cool, Makes sense!
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.
One standing question but otherwise LGTM
robot/impl/resource_manager.go
Outdated
@@ -514,7 +520,11 @@ func (manager *resourceManager) RemoteByName(name string) (robot.Robot, bool) { | |||
if iface, ok := manager.resources.Node(rName); ok { | |||
part, ok := iface.(robot.Robot) | |||
if !ok { | |||
manager.logger.Errorw("tried to access remote but its not a robot interface", "remote_name", name, "type", iface) | |||
if ph, ok := iface.(*resourcePlaceholder); ok { | |||
manager.logger.Errorw("failed to get remote", "remote", name, "err", ph.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.
nit: remote not available
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.
updated
robot/impl/resource_manager.go
Outdated
if ph, ok := iface.(*resourcePlaceholder); ok { | ||
manager.logger.Errorw("failed to get remote", "remote", name, "err", ph.err) | ||
} else { | ||
manager.logger.Errorw("tried to access remote but its not a robot interface", "remote", name, "type", iface) |
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.
are we going to get the relevant Type info without using %T?
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 doesn't - updated
robot/impl/resource_manager.go
Outdated
@@ -630,6 +641,7 @@ func (manager *resourceManager) wrapResource(name resource.Name, config interfac | |||
wrapper = &resourcePlaceholder{ | |||
real: part, | |||
config: config, | |||
err: errors.New("resource being initialized"), |
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.
nit: resource not initialized yet
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.
updated
robot/impl/resource_manager.go
Outdated
@@ -564,6 +574,7 @@ func (manager *resourceManager) markChildrenForUpdate(ctx context.Context, rName | |||
wrapper := &resourcePlaceholder{ | |||
real: nil, | |||
config: originalConfig, | |||
err: errors.New("resource marked for update"), |
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.
nit: resource not updated yet
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.
updated
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 couples of nits.
saves the error to the wrapper, which is returned when we try to access that resource.
Also updated some errors and logging to always return resource name + model if applicable