Skip to content

Commit

Permalink
[PLAT-16918]: Master Configuration Changes are not applied during edi…
Browse files Browse the repository at this point in the history
…t universe

Summary:
there are 3 issues. All the issues happens ONLY for universes which has migrated from 2.20 to 2024.2
1. Total pods field is showing up , but it should up separately for TServer and master
2. Editing MASTER cpuCore count and master volume Size does not work, it always retains default values
3. in the Universe overview page, the cluster widget does not show details separately for TServer and Master.
4. This is issue which persists always and may be this diff will fix it, show uptime in seconds for both TServer and Master

All of the issues happens due to recent change where master dedicatedNodes is being sent as false (which is expected now).

The fix is as follows:
NodeDetailsTable - We need to show both master and Tserver uptime in K8, this is a minor issue that has been there for long time, this issue cleans it up
UniverseOverviewNew.js  and UniverseUtils.js - some linting corrections, also `isDedicatedNodePlacement` should return true if provider type is kubernetes, this is used by UniverseOverviewNew where all CPU Usage panel, Disk Usage Panel will show separate stats for TServer and Master
EditUniverse.tsx - masterK8SNodeResourceSpec and tserverK8SNodeResourceSpec should get values from form when universe is a kubernetes based one
TotalNodesField.tsx - We need to show separate TServer pods and Master pods if it is dedicated or when it is k8 universe (which is primary)
InstanceConfiguration.tsx - Show TServer and Master info in case of K8 primary and show TServer config only in case of k8 RR

Test Plan: Once this diff is merged, QA can test this locally by creating a universe in 2.20 and upgrading it to latest master build

Reviewers: jmak, anijhawan

Reviewed By: jmak

Differential Revision: https://phorge.dev.yugabyte.com/D42227
  • Loading branch information
rajmaddy89 committed Mar 4, 2025
1 parent 9e694b6 commit 6222c84
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,16 @@ export default class NodeDetailsTable extends Component {

const getStatusUptime = (cell, row) => {
let uptime = '_';
const uptimeSeconds =
isDedicatedNodes && row.dedicatedTo === NodeType.Master.toUpperCase()
? row.master_uptime_seconds
: row.uptime_seconds;
let uptimeSeconds = row.uptime_seconds;
if (isDedicatedNodes) {
uptimeSeconds =
row.dedicatedTo === NodeType.Master.toUpperCase()
? row.master_uptime_seconds
: row.uptime_seconds;
}
if (isKubernetesCluster) {
uptimeSeconds = row.isMaster ? row.master_uptime_seconds : row.uptime_seconds;
}
if (isDefinedNotNull(uptimeSeconds)) {
// get the difference between the moments
const difference = parseFloat(uptimeSeconds) * 1000;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,8 @@ export default class UniverseOverviewNew extends Component {
<Col lg={3} sm={6} md={6} xs={12}>
<ClusterInfoPanelContainer
type={'read-replica'}
// In case of dedicated nodes, the read replica cluster can have only TServer nodes.
isDedicatedNodes={false}
universeInfo={currentUniverse}
runtimeConfigs={this.props.runtimeConfigs}
/>
Expand Down Expand Up @@ -873,15 +875,17 @@ export default class UniverseOverviewNew extends Component {
)?.value === 'true';

const isQueryMonitoringEnabled = localStorage.getItem('__yb_query_monitoring__') === 'true';
const isNewTaskDetailsUIEnabled = featureFlags?.test?.newTaskDetailsUI || featureFlags?.released?.newTaskDetailsUI;
const isNewTaskDetailsUIEnabled =
featureFlags?.test?.newTaskDetailsUI || featureFlags?.released?.newTaskDetailsUI;

return (
<Fragment>
{isRollBackFeatureEnabled &&
ybSoftwareUpgradeState === SoftwareUpgradeState.PRE_FINALIZE && (
<Row className="p-16">{<PreFinalizeBanner universeData={universeInfo} />}</Row>
)}
{isRollBackFeatureEnabled && !isNewTaskDetailsUIEnabled &&
{isRollBackFeatureEnabled &&
!isNewTaskDetailsUIEnabled &&
[SoftwareUpgradeState.ROLLBACK_FAILED, SoftwareUpgradeState.UPGRADE_FAILED].includes(
ybSoftwareUpgradeState
) &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,12 @@ export const EditUniverse: FC<EditUniverseProps> = ({ uuid, isViewMode }) => {
userIntent.masterDeviceInfo = _.get(formData, MASTER_DEVICE_INFO_FIELD);
}

if (isK8sUniverse && masterPlacement === MasterPlacementMode.DEDICATED) {
userIntent.masterK8SNodeResourceSpec = userIntent.dedicatedNodes
? _.get(formData, MASTER_K8_NODE_SPEC_FIELD)
: null;
if (isK8sUniverse) {
userIntent.masterK8SNodeResourceSpec = _.get(formData, MASTER_K8_NODE_SPEC_FIELD);
userIntent.tserverK8SNodeResourceSpec = _.get(formData, TSERVER_K8_NODE_SPEC_FIELD);
// In case of K8 universe, user intent dedicatedNodes will be false,
// hence we need to set masterDeviceInfo here as well
userIntent.masterDeviceInfo = _.get(formData, MASTER_DEVICE_INFO_FIELD);
}

payload.clusters[primaryIndex].placementInfo.cloudList[0].regionList = getPlacements(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import { useFormFieldStyles } from '../../../universeMainStyle';

interface TotalNodesFieldProps {
disabled?: boolean;
isPrimary: boolean;
useK8CustomResources: boolean;
}

const useStyles = makeStyles((theme) => ({
Expand All @@ -25,7 +27,11 @@ const useStyles = makeStyles((theme) => ({
}
}));

export const TotalNodesField = ({ disabled }: TotalNodesFieldProps): ReactElement => {
export const TotalNodesField = ({
disabled,
isPrimary,
useK8CustomResources
}: TotalNodesFieldProps): ReactElement => {
const { control, setValue, getValues } = useFormContext<UniverseFormData>();
const classes = useFormFieldStyles();
const helperClasses = useStyles();
Expand All @@ -40,11 +46,11 @@ export const TotalNodesField = ({ disabled }: TotalNodesFieldProps): ReactElemen
const masterPlacement = getValues(MASTER_PLACEMENT_FIELD);
const placements = useWatch({ name: PLACEMENTS_FIELD });
const currentTotalNodes = getValues(TOTAL_NODES_FIELD);
const isKubernetes = provider?.code === CloudType.kubernetes;

const fieldLabel =
provider?.code === CloudType.kubernetes
? t('universeForm.cloudConfig.totalPodsField')
: t('universeForm.cloudConfig.totalNodesField');
const fieldLabel = isKubernetes
? t('universeForm.cloudConfig.totalPodsField')
: t('universeForm.cloudConfig.totalNodesField');

const handleChange = (e: FocusEvent<HTMLInputElement>) => {
//reset field value to replication factor if field is empty or less than RF
Expand All @@ -69,7 +75,9 @@ export const TotalNodesField = ({ disabled }: TotalNodesFieldProps): ReactElemen
if (totalNodesinAz >= replicationFactor) setValue(TOTAL_NODES_FIELD, totalNodesinAz);
}
}, [placements]);
const isDedicatedNodes = masterPlacement === MasterPlacementMode.DEDICATED;
const isDedicatedNodes =
masterPlacement === MasterPlacementMode.DEDICATED ||
(isKubernetes && isPrimary && useK8CustomResources);

const numNodesElement = (
<Box display="flex" flexDirection="row">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@ export const CloudConfiguration = ({ runtimeConfigs }: UniverseFormConfiguration
const useK8CustomResourcesObject = runtimeConfigs?.configEntries?.find(
(c: RunTimeConfigEntry) => c.key === RuntimeConfigKey.USE_K8_CUSTOM_RESOURCES_FEATURE_FLAG
);
const isRfChangeEnabled = runtimeConfigs?.configEntries?.find(
const isRfChangeEnabled =
runtimeConfigs?.configEntries?.find(
(c: RunTimeConfigEntry) => c.key === RuntimeConfigKey.RF_CHANGE_FEATURE_FLAG
)?.value === 'true';
)?.value === 'true';

const useK8CustomResources = !!(useK8CustomResourcesObject?.value === 'true');
const isDedicatedNodesEnabled = !!(enableDedicatedNodesObject?.value === 'true');
Expand Down Expand Up @@ -112,11 +113,18 @@ export const CloudConfiguration = ({ runtimeConfigs }: UniverseFormConfiguration
</Box>
)}
<Box mt={2}>
<TotalNodesField disabled={isViewMode} />
<TotalNodesField
disabled={isViewMode}
isPrimary={isPrimary}
useK8CustomResources={useK8CustomResources}
/>
</Box>
<Box mt={2}>
<ReplicationFactor disabled={isViewMode || (isEditPrimary && !isRfChangeEnabled)}
isPrimary={isPrimary} isEditMode={isEditMode} />
<ReplicationFactor
disabled={isViewMode || (isEditPrimary && !isRfChangeEnabled)}
isPrimary={isPrimary}
isEditMode={isEditMode}
/>
</Box>
{isPrimary && isGeoPartitionEnabled && (
<Box mt={2} display="flex" flexDirection="column">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ export const InstanceConfiguration = ({ runtimeConfigs }: UniverseFormConfigurat
(c: any) => c.key === RuntimeConfigKey.AWS_COOLDOWN_HOURS
)?.value;

const useK8CustomResourcesObject = runtimeConfigs?.configEntries?.find(
(c: RunTimeConfigEntry) => c.key === 'yb.use_k8s_custom_resources'
);
const useK8CustomResources = !!(useK8CustomResourcesObject?.value === 'true');

const maxVolumeCount = runtimeConfigs?.configEntries?.find(
(c: RunTimeConfigEntry) => c.key === 'yb.max_volume_count'
)?.value;
Expand Down Expand Up @@ -184,10 +189,16 @@ export const InstanceConfiguration = ({ runtimeConfigs }: UniverseFormConfigurat
getDedicatedContainerElement('universeForm.master', true)}
</>
)}
{provider?.code === CloudType.kubernetes &&
{useK8CustomResources &&
provider?.code === CloudType.kubernetes &&
getKubernetesInstanceElement('universeForm.tserver', false)}
{provider?.code === CloudType.kubernetes &&
{useK8CustomResources &&
provider?.code === CloudType.kubernetes &&
isPrimary &&
getKubernetesInstanceElement('universeForm.master', true)}
{provider?.code === CloudType.kubernetes &&
!useK8CustomResources &&
getInstanceMetadataElement(false)}
</Box>
</Grid>
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,9 @@ export const getFormData = (
data.instanceConfig.masterDeviceInfo = userIntent.masterDeviceInfo;
}

if (
data.cloudConfig.provider?.code === CloudType.kubernetes &&
data.cloudConfig.masterPlacement === MasterPlacementMode.DEDICATED
) {
if (data.cloudConfig.provider?.code === CloudType.kubernetes) {
data.instanceConfig.masterK8SNodeResourceSpec = userIntent.masterK8SNodeResourceSpec;
data.instanceConfig.masterDeviceInfo = userIntent.masterDeviceInfo;
}

return data;
Expand Down Expand Up @@ -353,18 +351,16 @@ export const getUserIntent = (
if (!_.isEmpty(proxyConfig)) intent.proxyConfig = proxyConfig;
if (!_.isEmpty(universeOverrides)) intent.universeOverrides = universeOverrides;

if (
cloudConfig.provider?.code === CloudType.kubernetes &&
cloudConfig.masterPlacement === MasterPlacementMode.DEDICATED
) {
intent.masterK8SNodeResourceSpec = instanceConfig.masterK8SNodeResourceSpec;
}

if (cloudConfig.masterPlacement === MasterPlacementMode.DEDICATED) {
intent.masterInstanceType = instanceConfig.masterInstanceType;
intent.masterDeviceInfo = instanceConfig.masterDeviceInfo;
}

if (cloudConfig.provider?.code === CloudType.kubernetes) {
intent.masterK8SNodeResourceSpec = instanceConfig.masterK8SNodeResourceSpec;
intent.masterDeviceInfo = instanceConfig.masterDeviceInfo;
}

if (instanceConfig.enableYSQLAuth && instanceConfig.ysqlPassword)
intent.ysqlPassword = instanceConfig.ysqlPassword;

Expand Down
4 changes: 3 additions & 1 deletion managed/ui/src/utils/UniverseUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,14 @@ export const getUniverseDedicatedNodeCount = (nodeDetailsSet, cluster = null) =>

export const isDedicatedNodePlacement = (currentUniverse) => {
let isDedicatedNodes = false;

if (!currentUniverse?.universeDetails) return isDedicatedNodes;

const clusters = currentUniverse.universeDetails.clusters;
const primaryCluster = clusters && getPrimaryCluster(clusters);
const isK8sUniverse = primaryCluster.userIntent.providerType === 'kubernetes';
isDedicatedNodes = primaryCluster.userIntent.dedicatedNodes;
return isDedicatedNodes;
return isDedicatedNodes || isK8sUniverse;
};

export function getProviderMetadata(provider) {
Expand Down

0 comments on commit 6222c84

Please sign in to comment.