Skip to content

Commit

Permalink
fix: 0 desired routing count in endpoint edit page (#2768)
Browse files Browse the repository at this point in the history
**Changes:**

This PR modifies the `ServiceLauncherPageContent` component to use the nullish coalescing operator (`??`) instead of the logical OR operator (`||`) when setting the `desiredRoutingCount` value. This ensures that a value of `0` for `endpoint?.desired_session_count` is respected rather than defaulting to `1`.

**Rationale:**

The previous implementation using `||` would treat `0` as a falsy value, causing it to default to `1`. By using `??`, we now correctly handle cases where `desired_session_count` is explicitly set to `0`, while still defaulting to `1` when the value is `null` or `undefined`.

**Impact:**

This change allows users to set a `desired_session_count` of `0` for endpoints, which may be necessary for certain service configurations or management scenarios.
  • Loading branch information
yomybaby committed Oct 23, 2024
1 parent cf26e16 commit 3e45cde
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 2 deletions.
1 change: 0 additions & 1 deletion react/src/components/BAILink.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { createStyles } from 'antd-style';
import { X } from 'lucide-react';
import React from 'react';
import { Link, LinkProps } from 'react-router-dom';

Expand Down
2 changes: 1 addition & 1 deletion react/src/components/ServiceLauncherPageContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ const ServiceLauncherPageContent: React.FC<ServiceLauncherPageContentProps> = ({
serviceName: endpoint?.name,
resourceGroup: endpoint?.resource_group,
allocationPreset: 'custom',
desiredRoutingCount: endpoint?.desired_session_count || 1,
desiredRoutingCount: endpoint?.desired_session_count ?? 1,
// FIXME: memory doesn't applied to resource allocation
resource: {
cpu: parseInt(JSON.parse(endpoint?.resource_slots)?.cpu),
Expand Down

0 comments on commit 3e45cde

Please sign in to comment.