-
Notifications
You must be signed in to change notification settings - Fork 813
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
Health check error message #2649
Health check error message #2649
Conversation
if for some reason agones server connection fails - `healthStream.write` throws error that I fail to catch but at least we can show source of error
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Nice addition! Could you check coverage with |
@steven-supersolid recheck please, if it's ok to make health() function to be able to take optional errorCallback? |
Build Failed 😱 Build Id: 4dc8857c-51f1-48b6-815d-0314335b66ec To get permission to view the Cloud Build view, join the agones-discuss Google Group. |
e2e feature gates - that's a new one, but looks unrelated to the change at hand. |
sdks/nodejs/spec/agonesSDK.spec.js
Outdated
return stream; | ||
}); | ||
try { | ||
agonesSDK.health(() => {}); |
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 may be worth adding an expect in here to test/demonstrate that the error is passed to the callback intact.
Could spy on the callback and I think and check what it was called with
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.
done
fail(); | ||
} | ||
}); | ||
it('calls the server and re throws stream write error if no callback', async () => { |
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: For consistency with other tests, perhaps we should add a newline here to separate tests
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.
done
sdks/nodejs/spec/agonesSDK.spec.js
Outdated
expect(error).toEqual('error'); | ||
} | ||
}); | ||
it('do not call error callback if there was no stream error', async () => { |
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
it('do not call error callback if there was no stream error', async () => { | |
it('does not call error callback if there was no stream error', async () => { | |
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.
done
sdks/nodejs/src/agonesSDK.js
Outdated
if (this.healthStream === undefined) { | ||
this.healthStream = this.client.health(() => { | ||
// Ignore error as this can't be caught | ||
}); | ||
if (typeof this.healthStream.on === 'function') { |
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.
@XiaNi I'm just wondering a couple of things about this change:
- Do we need to listen to the event if we are already passing a callback above? Or is this just to make testing easier?
- If so, do we need the
typeof
check? Generally I would trust gRPC client types not to change unless we intentionally update the client and then would change this code too
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.
-
If we won't listen to event - there will be uncatchable error thrown even with callback. So now we can control to "catch"
error and pass it to callback or re-throw if no callback.
In real life scenario it 99% will be called or always without or always with callback so i could add that event handler only if callback is there on first call. But i think it will add inconsistency. And then is should be mentioned in docs that first health() call will determine behaviour of it's next calls. -
I'v added this check to not break tests where we implement just "write" method. So in tests ".on" is usualy undefined and in real environment it will be always 'function'. So i agree that this type check looks strange. Should i add "on" to stream spyobject of all tests with health() call? (i like this option)
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.
Thanks for the detailed explanation. On point 2 I'd add an 'on' to the stream spy object so we can remove this check
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 added 'on' to tests and removed that type check
The callback is a great idea - we may have to update some documentation too though, e.g. in https://github.com/googleforgames/agones/blob/main/site/content/en/docs/Guides/Client%20SDKs/nodejs.md |
documentation is updated now too |
+ add 'on' method to stream spy object of 'health()' tests
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: markmandel, steven-supersolid, XiaNi The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What type of PR is this?
/kind feature
What this PR does / Why we need it:
it turns faceless error like:
to
where developer can see who was trying to write and why.
Which issue(s) this PR fixes:
Special notes for your reviewer: