Skip to content
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

Merged
merged 7 commits into from
Oct 24, 2022

Conversation

cheukt
Copy link
Member

@cheukt cheukt commented Oct 24, 2022

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

@@ -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)
Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Ohh cool, Makes sense!

Copy link
Member

@Kschappacher Kschappacher left a 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

@@ -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)
Copy link
Member

Choose a reason for hiding this comment

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

nit: remote not available

Copy link
Member Author

Choose a reason for hiding this comment

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

updated

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)
Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

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

it doesn't - updated

@@ -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"),
Copy link
Member

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

Copy link
Member Author

Choose a reason for hiding this comment

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

updated

@@ -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"),
Copy link
Member

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

Copy link
Member Author

Choose a reason for hiding this comment

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

updated

Copy link
Member

@npmenard npmenard left a 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.

@cheukt cheukt merged commit 240d1b5 into viamrobotics:main Oct 24, 2022
@cheukt cheukt deleted the save-resource-error branch October 24, 2022 16:38
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.

3 participants