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

Adder: Make sure errors from addAllAndPin make it to the client #3230

Closed
wants to merge 1 commit into from

Conversation

kevina
Copy link
Contributor

@kevina kevina commented Sep 16, 2016

Before the error would be printed by the daemon but not make it to the
client.

License: MIT
Signed-off-by: Kevin Atkinson k@kevina.org

@kevina kevina added the topic/commands:add Topic commands:add label Sep 16, 2016
@Kubuxu Kubuxu added the status/in-progress In progress label Sep 16, 2016
@kevina kevina changed the title Adder: Make sure errors from addAllAndPin make it to the client RFC: Adder: Make sure errors from addAllAndPin make it to the client Sep 16, 2016
Before the error would be printed by the daemon but not make it to the
client.

License: MIT
Signed-off-by: Kevin Atkinson <k@kevina.org>
@kevina
Copy link
Contributor Author

kevina commented Sep 16, 2016

Not sure if this is the best way to go about fixing this. A better way would be to somehow trigger this case in PostRun:

            case <-req.Context().Done():
                res.SetError(req.Context().Err(), cmds.ErrNormal)
                return
            }

But that doesn't seam possible. However, it could be that I just don't understand the code well enough.

@whyrusleeping
Copy link
Member

This LGTM. I wonder why the error returned there doesnt get propogated to the other side... It does so in other commands

@kevina
Copy link
Contributor Author

kevina commented Sep 20, 2016

@whyrusleeping The problem here is that the Run() function has already returned with non-error status. res.SetError is then called in a go routine. When run without the daemon online this seams to work okay, when run with the daemon the server does not know what to do with the error so it just logs it. There does not appear to be a way to retrieve the error status when run with the daemon online; however, I might be missing something.

Is there another command that does a res.SetError in a go routene? If so, let me know I and will figure out what the problem is in this case.

@whyrusleeping
Copy link
Member

@kevina I think cat does, but i'm not 100% sure really.

@kevina
Copy link
Contributor Author

kevina commented Sep 20, 2016

@whyrusleeping, actually cat doesn't.

I found the problem. The server was sending an error response but the client code in commands/http/client.go was dropping it. Not sure how to fix it. The error is being dropped in readStreamedJson() (see https://github.com/ipfs/go-ipfs/blob/master/commands/http/client.go#L247) because it doesn't know what to do with it as it is launched in a goroutine (see https://github.com/ipfs/go-ipfs/blob/master/commands/http/client.go#L183). Not sure how to fix this.

My recommendation is to merge this and file a bug report for a correct fix, but there code doesn't need to be merged right away.

@kevina kevina changed the title RFC: Adder: Make sure errors from addAllAndPin make it to the client Adder: Make sure errors from addAllAndPin make it to the client Sep 20, 2016
@kevina kevina mentioned this pull request Sep 25, 2016
6 tasks
@kevina kevina removed the status/in-progress In progress label Sep 25, 2016
@whyrusleeping
Copy link
Member

@kevina what if that readStreamedJson call took in the Result object, and when it errors, sets the error on the result object before closing its output channel? That might do the trick

@kevina
Copy link
Contributor Author

kevina commented Sep 29, 2016

@whyrusleeping, that seams to work. Have a look at 2d795b5. I am just not 100% sure why it works...

If you are happy with the new change I will close this pull request and create a new one with the readStreamedJson fix.

BTW: There are tests case for this #2634. I am not really sure how to create a test case for this outside of #2634 as I would have to create an error somehow and make sure it doesn't get dropped.

@whyrusleeping
Copy link
Member

@kevina hrm... I guess i'm fine with waiting on the test cases for that one. Lets go ahead and close this in favor of the other change

kevina added a commit to ipfs-filestore/go-ipfs that referenced this pull request Sep 30, 2016
Better fix than ipfs#3230 to make sure errors from addAllAndPin make it to
the client.

License: MIT
Signed-off-by: Kevin Atkinson <k@kevina.org>
@kevina
Copy link
Contributor Author

kevina commented Sep 30, 2016

Closing in favor of #3276.

@kevina kevina closed this Sep 30, 2016
@Kubuxu Kubuxu deleted the kevina/adder-error branch February 27, 2017 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic/commands:add Topic commands:add
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants