Skip to content

Commit

Permalink
Fix timeout memory leak (#566)
Browse files Browse the repository at this point in the history
* fix: set timeout for polling

* Revert "Fix local build and run issues (#565)"

This reverts commit 1df3ff4.

* hide developer resources on OS4

* update fuse name
  • Loading branch information
pb82 authored Mar 12, 2020
1 parent 1df3ff4 commit cdec03e
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 65 deletions.
9 changes: 1 addition & 8 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -523,13 +523,6 @@ function getMockConfigData() {
optionalWatchServices: [],
optionalProvisionServices: [],
mockData: {
mockUser: {
metadata: {
uid: '_mock_usr_1',
name: 'mockUser'
},
fullName: 'Mock User'
},
serviceInstances: [
{
spec: {
Expand Down Expand Up @@ -605,7 +598,7 @@ function getMockConfigData() {
},
{
spec: {
clusterServiceClassExternalName: 'apicurito'
clusterServiceClassExternalName: 'apicurio'
},
status: {
dashboardURL:'${process.env.OPENSHIFT_URL}',
Expand Down
78 changes: 38 additions & 40 deletions src/components/masthead/masthead.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,43 @@ class Masthead extends React.Component {
return logoName;
};

getDeveloperResources(gsUrl, riUrl, csUrl) {
const items = [];
items.push(
<DropdownItem key="help-getting-started" href={gsUrl} target="_blank" aria-label="Link to getting started page">
Getting started
</DropdownItem>
);

items.push(
<DropdownItem key="help-release-info" href={riUrl} target="_blank" aria-label="Link to release information page">
Release information
</DropdownItem>
);

items.push(
<DropdownItem key="help-customer-support" href={csUrl} target="_blank" aria-label="Link to customer support page">
Customer support
</DropdownItem>
);

if (window.OPENSHIFT_CONFIG && window.OPENSHIFT_CONFIG.openshiftVersion === 3) {
items.push(
<DropdownItem key="help-dev-resources" onClick={this.onDevResourcesClick}>
Developer resources
</DropdownItem>
);
}

items.push(<DropdownSeparator key="help-separator-2" />);
items.push(
<DropdownItem key="about" component="button" href="#about" onClick={this.onAboutModal} aria-label="About">
About
</DropdownItem>
);
return items;
}

onHelpDropdownSelect = () => {
this.setState({
isHelpDropdownOpen: !this.state.isHelpDropdownOpen
Expand Down Expand Up @@ -173,46 +210,7 @@ class Masthead extends React.Component {
</DropdownToggle>
}
autoFocus={false}
dropdownItems={[
<DropdownItem
key="help-getting-started"
href={gsUrl}
target="_blank"
aria-label="Link to getting started page"
>
Getting started
</DropdownItem>,
<DropdownItem
key="help-release-info"
href={riUrl}
target="_blank"
aria-label="Link to release information page"
>
Release information
</DropdownItem>,
<DropdownItem
key="help-customer-support"
href={csUrl}
target="_blank"
aria-label="Link to customer support page"
>
Customer support
</DropdownItem>,
<DropdownSeparator key="help-separator-1" />,
<DropdownItem key="help-dev-resources" onClick={this.onDevResourcesClick}>
Developer resources
</DropdownItem>,
<DropdownSeparator key="help-separator-2" />,
<DropdownItem
key="about"
component="button"
href="#about"
onClick={this.onAboutModal}
aria-label="About"
>
About
</DropdownItem>
]}
dropdownItems={this.getDeveloperResources(gsUrl, riUrl, csUrl)}
/>
</ToolbarItem>
</ToolbarGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/product-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default {
hidden: true
},
'fuse-managed': {
prettyName: 'Red Hat Fuse Online (Shared)',
prettyName: 'Red Hat Fuse Online',
gaStatus: 'GA',
primaryTask: 'Create integrations',
description:
Expand Down
2 changes: 1 addition & 1 deletion src/services/amqOnlineServices.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { provisionOperator } from './operatorServices';
const MANIFEST_NAME = 'integreatly-amq-online';

const watchAMQOnline = (dispatch, username, namespace) =>
poll(addressSpaceDef(namespace)).then(pollListener => {
poll(addressSpaceDef(namespace), 5000, 2000).then(pollListener => {
pollListener.onEvent(event => {
if (!event || !event.metadata || !event.metadata.name === cleanUsername(username)) {
dispatch(getPayloadFromAddressSpace(event));
Expand Down
2 changes: 2 additions & 0 deletions src/services/middlewareServices.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ const mockMiddlewareServices = (dispatch, mockData) => {
if (!mockData || !mockData.serviceInstances) {
return;
}
const mockUsername = 'mockuser';
window.localStorage.setItem('currentUserName', mockUsername);
mockData.serviceInstances.forEach(si => {
dispatch({
type: FULFILLED_ACTION(middlewareTypes.CREATE_WALKTHROUGH),
Expand Down
27 changes: 12 additions & 15 deletions src/services/openshiftServices.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class OpenShiftPollEventListener {
const getUser = () => {
// Don't start the OAuth flow when in mock mode. Just resolve an empty user
if (window.OPENSHIFT_CONFIG.mockData) {
return new Promise(resolve => resolve(window.OPENSHIFT_CONFIG.mockData.mockUser));
return new Promise(resolve => resolve({}));
}
let user;
try {
Expand Down Expand Up @@ -218,18 +218,14 @@ const currentUser = () => {
const url = isOpenShift4()
? `${getMasterUri()}/apis/user.openshift.io/v1/users/~`
: `${getMasterUri()}/oapi/v1/users/~`;
return getUser().then(user => {
if (window.OPENSHIFT_CONFIG.mockData) {
Promise.resolve(new OpenShiftUser(user));
} else {
axios({
url,
headers: {
authorization: `Bearer ${user.access_token}`
}
}).then(response => new OpenShiftUser(response.data));
}
});
return getUser().then(user =>
axios({
url,
headers: {
authorization: `Bearer ${user.access_token}`
}
}).then(response => new OpenShiftUser(response.data))
);
};

const get = (res, name) =>
Expand Down Expand Up @@ -375,17 +371,18 @@ const remove = (res, obj) =>
}).then(response => response.data);
});

const poll = (res, interval) =>
const poll = (res, interval, timeout) =>
getUser().then(user => {
const reqUrl = `${_buildRequestUrl(res)}`;
return Promise.resolve(
new OpenShiftPollEventListener({
url: reqUrl,
method: 'GET',
timeout: timeout || 2000,
headers: {
authorization: `Bearer ${user.access_token}`
}
}).init(interval || 1000)
}).init(interval || 2000)
);
});

Expand Down

0 comments on commit cdec03e

Please sign in to comment.