Skip to content

Commit

Permalink
The modifyInstance() function is returning back to the caller when th…
Browse files Browse the repository at this point in the history
…e the instance is not in UP status. So the cache is never updated to the OUT_OF_SERVICE status. This should fix that problem. (#148)
  • Loading branch information
kiranmanda authored and awolden committed Oct 30, 2018
1 parent 0d4c142 commit 230973f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@ node_modules
lib/

.DS_Store

#IDE
.idea
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eureka-js-client",
"version": "4.4.1",
"version": "4.4.2",
"description": "A JavaScript implementation the Netflix OSS service registry, Eureka.",
"main": "lib/index.js",
"scripts": {
Expand Down
1 change: 0 additions & 1 deletion src/EurekaClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,6 @@ export default class Eureka extends EventEmitter {
}

modifyInstance(cache, instance) {
if (!this.validateInstance(instance)) return;
const vipAddresses = this.splitVipAddress(instance.vipAddress);
const appName = instance.app.toUpperCase();
vipAddresses.forEach((vipAddress) => {
Expand Down
21 changes: 21 additions & 0 deletions test/EurekaClient.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1178,6 +1178,27 @@ describe('Eureka client', () => {
expect(client.cache.app.THEAPP[0]).to.have.property('newProp');
});

it('should modify instances even when status is not UP', () => {
const appDelta = [
{
instance: [
{ hostName: '127.0.0.1', port: { $: 1000 }, app: 'THEAPP', vipAddress: 'thevip', status: 'DOWN', actionType: 'MODIFIED', newProp: 'foo' },
],
},
];
const original = { hostName: '127.0.0.1', port: { $: 1000 }, app: 'THEAPP', vipAddress: 'thevip', status: 'UP', actionType: 'MODIFIED' };
client.cache = {
app: { THEAPP: [original] },
vip: { thevip: [original] },
};

client.handleDelta(client.cache, appDelta);
expect(client.cache.vip.thevip).to.have.length(1);
expect(client.cache.app.THEAPP).to.have.length(1);
expect(client.cache.vip.thevip[0]).to.have.property('newProp');
expect(client.cache.app.THEAPP[0]).to.have.property('newProp');
});

it('should add if instance doesnt exist when modifying', () => {
const appDelta = [
{
Expand Down

0 comments on commit 230973f

Please sign in to comment.