-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
update for the go-ipfs-cmds refactor #5035
Conversation
8d7381a
to
2daf766
Compare
473884a
to
9cd9bd4
Compare
@Stebalien sharness test The issue is that after adding a file through the urlstore, the subsequent The furthest I have traced the error is that it is returned by a promise in the I'm pretty puzzled and meandering through unfamiliar code, so I thought you might have an idea where that issue might come from. |
The answer is: not your bug, your patch just makes us correctly report errors. I'll look into it. |
That did the trick, thanks! 🌈 |
d1e73de
to
57e7b62
Compare
@Stebalien I removed the remaining debug output and rebased to master. This is now ready for review. |
cmd/ipfs/daemon.go
Outdated
// Inject metrics before we do anything | ||
err := mprome.Inject() | ||
if err != nil { | ||
log.Errorf("Injecting prometheus handler for metrics failed with message: %s\n", err.Error()) | ||
return fmt.Errorf("Injecting prometheus handler for metrics failed with message %s", err.Error()) |
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.
Don't want to return here. This can fail for various reasons.
if ch, ok := out.(chan interface{}); ok { | ||
out = (<-chan interface{})(ch) | ||
// don't emit nil or Single{nil} | ||
if out == nil || out == (cmds.Single{Value: nil}) { |
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.
Is not emitting nil
correct?
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 reason I did this is that I had some command sometimes emit a nil at the beginning. This led to the http response emitter call the preamble with nil, which led to wrong state in the http response. I don't see a reason to actually send nils, so I figured it's easiest to just ignore them. I don't remember which command that was, though.
Do you think this is wrong?
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'm worried we should be closing the output (if we're emitting a Single
). However, this is probably fine (we'll close anyways).
core/commands/files.go
Outdated
|
||
_, err := statGetFormatOptions(req) | ||
if err != nil { | ||
res.SetError(err, cmdkit.ErrClient) | ||
// REVIEW NOTE: We didn't return here before, was that correct? | ||
return cmdkit.Errorf(cmdkit.ErrClient, err.Error()) |
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 like a bug.
core/commands/files.go
Outdated
} | ||
|
||
defer func() { | ||
err := wfd.Close() | ||
if err != nil { | ||
re.SetError(err, cmdkit.ErrNormal) | ||
re.CloseWithError(cmdkit.Errorf(cmdkit.ErrNormal, err.Error())) |
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.
Be careful not to swallow any errors that may have caused this condition. We should probably:
- Use a named return value.
- Store the close error in, e.g.,
err2
. - Replace the returned error if it's nil.
Sound reasonable?
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 so. Is this what you had in mind?
core/commands/get.go
Outdated
if !ok { | ||
// TODO or just return the error here? | ||
log.Error(e.New(e.TypeErr(outReader, v))) | ||
return nil |
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.
Return the error (IMO).
} | ||
select { | ||
case <-time.After(interval): | ||
case <-req.Context.Done(): | ||
return | ||
break |
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.
return req.Context.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.
That would return an error and non-zero exit code to the user, even though everything was in order. Do you think this is a good idea?
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, I see. You're right.
core/commands/urlstore.go
Outdated
} | ||
|
||
cmds.EmitOnce(res, BlockStat{ | ||
err = cmds.EmitOnce(res, &BlockStat{ |
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.
Can return directly.
@@ -26,6 +26,7 @@ fi | |||
# it's too late to pass in --verbose, and --verbose is harder | |||
# to pass through in some cases. | |||
test "$TEST_VERBOSE" = 1 && verbose=t | |||
test "$TEST_IMMEDIATE" = 1 && immediate=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.
?
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 yeah, if you want we can remove this, but in that case I'd open a new PR for this.
When running single tests, I usually run them with ./txxxx-foo-bar.sh -v -i
, which results in the test aborting immediately after an error. This makes finding the failing test in a large test file a lot easier. For some reason this behaviour could not be set using the env, meaning that it could not be used when invoked with make
. This line allows enabling this mode using TEST_IMMEDIATE=1 make
.
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.
Got it, sounds useful, let's keep it (although we should probably document it in the sharness readme).
@keks: This has been unblocked. Once this is finished, we can merge ipfs/go-ipfs-cmds#112 and ship it. |
@Stebalien The sharness test t0252 consistently fails:
I can't tell whether this is because of something else of my changes. I don't really see a connection. Also, sometimes the robust repo gc (t0087) fails, but I got used to that one. |
The test was broken. I've fixed it. |
core/commands/filestore.go
Outdated
} | ||
r, ok := v.(*filestore.ListRes) | ||
if !ok { | ||
// TODO or just return that error? why didn't we do that before? |
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.
@Stebalien What do you think should we do here?
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.
Yes. I'm not sure why we didn'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.
LGTM modulo the gc change.
core/commands/repo.go
Outdated
@@ -99,7 +99,7 @@ order to reclaim hard disk space. | |||
} | |||
} | |||
if errs { | |||
res.SetError(fmt.Errorf("encountered errors during gc run"), cmdkit.ErrNormal) | |||
outChan <- &GcResult{Error: "encountered errors during gc run"} |
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 we actually want to return the error here. We spit out errors as we encounter them but this is supposed to cause the command to exit with an exit status of 1.
We should probably just switch this command away from the legacy commands system. Then we can drop the goroutine and just emit the values normally.
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.
Yeah, not sure what I was thinking here...
Fixing the gc command should fix travis. I'm not sure why jenkins didn't fail... |
As far as I can see the issue is that it doesn't report all gc errors (some of the |
Looks like making |
@keks LGTM but I'd like @magik6k to take a look. @magik6k Any feedback and/or objections to these changes? I've done a pretty thorough code review (don't feel like you need to do a line-by-line audit) but I'd like to get a final sign-off from you before we actually merge this into go-ipfs. Summary:
|
excerpt of commit messages: - update postrun functions in core/commands - sharness: allow setting -i with TEST_IMMEDIATE=1 - cmds Run func returns error now - gx update cmdkit to 1.1.2 and cmds to 2.0.0-beta1 License: MIT Signed-off-by: keks <keks@cryptoscope.co>
License: MIT Signed-off-by: keks <keks@cryptoscope.co>
License: MIT Signed-off-by: keks <keks@cryptoscope.co>
License: MIT Signed-off-by: keks <keks@cryptoscope.co>
`ipfs refs` won't work because we don't have the referenced objects (ipfs refs fetches everything it prints). License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>
License: MIT Signed-off-by: keks <keks@cryptoscope.co>
License: MIT Signed-off-by: keks <keks@cryptoscope.co>
License: MIT Signed-off-by: keks <keks@cryptoscope.co>
License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>
0ae5413
to
b7484c1
Compare
License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>
🎉 🎉 🎉 |
🎉 🎊 |
update for the go-ipfs-cmds refactor This commit was moved from ipfs/kubo@3538257
This branch contains changes to go-ipfs so we can use it with this branch of go-ipfs-cmds: ipfs/go-ipfs-cmds#112