Skip to content

Commit eb4addc

Browse files
committed
Merge pull request #2337 from uProxy/trevj-remove-cloud-install-retry
remove cloud install retry since the installer module now does it
2 parents d9c6062 + ce3afe6 commit eb4addc

File tree

2 files changed

+1
-66
lines changed

2 files changed

+1
-66
lines changed

src/generic_core/uproxy_core.spec.ts

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -110,48 +110,3 @@ describe('Core', () => {
110110
}).then(done);
111111
});
112112
});
113-
114-
describe('retry', () => {
115-
var MAX_ATTEMPTS = 5;
116-
var RETURN_VALUE = 'hello';
117-
118-
it('only calls successful func once', (done) => {
119-
var spyFunc = jasmine.createSpy('spyFunc');
120-
spyFunc.and.returnValue(Promise.resolve(RETURN_VALUE));
121-
uproxy_core.retry(spyFunc, MAX_ATTEMPTS).then((x :any) => {
122-
expect(spyFunc.calls.count()).toEqual(1);
123-
expect(x).toEqual(RETURN_VALUE);
124-
done();
125-
});
126-
});
127-
128-
it('calls func multiple times until success', (done) => {
129-
var spyFunc = jasmine.createSpy('spyFunc');
130-
var callCount = 0;
131-
var NUM_CALLS_BEFORE_SUCCESS = 3;
132-
expect(NUM_CALLS_BEFORE_SUCCESS).toBeLessThan(MAX_ATTEMPTS);
133-
spyFunc.and.callFake(() => {
134-
if (++callCount === NUM_CALLS_BEFORE_SUCCESS) {
135-
return Promise.resolve(RETURN_VALUE);
136-
} else {
137-
return Promise.reject('error');
138-
}
139-
});
140-
uproxy_core.retry(spyFunc, MAX_ATTEMPTS).then((x :any) => {
141-
expect(spyFunc.calls.count()).toEqual(NUM_CALLS_BEFORE_SUCCESS);
142-
expect(x).toEqual(RETURN_VALUE);
143-
done();
144-
});
145-
});
146-
147-
it('stops calling failing func after the max number of tries', (done) => {
148-
var RETURN_VALUE = 'hello';
149-
var spyFunc = jasmine.createSpy('spyFunc');
150-
spyFunc.and.returnValue(Promise.reject(RETURN_VALUE));
151-
uproxy_core.retry(spyFunc, MAX_ATTEMPTS).catch((x :any) => {
152-
expect(spyFunc.calls.count()).toEqual(MAX_ATTEMPTS);
153-
expect(x).toEqual(RETURN_VALUE);
154-
done();
155-
});
156-
});
157-
});

src/generic_core/uproxy_core.ts

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -667,15 +667,8 @@ export class uProxyCore implements uproxy_core_api.CoreApi {
667667
DEPLOY_PROGRESS + (progress * ((100 - DEPLOY_PROGRESS) / 100)));
668668
});
669669

670-
// Attempt to install. If install fails, retry will attempt again
671-
// up to MAX_INSTALLS times. Failure may occur because we have just
672-
// created the server and it is not yet ready for SSH.
673670
// TODO: The provisioning module should return the username!
674-
const install = () => {
675-
return installer.install(host, port, 'root', serverInfo.ssh.private);
676-
};
677-
const MAX_INSTALLS = 5;
678-
return retry(install, MAX_INSTALLS);
671+
return installer.install(host, port, 'root', serverInfo.ssh.private);
679672
}).then((cloudNetworkData: any) => {
680673
// TODO: make cloudNetworkData an Invite type. This requires the cloud
681674
// social provider to export the Invite interface, and also to cleanup
@@ -792,16 +785,3 @@ export class uProxyCore implements uproxy_core_api.CoreApi {
792785
return Promise.resolve<void>();
793786
}
794787
} // class uProxyCore
795-
796-
// Invoke an async function, and retry on error, calling func up to
797-
// maxAttempts number of times.
798-
export var retry = <T>(func :() => Promise<T>, maxAttempts :number) : Promise<T> => {
799-
return func().catch((err) => {
800-
--maxAttempts;
801-
if (maxAttempts > 0) {
802-
return retry(func, maxAttempts);
803-
} else {
804-
return Promise.reject(err)
805-
}
806-
});
807-
}

0 commit comments

Comments
 (0)