Skip to content

Commit

Permalink
[PLAT-13804]: Create a workflow in YBA to enable monitoring of univer…
Browse files Browse the repository at this point in the history
…ses by TS service

Summary: Create a workflow in YBA to enable monitoring of universes by TS service

Test Plan:
Please refer to the video
{F177155}

Reviewers: jmak, amalyshev

Reviewed By: amalyshev

Subscribers: yugaware

Differential Revision: https://phorge.dev.yugabyte.com/D34808
  • Loading branch information
rajmaddy89 committed May 14, 2024
1 parent 0303740 commit 85941de
Show file tree
Hide file tree
Showing 33 changed files with 1,252 additions and 300 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,12 @@ public class CustomerConfKeys extends RuntimeConfigKeysModule {
"Enable IMDSv2 support for AWS providers",
ConfDataType.BooleanType,
ImmutableList.of(ConfKeyTags.PUBLIC));
public static final ConfKeyInfo<Boolean> enableTroubleshooting =
new ConfKeyInfo<>(
"yb.ui.feature_flags.enable_troubleshooting",
ScopeType.CUSTOMER,
"Enables Troubleshooting for the Universe",
"Enables Troubleshooting for the Universe",
ConfDataType.BooleanType,
ImmutableList.of(ConfKeyTags.INTERNAL));
}
Original file line number Diff line number Diff line change
Expand Up @@ -1272,14 +1272,6 @@ public class GlobalConfKeys extends RuntimeConfigKeysModule {
"Enable the new releases design",
ConfDataType.BooleanType,
ImmutableList.of(ConfKeyTags.INTERNAL));
public static final ConfKeyInfo<Boolean> enableTroubleshooting =
new ConfKeyInfo<>(
"yb.ui.feature_flags.enable_troubleshooting",
ScopeType.GLOBAL,
"Enables Troubleshooting for the Universe",
"Enables Troubleshooting for the Universe",
ConfDataType.BooleanType,
ImmutableList.of(ConfKeyTags.INTERNAL));
public static final ConfKeyInfo<Boolean> enableAzureProviderValidation =
new ConfKeyInfo<>(
"yb.provider.azure_provider_validation",
Expand Down
14 changes: 7 additions & 7 deletions managed/ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion managed/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"@types/react-select": "3.0.19",
"@types/redux-form": "8.3.1",
"@types/yup": "0.29.11",
"@yugabytedb/troubleshoot-ui": "2.0.0",
"@yugabytedb/troubleshoot-ui": "2.0.9",
"ace-builds": "1.4.12",
"axios": "0.21.3",
"bootstrap": "3.4.1",
Expand Down
26 changes: 22 additions & 4 deletions managed/ui/src/actions/customers.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ export const FETCH_RUNTIME_CONFIGS_RESPONSE = 'FETCH_RUNTIME_CONFIGS_RESPONSE';
export const FETCH_RUNTIME_CONFIGS_KEY_INFO = 'FETCH_RUNTIME_CONFIGS_KEY_INFO';
export const FETCH_RUNTIME_CONFIGS_KEY_INFO_RESPONSE = 'FETCH_RUNTIME_CONFIGS_KEY_INFO_RESPONSE';

export const FETCH_CUSTOMER_RUNTIME_CONFIGS = 'FETCH_CUSTOMER_RUNTIME_CONFIGS';
export const FETCH_CUSTOMER_RUNTIME_CONFIGS_RESPONSE = 'FETCH_CUSTOMER_RUNTIME_CONFIGS_RESPONSE';

export const FETCH_PROVIDER_RUNTIME_CONFIGS = 'FETCH_PROVIDER_RUNTIME_CONFIGS';
export const FETCH_PROVIDER_RUNTIME_CONFIGS_RESPONSE = 'FETCH_PROVIDER_RUNTIME_CONFIGS_RESPONSE';

Expand Down Expand Up @@ -388,10 +391,7 @@ export function updatePassword(_user, values) {
const data = {
...values
};
return axios.put(
`${ROOT_URL}/customers/${cUUID}/reset_password`,
data
);
return axios.put(`${ROOT_URL}/customers/${cUUID}/reset_password`, data);
}

export function updateUserProfile(user, values) {
Expand Down Expand Up @@ -1004,6 +1004,24 @@ export function fetchProviderRunTimeConfigsResponse(response) {
};
}

export function fetchCustomerRunTimeConfigs(includeInherited = false) {
const cUUID = localStorage.getItem('customerId');
const request = axios.get(
`${ROOT_URL}/customers/${cUUID}/runtime_config/${cUUID}?includeInherited=${includeInherited}`
);
return {
type: FETCH_CUSTOMER_RUNTIME_CONFIGS,
payload: request
};
}

export function fetchCustomerRunTimeConfigsResponse(response) {
return {
type: FETCH_CUSTOMER_RUNTIME_CONFIGS_RESPONSE,
payload: response
};
}

export function setRunTimeConfig({ key, value, scope = DEFAULT_RUNTIME_GLOBAL_SCOPE }) {
const cUUID = localStorage.getItem('customerId');
const headers = {
Expand Down
19 changes: 18 additions & 1 deletion managed/ui/src/components/common/nav_bar/NavBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,30 @@ import { Component } from 'react';
import TopNavBar from './TopNavBar';
import SideNavBar from './SideNavBar';
import './stylesheets/NavBar.scss';
import { RuntimeConfigKey } from '../../../redesign/helpers/constants';

export default class NavBar extends Component {
componentDidMount() {
this.props.fetchCustomerRunTimeConfigs();
}

render() {
// const { customerRuntimeConfigs } = this.props;
const {
customer: { customerRuntimeConfigs }
} = this.props;
const isTroubleshootingEnabled = customerRuntimeConfigs?.data?.configEntries?.some(
(config) => config.key === RuntimeConfigKey.ENABLE_TROUBLESHOOTING && config.value === 'true'
);

return (
<div className="yb-nav-bar">
<TopNavBar customer={this.props.customer} logoutProfile={this.props.logoutProfile} />
<SideNavBar customer={this.props.customer} enableBackupv2={this.props.enableBackupv2} />
<SideNavBar
customer={this.props.customer}
enableBackupv2={this.props.enableBackupv2}
isTroubleshootingEnabled={isTroubleshootingEnabled}
/>
</div>
);
}
Expand Down
13 changes: 12 additions & 1 deletion managed/ui/src/components/common/nav_bar/NavBarContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
import { connect } from 'react-redux';

import NavBar from './NavBar';
import { logout, logoutSuccess, logoutFailure } from '../../../actions/customers';
import {
logout,
logoutSuccess,
logoutFailure,
fetchCustomerRunTimeConfigs,
fetchCustomerRunTimeConfigsResponse
} from '../../../actions/customers';

const mapDispatchToProps = (dispatch) => {
return {
Expand All @@ -16,6 +22,11 @@ const mapDispatchToProps = (dispatch) => {
dispatch(logoutSuccess());
}
});
},
fetchCustomerRunTimeConfigs: () => {
return dispatch(fetchCustomerRunTimeConfigs(true)).then((response) =>
dispatch(fetchCustomerRunTimeConfigsResponse(response.payload))
);
}
};
};
Expand Down
13 changes: 13 additions & 0 deletions managed/ui/src/components/common/nav_bar/SideNavBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,19 @@ export default class SideNavBar extends Component {
text="Configs"
display={getFeatureState(currentCustomer.data.features, 'menu.config')}
/>

{this.props.isTroubleshootingEnabled && (
<NavLink
to="/troubleshoot"
icon="fa fa-cloud-upload"
text="Troubleshoot"
display={getFeatureState(
currentCustomer.data.features,
'menu.troubleshoot'
)}
/>
)}

<NavLink
to="/admin"
icon="fa fa-gear"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { isAvailable, showOrRedirect } from '../../utils/LayoutUtils';
import { api, regionMetadataQueryKey } from '../../redesign/helpers/api';
import { RbacValidator } from '../../redesign/features/rbac/common/RbacApiPermValidator';
import { ApiPermissionMap } from '../../redesign/features/rbac/ApiAndUserPermMapping';
import { TroubleshootConfiguration } from '@yugabytedb/troubleshoot-ui';

interface ReactRouterProps {
location: LocationShape;
Expand All @@ -58,6 +59,7 @@ export const DataCenterConfigRedesign = ({ location, params }: ReactRouterProps)
queryFn: () => api.fetchRegionMetadata(providerCode)
}))
);

useQueries(
SUPPORTED_KUBERNETES_PROVIDERS.map((kubernetesProvider) => ({
queryKey: regionMetadataQueryKey.detail(ProviderCode.KUBERNETES, kubernetesProvider),
Expand All @@ -81,9 +83,7 @@ export const DataCenterConfigRedesign = ({ location, params }: ReactRouterProps)
return (
<div>
<h2 className="content-title">Provider Configuration</h2>
<RbacValidator
accessRequiredOn={ApiPermissionMap.GET_PROVIDERS}
>
<RbacValidator accessRequiredOn={ApiPermissionMap.GET_PROVIDERS}>
<YBTabsWithLinksPanel
defaultTab={defaultTab}
activeTab={activeTab}
Expand Down Expand Up @@ -211,10 +211,14 @@ export const DataCenterConfigRedesign = ({ location, params }: ReactRouterProps)
)}
{(featureFlags.test['enableMultiRegionConfig'] ||
featureFlags.released['enableMultiRegionConfig']) && (
<Tab eventKey={ConfigTabKey.BACKUP_NEW} title="New Backup Config" key="new-backup-config">
<NewStorageConfiguration activeTab={params.section} />
</Tab>
)}
<Tab
eventKey={ConfigTabKey.BACKUP_NEW}
title="New Backup Config"
key="new-backup-config"
>
<NewStorageConfiguration activeTab={params.section} />
</Tab>
)}
</YBTabsWithLinksPanel>
</RbacValidator>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ export const ConfigTabKey = {
INFRA: 'infra',
BACKUP: 'backup',
BACKUP_NEW: 'newBackupConfig',
SECURITY: 'security'
SECURITY: 'security',
TROUBLESHOOT: 'troubleshoot'
} as const;
export type ConfigTabKey = typeof ConfigTabKey[keyof typeof ConfigTabKey];

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import {
TroubleshootAdvisor,
TroubleshootAPI,
QUERY_KEY,
AttachUniverse
} from '@yugabytedb/troubleshoot-ui';
import { AppName } from '../../../redesign/features/Troubleshooting/TroubleshootingDashboard';
import { useQuery } from 'react-query';
import { useState } from 'react';
import { YBErrorIndicator, YBLoading } from '../../common/indicators';
import { Box, makeStyles } from '@material-ui/core';
import { useSelector } from 'react-redux';
import { api, QUERY_KEY as TOKEN_KEY } from '../../../redesign/utils/api';
import { IN_DEVELOPMENT_MODE, ROOT_URL } from '../../../config';

interface TroubleshootUniverseProps {
universeUuid: string;
appName: AppName;
timezone: string;
}

const useStyles = makeStyles((theme) => ({
register: {
cursor: 'pointer'
}
}));

export const TroubleshootUniverse = ({
universeUuid,
appName,
timezone
}: TroubleshootUniverseProps) => {
const helperClasses = useStyles();
const [showAttachUniverseDialog, setShowAttachUniverseDialog] = useState<boolean>(false);
const baseUrl = ROOT_URL.split('/api/');
const { currentCustomer } = useSelector((state: any) => state.customer);

const sessionInfo = useQuery(TOKEN_KEY.getSessionInfo, () => api.getSessionInfo());
const troubleshootingUniverseMetadata = useQuery(QUERY_KEY.fetchUniverseMetadataList, () =>
TroubleshootAPI.fetchUniverseMetadataList()
);

if (troubleshootingUniverseMetadata.isError) {
return <YBErrorIndicator />;
}
if (
troubleshootingUniverseMetadata.isLoading ||
(troubleshootingUniverseMetadata.isIdle && troubleshootingUniverseMetadata.data === undefined)
) {
return <YBLoading />;
}

const currentUniverseMetadata = troubleshootingUniverseMetadata?.data?.find(
(metadata) => metadata.id === universeUuid
);

const onAttachUniverseButtonClick = () => {
troubleshootingUniverseMetadata.refetch();
setShowAttachUniverseDialog(true);
};

const onAttachUniverseDialogClose = () => {
troubleshootingUniverseMetadata.refetch();
setShowAttachUniverseDialog(false);
};

const onAttachUniverse = () => {
onAttachUniverseButtonClick();
};

return currentUniverseMetadata ? (
<TroubleshootAdvisor universeUuid={universeUuid} appName={appName} timezone={timezone} />
) : (
<Box>
{'Universe is currently not registered to the troubleshooting service,'}
<a onClick={onAttachUniverse} className={helperClasses.register}>
{' please register here'}
</a>
{showAttachUniverseDialog && (
<AttachUniverse
universeUuid={universeUuid}
customerUuid={currentCustomer.data.uuid}
baseUrl={baseUrl[0]}
apiToken={sessionInfo?.data?.apiToken}
open={showAttachUniverseDialog}
onClose={onAttachUniverseDialogClose}
isDevMode={IN_DEVELOPMENT_MODE}
/>
)}
</Box>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { Link, withRouter, browserHistory } from 'react-router';
import { Grid, DropdownButton, MenuItem, Tab, Alert } from 'react-bootstrap';
import Measure from 'react-measure';
import { mouseTrap } from 'react-mousetrap';
import { TroubleshootAdvisor } from '@yugabytedb/troubleshoot-ui';
import { CustomerMetricsPanel } from '../../metrics';
import { RollingUpgradeFormContainer } from '../../../components/common/forms';
import {
Expand Down Expand Up @@ -63,10 +62,13 @@ import { UniverseState, getUniverseStatus, SoftwareUpgradeState } from '../helpe
import { RbacValidator } from '../../../redesign/features/rbac/common/RbacApiPermValidator';
import { ApiPermissionMap } from '../../../redesign/features/rbac/ApiAndUserPermMapping';
import { DrPanel } from '../../xcluster/disasterRecovery/DrPanel';
import { TroubleshootUniverse } from '../TroubleshootUniverse/TroubleshootUniverse';
import {
VM_PATCHING_RUNTIME_CONFIG,
isImgBundleSupportedByProvider
} from '../../configRedesign/providerRedesign/components/linuxVersionCatalog/LinuxVersionUtils';

import { AppName } from '../../../redesign/features/Troubleshooting/TroubleshootingDashboard';
import { RuntimeConfigKey, UNIVERSE_TASKS } from '../../../redesign/helpers/constants';
import { isActionFrozen } from '../../../redesign/helpers/utils';

Expand Down Expand Up @@ -647,10 +649,9 @@ class UniverseDetail extends Component {
'universes.details.troubleshooting'
)}
>
<TroubleshootAdvisor
<TroubleshootUniverse
universeUuid={currentUniverse.data.universeUUID}
universeData={currentUniverse.data.universeDetails}
appName={'YBA'}
appName={AppName.YBA}
timezone={currentUser.data.timezone}
/>
</Tab.Pane>
Expand Down
5 changes: 5 additions & 0 deletions managed/ui/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ export const ROOT_URL =
// Allow requests made to endpoints in ‘routes’ file.
export const BASE_URL = IN_DEVELOPMENT_MODE ? 'http://localhost:9000' : '';

export const REACT_TROUBLESHOOT_API_DEV_URL =
process.env.REACT_TROUBLESHOOT_API_DEV_URL ?? `http://localhost:8080`;
export const REACT_TROUBLESHOOT_API_PROD_URL =
process.env.REACT_TROUBLESHOOT_API_PROD_URL ?? `https://10.9.15.156:8443/api`;

export const MAP_SERVER_URL = IN_DEVELOPMENT_MODE
? `https://s3-us-west-2.amazonaws.com/${process.env.REACT_APP_YB_MAP_URL}/map`
: '/static/map';
Expand Down

0 comments on commit 85941de

Please sign in to comment.