Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,4 @@ COMMAND_BAR_REFETCH_INTERVAL=3600
FEATURE_STORAGE_ENABLE=false
FEATURE_ATHENA_DEBUG_MODE_ENABLE=false
GRAFANA_ORG_ID=2
FEATURE_NODE_AUTOSCALER_ENABLE=false
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"homepage": "/dashboard",
"dependencies": {
"@devtron-labs/devtron-fe-common-lib": "4.0.4",
"@devtron-labs/devtron-fe-common-lib": "4.0.5",
"@esbuild-plugins/node-globals-polyfill": "0.2.3",
"@sentry/browser": "7.119.1",
"@sentry/integrations": "7.50.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

const RemoteConnectionRadio = importComponentFromFELibrary('RemoteConnectionRadio', null, 'function')
const AssignCategorySelect = importComponentFromFELibrary('AssignCategorySelect', null, 'function')
const AutoscalerProfileSelect = importComponentFromFELibrary('AutoscalerProfileSelect', null, 'function')

const ClusterConfigurations = ({
id,
Expand All @@ -45,6 +46,8 @@
initialIsTlsConnection,
getIsConnectProtocolConfigInvalid,
getIsTLSConfigInvalid,
autoscalerProfile,
setAutoscalerProfile,
}: ClusterConfigurationsProps) => {
const [clusterConfigPage, setClusterConfigPage] = useState<ClusterConfigPages>(ClusterConfigPages.BASIC_CONFIG)

Expand Down Expand Up @@ -302,14 +305,24 @@
</RadioGroup>
</div>

{AssignCategorySelect && (
<div className="w-250">
<AssignCategorySelect
selectedCategory={selectedCategory}
setSelectedCategory={setSelectedCategory}
/>
</div>
)}
<div className="flex left dc__gap-12">
{AssignCategorySelect && (
<div className="w-250">
<AssignCategorySelect
selectedCategory={selectedCategory}
setSelectedCategory={setSelectedCategory}
/>
</div>
)}
{window._env_.FEATURE_NODE_AUTOSCALER_ENABLE && AutoscalerProfileSelect && (

Check warning on line 317 in src/Pages/GlobalConfigurations/ClustersAndEnvironments/ClusterForm/ClusterConfigurations.tsx

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Prefer `globalThis` over `window`.

See more on https://sonarcloud.io/project/issues?id=devtron-labs_dashboard&issues=AZ3Yk5ujBIKHU6rmv6Gr&open=AZ3Yk5ujBIKHU6rmv6Gr&pullRequest=3103
<div className="w-250">
<AutoscalerProfileSelect
autoscalerProfile={autoscalerProfile}
setAutoscalerProfile={setAutoscalerProfile}
/>
</div>
)}
</div>
</div>
{id !== DEFAULT_CLUSTER_ID && (
<div className="flexbox-col dc__gap-12">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
ToastManager,
ToastVariantType,
useAsync,
useQuery,
} from '@devtron-labs/devtron-fe-common-lib'

import { getModuleInfo } from '@Components/v2/devtronStackManager/DevtronStackManager.service'
Expand All @@ -62,6 +63,8 @@
const getRemoteConnectionConfig = importComponentFromFELibrary('getRemoteConnectionConfig', noop, 'function')
const getCategoryPayload = importComponentFromFELibrary('getCategoryPayload', null, 'function')
const ClusterCostConfig = importComponentFromFELibrary('ClusterCostConfig', null, 'function')
const attachProfileToCluster = importComponentFromFELibrary('attachProfileToCluster', null, 'function')
const getProfileAttachedToCluster = importComponentFromFELibrary('getProfileAttachedToCluster', null, 'function')

const ClusterForm = ({
id = null,
Expand Down Expand Up @@ -126,6 +129,19 @@
const [isUpdating, setIsUpdating] = useState<boolean>(false)
const [isConnectedViaProxyTemp, setIsConnectedViaProxyTemp] = useState(!!proxyUrl)
const [isConnectedViaSSHTunnelTemp, setIsConnectedViaSSHTunnelTemp] = useState(isConnectedViaSSHTunnel)
const [autoscalerProfile, setAutoscalerProfile] = useState<SelectPickerOptionType<number>>(null)

const { data: profileData } = useQuery({
queryKey: ['getProfileAttachedToCluster', clusterName],
queryFn: () => getProfileAttachedToCluster(clusterName),
enabled: !!clusterName && window._env_.FEATURE_NODE_AUTOSCALER_ENABLE && !!getProfileAttachedToCluster,

Check warning on line 137 in src/Pages/GlobalConfigurations/ClustersAndEnvironments/ClusterForm/ClusterForm.tsx

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Prefer `globalThis` over `window`.

See more on https://sonarcloud.io/project/issues?id=devtron-labs_dashboard&issues=AZ33Eu6GeKAE4FWb3ozU&open=AZ33Eu6GeKAE4FWb3ozU&pullRequest=3103
})

useEffect(() => {
if (profileData) {
setAutoscalerProfile(profileData)
}
}, [profileData])

const isPrometheusEnabled = costModuleState.enabled || isAppMetricsEnabled

Expand Down Expand Up @@ -322,6 +338,9 @@
try {
setIsUpdating(true)
await api(payload)
if (window._env_.FEATURE_NODE_AUTOSCALER_ENABLE && attachProfileToCluster) {

Check warning on line 341 in src/Pages/GlobalConfigurations/ClustersAndEnvironments/ClusterForm/ClusterForm.tsx

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Prefer `globalThis` over `window`.

See more on https://sonarcloud.io/project/issues?id=devtron-labs_dashboard&issues=AZ3Yk5u8BIKHU6rmv6Gt&open=AZ3Yk5u8BIKHU6rmv6Gt&pullRequest=3103
attachProfileToCluster(autoscalerProfile?.value, payload.cluster_name)
}
ToastManager.showToast({
variant: ToastVariantType.success,
description: `Successfully ${id ? 'updated' : 'saved'}`,
Expand Down Expand Up @@ -541,6 +560,8 @@
initialIsTlsConnection={initialIsTlsConnection}
getIsConnectProtocolConfigInvalid={getIsConnectProtocolConfigInvalid}
getIsTLSConfigInvalid={getIsTLSConfigInvalid}
autoscalerProfile={autoscalerProfile}
setAutoscalerProfile={setAutoscalerProfile}
/>
</div>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export interface ClusterConfigurationsProps {
initialIsTlsConnection: boolean
getIsConnectProtocolConfigInvalid: () => boolean
getIsTLSConfigInvalid: () => boolean
autoscalerProfile: SelectPickerOptionType<number>
setAutoscalerProfile: Dispatch<SetStateAction<SelectPickerOptionType<number>>>
}

export interface KubeConfigEditorProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { generatePath, Link, useLocation, useNavigate, useParams } from 'react-r
import {
ActionMenu,
ActionMenuItemType,
Badge,
Button,
ButtonStyleType,
ButtonVariantType,
Expand Down Expand Up @@ -203,7 +204,17 @@ export const ClusterListCellComponent: FunctionComponent<
> = ({
field,
row: {
data: { clusterId, clusterName, clusterType, envCount, serverUrl, clusterCategory, isVirtualCluster, status },
data: {
clusterId,
clusterName,
clusterType,
envCount,
serverUrl,
clusterCategory,
isVirtualCluster,
status,
autoscalerProfile,
},
},
isRowActive,
signals,
Expand Down Expand Up @@ -250,6 +261,18 @@ export const ClusterListCellComponent: FunctionComponent<
)
case ClusterListFields.CLUSTER_TYPE:
return <span className="flex left py-10">{clusterType}</span>
case ClusterListFields.AUTOSCALER_PROFILE:
return autoscalerProfile ? (
<div className="flex left py-10">
<Badge
variant="custom"
fontColor="V500"
bgColor="V200"
label={autoscalerProfile}
size={ComponentSizeType.xxs}
/>
</div>
) : null
case ClusterListFields.ENV_COUNT:
return <span className="flex left py-10">{envCount ? `${envCount}` : 'No'} Environments</span>
case ClusterListFields.CLUSTER_CATEGORY:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
TableColumnType,
useAsync,
useMainContext,
useQuery,
useUrlFilters,
} from '@devtron-labs/devtron-fe-common-lib'

Expand Down Expand Up @@ -84,6 +85,7 @@
const ManageCategoryButton = importComponentFromFELibrary('ManageCategoryButton', null, 'function')
const PodSpreadModal = importComponentFromFELibrary('PodSpreadModal', null, 'function')
const HibernationRulesModal = importComponentFromFELibrary('HibernationRulesModal', null, 'function')
const getClusterAutoscalerProfileMap = importComponentFromFELibrary('getClusterAutoscalerProfileMap', null, 'function')

const ClusterList = () => {
const { isSuperAdmin } = useMainContext()
Expand Down Expand Up @@ -118,6 +120,12 @@
isSuperAdmin && !isK8sClient,
)

const { data: clusterNameVsAutoscalerProfile, refetch: refetchProfileMap } = useQuery({
queryKey: ['clusterNameVsAutoscalerProfile'],
queryFn: getClusterAutoscalerProfileMap,
enabled: !!getClusterAutoscalerProfileMap && !!window._env_.FEATURE_NODE_AUTOSCALER_ENABLE,

Check warning on line 126 in src/Pages/GlobalConfigurations/ClustersAndEnvironments/ClusterList.tsx

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Prefer `globalThis` over `window`.

See more on https://sonarcloud.io/project/issues?id=devtron-labs_dashboard&issues=AZ33Eu_yeKAE4FWb3ozV&open=AZ33Eu_yeKAE4FWb3ozV&pullRequest=3103
})

const [showUnmappedEnvs, setShowUnmappedEnvs] = useState(false)

const clusterCount = clusterListResult?.length ?? 0
Expand Down Expand Up @@ -169,7 +177,7 @@
{
field: ClusterListFields.CLUSTER_NAME,
label: 'CLUSTER',
size: { fixed: 200 },
size: { fixed: 180 },
isSortable: true,
comparator: stringComparatorBySortOrder,
CellComponent: ClusterListCellComponent,
Expand All @@ -180,7 +188,7 @@
{
field: ClusterListFields.ENV_COUNT,
label: 'ENVIRONMENTS',
size: { fixed: 150 },
size: { fixed: 120 },
isSortable: true,
comparator: numberComparatorBySortOrder,
CellComponent: ClusterListCellComponent,
Expand All @@ -199,13 +207,23 @@
{
field: ClusterListFields.CLUSTER_CATEGORY,
label: 'CATEGORY',
size: { fixed: 150 },
size: { fixed: 100 },
isSortable: true,
comparator: stringComparatorBySortOrder,
CellComponent: ClusterListCellComponent,
} as TableColumnType<ClusterRowData, FiltersTypeEnum.STATE, {}>,
]
: []),
...(window._env_.FEATURE_NODE_AUTOSCALER_ENABLE && getClusterAutoscalerProfileMap

Check warning on line 217 in src/Pages/GlobalConfigurations/ClustersAndEnvironments/ClusterList.tsx

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Prefer `globalThis` over `window`.

See more on https://sonarcloud.io/project/issues?id=devtron-labs_dashboard&issues=AZ3Yk5vdBIKHU6rmv6Gv&open=AZ3Yk5vdBIKHU6rmv6Gv&pullRequest=3103
? [
{
field: ClusterListFields.AUTOSCALER_PROFILE,
label: 'AUTOSCALER PROFILE',
size: { fixed: 140 },
CellComponent: ClusterListCellComponent,
},
]
: []),
{
field: ClusterListFields.SERVER_URL,
label: 'SERVER URL',
Expand Down Expand Up @@ -233,6 +251,7 @@
clusterCategory: (category?.label as string) ?? '',
isVirtualCluster,
status,
autoscalerProfile: clusterNameVsAutoscalerProfile?.[clusterName] ?? null,
},
}
},
Expand Down Expand Up @@ -293,6 +312,11 @@
})
}

const handleCloseEditClusterModal = async () => {
await refetchProfileMap()
handleRedirectToClusterList()
}

const renderList = () => {
if (isClusterEnvListLoading) {
return <ClusterEnvLoader />
Expand Down Expand Up @@ -479,7 +503,7 @@
<EditCluster
clusterList={clusterListResult ?? []}
reloadClusterList={reloadClusterList}
handleClose={handleRedirectToClusterList}
handleClose={handleCloseEditClusterModal}
/>
}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ export interface ClusterRowData
envCount: number
clusterType: string
clusterCategory: string
autoscalerProfile: string
}

export enum ClusterEnvTabs {
Expand All @@ -267,6 +268,7 @@ export enum ClusterListFields {
CLUSTER_TYPE = 'clusterType',
ENV_COUNT = 'envCount',
CLUSTER_CATEGORY = 'clusterCategory',
AUTOSCALER_PROFILE = 'autoscalerProfile',
SERVER_URL = 'serverUrl',
ACTIONS = 'actions',
}
Expand Down
Loading
Loading