Skip to content
Open
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
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 failure on line 317 in src/Pages/GlobalConfigurations/ClustersAndEnvironments/ClusterForm/ClusterConfigurations.tsx

View workflow job for this annotation

GitHub Actions / ci

Property 'FEATURE_NODE_AUTOSCALER_ENABLE' does not exist on type 'customEnv'.

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 @@ -62,6 +62,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 +128,17 @@
const [isUpdating, setIsUpdating] = useState<boolean>(false)
const [isConnectedViaProxyTemp, setIsConnectedViaProxyTemp] = useState(!!proxyUrl)
const [isConnectedViaSSHTunnelTemp, setIsConnectedViaSSHTunnelTemp] = useState(isConnectedViaSSHTunnel)
const [autoscalerProfile, setAutoscalerProfile] = useState<SelectPickerOptionType<number>>(null)

useEffect(() => {
if (clusterName && window._env_.FEATURE_NODE_AUTOSCALER_ENABLE && getProfileAttachedToCluster) {

Check failure on line 134 in src/Pages/GlobalConfigurations/ClustersAndEnvironments/ClusterForm/ClusterForm.tsx

View workflow job for this annotation

GitHub Actions / ci

Property 'FEATURE_NODE_AUTOSCALER_ENABLE' does not exist on type 'customEnv'.

Check warning on line 134 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=AZ3Yk5u8BIKHU6rmv6Gs&open=AZ3Yk5u8BIKHU6rmv6Gs&pullRequest=3103
getProfileAttachedToCluster(clusterName).then((profile) => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

catch? And maybe useQuery

if (profile) {
setAutoscalerProfile(profile)
}
})
}
}, [])

const isPrometheusEnabled = costModuleState.enabled || isAppMetricsEnabled

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

Check failure on line 338 in src/Pages/GlobalConfigurations/ClustersAndEnvironments/ClusterForm/ClusterForm.tsx

View workflow job for this annotation

GitHub Actions / ci

Property 'FEATURE_NODE_AUTOSCALER_ENABLE' does not exist on type 'customEnv'.

Check warning on line 338 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 +557,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 @@ -84,6 +84,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 +119,12 @@
isSuperAdmin && !isK8sClient,
)

const [, clusterNameVsAutoscalerProfile, , refetchProfileMap] = useAsync(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useQuery?, and in enabled field, also check for getClusterAutoscalerProfileMap

getClusterAutoscalerProfileMap,
[],
!!window._env_.FEATURE_NODE_AUTOSCALER_ENABLE,

Check failure on line 125 in src/Pages/GlobalConfigurations/ClustersAndEnvironments/ClusterList.tsx

View workflow job for this annotation

GitHub Actions / ci

Property 'FEATURE_NODE_AUTOSCALER_ENABLE' does not exist on type 'customEnv'.

Check warning on line 125 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=AZ3Yk5vdBIKHU6rmv6Gu&open=AZ3Yk5vdBIKHU6rmv6Gu&pullRequest=3103
)

const [showUnmappedEnvs, setShowUnmappedEnvs] = useState(false)

const clusterCount = clusterListResult?.length ?? 0
Expand Down Expand Up @@ -169,7 +176,7 @@
{
field: ClusterListFields.CLUSTER_NAME,
label: 'CLUSTER',
size: { fixed: 200 },
size: { fixed: 180 },
isSortable: true,
comparator: stringComparatorBySortOrder,
CellComponent: ClusterListCellComponent,
Expand All @@ -180,7 +187,7 @@
{
field: ClusterListFields.ENV_COUNT,
label: 'ENVIRONMENTS',
size: { fixed: 150 },
size: { fixed: 120 },
isSortable: true,
comparator: numberComparatorBySortOrder,
CellComponent: ClusterListCellComponent,
Expand All @@ -199,13 +206,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 failure on line 216 in src/Pages/GlobalConfigurations/ClustersAndEnvironments/ClusterList.tsx

View workflow job for this annotation

GitHub Actions / ci

Property 'FEATURE_NODE_AUTOSCALER_ENABLE' does not exist on type 'customEnv'.

Check warning on line 216 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 +250,7 @@
clusterCategory: (category?.label as string) ?? '',
isVirtualCluster,
status,
autoscalerProfile: clusterNameVsAutoscalerProfile?.[clusterName] ?? null,
},
}
},
Expand Down Expand Up @@ -293,6 +311,11 @@
})
}

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

const renderList = () => {
if (isClusterEnvListLoading) {
return <ClusterEnvLoader />
Expand Down Expand Up @@ -479,7 +502,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