-
Notifications
You must be signed in to change notification settings - Fork 62
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
fix: daemon should recognize previously created repos. #212
Conversation
test/spawn-options.spec.js
Outdated
@@ -141,6 +141,11 @@ describe('Spawn options', () => { | |||
expect(_ipfsd).to.exist() | |||
expect(_ipfsd.api).to.not.exist() | |||
|
|||
// proc nodes do not reuse initialized repos |
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 there is no reason why we can't do this in 'proc' nodes as well.
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.
My thought was that proc nodes always set their initialized
to false (here) so having this check would avoid a failure once an issue with proc nodes (line 122 above) is resolved.
@dryajov Travis is failing on browser tests for my changes. There may be an obvious answer for this, but: how are browser tests being run? When I run
As I understand, aegir looks for a |
Ah! Figured it out. aegir fallsback on all tests with |
@dryajov I've looked into why the browser tests are failing and think it's a bug. The daemon that the browser's DaemonClient is communicating with is The flow is, I think:
Should we instead carry the |
I've just pushed changes for the above problem. Happy to change or revert it if you want me to. There's is a race condition I was running into during browser tests for |
Current status: CI inconsistent but overall Jenkins and Travis show that things are okay. Jenkins passed Windows 9.2 but failed 8.9 with a daemon.stop race condition (shutdown related). Travis passed Node 6 and Node 8 tests passed but coverage failed. A similar thing happened with previous CI: Travis failed during coverage (but on different tests than this time). Ready for review |
Pity that we don't get CircleCi builds - I'm guessing its because this is a PR from a fork. The existing CI issues indeed look "normal" - windows builds fail because of lack of #205 (as you mention). |
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 besides lint.
test/spawn-options.spec.js
Outdated
@@ -137,11 +137,16 @@ describe('Spawn options', () => { | |||
} | |||
|
|||
f.spawn(options, (err, _ipfsd) => { | |||
ipfsd = _ipfsd |
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 believe this will fail lint - can you run npm run lint
on the repo and make sure everything passes please?
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 have and do not see any failures. Were you expecting it to fail because it's assigning a global? ipfsd is defined above, on line 124 so here we are just setting it.
I moved this assignment from below because if any of the below expect
s failed, it would inadvertently cause the next it
s to fail.
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.
Usually eslint will complain if the first line in the callback is not handling the error, but perhaps its OK since it happens right after ipfsd = _ipfsd
. I would still move the assignment below the expects
s since if there was an error _ipfsd
would be null/empty/invalid
.
test/spawn-options.spec.js
Outdated
expect(err).to.not.exist() | ||
expect(_ipfsd).to.exist() | ||
expect(_ipfsd.api).to.not.exist() | ||
|
||
ipfsd = _ipfsd | ||
// proc nodes don't reuse initialized repos | ||
if (fOpts.type !== 'proc') { |
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.
We should add this functionality to proc
nodes - there is no reason they can't do that. But I'm fine if its in another PR. Could you file an issue to add this please?
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.
Ahh cool. I really haven't even looked at in-proc nodes but this is an opportunity. I've filed an issue and am happy to work on it later. #214
@@ -52,7 +52,7 @@ class Daemon { | |||
this.disposable = this.opts.disposable | |||
this.exec = this.opts.exec || process.env.IPFS_EXEC || findIpfsExecutable(this.opts.type, rootPath) | |||
this.subprocess = null | |||
this.initialized = fs.existsSync(path) | |||
this.initialized = fs.existsSync(this.path) |
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.
👍
Codecov Report
@@ Coverage Diff @@
## master #212 +/- ##
=========================================
Coverage ? 87.03%
=========================================
Files ? 17
Lines ? 671
Branches ? 0
=========================================
Hits ? 584
Misses ? 87
Partials ? 0
Continue to review full report at Codecov.
|
I have added the fix for in-proc nodes to this PR: #214. It ended up being a two-liner:
I think that they are in-line with the original intent of this PR. If we'd prefer to separate them, I am happy to revert. Edit: Whoops, didn't run browser tests. Looking into it. |
src/factory-in-proc.js
Outdated
@@ -131,6 +131,7 @@ class FactoryInProc { | |||
const node = new Node(options) | |||
|
|||
series([ | |||
(cb) => node.exec.on('ready', cb), |
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.
please use once
- this event might be triggered several times.
src/ipfsd-in-proc.js
Outdated
@@ -29,11 +30,11 @@ class Node { | |||
this.path = this.opts.repoPath | |||
this.repo = createRepo(this.path) | |||
this.disposable = this.opts.disposable | |||
this.initialized = fs.existsSync(this.path) |
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.
this will fail in the browser, since it wouldn't be a path... Maybe we can use the ipfs-repo
module here to verify it's a repo - tho I've little experience with it.
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.
Whew! Took me a minute to realize we use package.json to define aliases for some files on browsers. That threw me for a loop.
There's a good possibility from ipfs-repo
: _isInitialized(callback)
. I'm about to push something, just running all tests. Lemme know what you think.
src/factory-in-proc.js
Outdated
|
||
node.once('ready', () => { | ||
node.version((err, _version) => { | ||
if (err) { callback(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.
needs return.
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.
Ha! Thanks, you really have an eye for these. Perhaps we could write a lint warning for 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.
@diasdavid Looks like there already is an ESLint rule for this: https://eslint.org/docs/rules/callback-return
Adding a lint rule to aegir would be a big change across our projects but it might be worth it for this one as it's not about style but functionality and could catch bugs. Have you guys looked into it before?
It might be okay to set it with error severity but we would want to pre-run some repos to check. We could alternatively phase it in as a warning and do a fix chore of key repos during that period, bumping it to an error afterwards.
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 say enable the lint rule in aegir as an error and see what happens.
src/factory-in-proc.js
Outdated
node.version((err, _version) => { | ||
if (err) { callback(err) } | ||
callback(null, _version) | ||
}) |
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.
Same comment as #205 (comment)
src/factory-in-proc.js
Outdated
@@ -131,6 +135,19 @@ class FactoryInProc { | |||
const node = new Node(options) | |||
|
|||
series([ | |||
(cb) => node.exec.once('ready', cb), |
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.
same comment as #205 (comment)
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.
Something isn't quite right here. the node is created but then what we listen on the ready event is exec??
@diasdavid Can you rephrase? node.exec
is the IPFS instance being run by the daemon node
. What's going on is that new Node()
instantiates the daemon and returns immediately with a still-booting IPFS instance under exec
. We could ask consumers to wait for their in-proc daemon's IPFS to be ready but that is inconsistent with the go and js factories, which deliver ready instances.
src/factory-in-proc.js
Outdated
try { | ||
node.repo._isInitialized(() => { | ||
node.initialized = true | ||
cb() |
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 not call callbacks within try blocks, it results on any error in the future that gets thrown (in any part of the code) to get caught by this try block
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.
Great! That's good to know
@dryajov looking at the js daemon, if you pass a custom IPFS exec: https://github.com/ipfs/js-ipfsd-ctl/blob/master/src/ipfsd-daemon.js#L53 |
|
@JonKrone can we get master rebased here. It should resolve the concerns that @diasdavid raised. |
… test suite from failing if the first 'it' does. Also trying to run the CI again because I haven't been able to replicate its failure.
…overage. Interested to see if the same thing happens again.
…ready before during spawning.
…ing.\nUse ipfs-repo._isInitialized to determine whether they are or not. I'm curious it throws instead of returning false.
…. It doesn't need a try/catch at all, I mistook the behavior of _isInitialized.
…rned, not invoked.
593ad0b
to
8613d28
Compare
…initialized: true'
PR is up to date. Jenkins failed due to a macos EADDIRINUSE error (has an issue: ipfs-inactive/jenkins#97) but everything else is ✅ I've since re-run CI and hit a couple of different issues:
|
Yeah, we have something weird with aegir itself or the tests it runs that doesn't properly stop resources when it's done and some processes ends up running, so the next run on the same project + worker leads to collisions...
There seems to be some DNS flipping happening with dist.ipfs.io currently, which is why this error is happening, so seems intermittent.
I think windows is just very slow on installing. The 30 minutes sounds like an aweful lot though, I'll look into it. |
@JonKrone please start opening PR from branches from the repo itself to make it simpler to collaborate on a WIP PR. |
Reading the above, LGTM. Great work @JonKrone :) |
While working on some go/js interop tests I noticed that a daemon spawned on an already-initialized repo doesn't report itself as initialized.
It turned out to be just a typo so I fixed that and added a test.
Update
This PR has four fixes related to
proc
node startup:proc
nodes error when reporting their version: hereproc
nodes spawn before their IPFS instance has finished booting: hereproc
nodes do not report themselves as initialized: here