shahar1 commented on code in PR #56163:
URL: https://github.com/apache/airflow/pull/56163#discussion_r2386299088
##########
airflow-core/src/airflow/ui/src/pages/Dashboard/PoolSummary/PoolSummary.tsx:
##########
@@ -17,25 +17,42 @@
* under the License.
*/
import { Box, Heading, Flex, Skeleton, Link } from "@chakra-ui/react";
+import { useState } from "react";
import { useTranslation } from "react-i18next";
import { BiTargetLock } from "react-icons/bi";
import { Link as RouterLink } from "react-router-dom";
import { useAuthLinksServiceGetAuthMenus } from "openapi/queries";
import { usePoolServiceGetPools } from "openapi/queries/queries";
+import type { ExpandedApiError } from "src/components/ErrorAlert";
+import { ErrorAlert } from "src/components/ErrorAlert";
import { PoolBar } from "src/components/PoolBar";
import { useAutoRefresh } from "src/utils";
import { type Slots, slotKeys } from "src/utils/slots";
export const PoolSummary = () => {
const { t: translate } = useTranslation("dashboard");
const refetchInterval = useAutoRefresh({});
- const { data, isLoading } = usePoolServiceGetPools(undefined, undefined, {
- refetchInterval,
- });
+
const { data: authLinks } = useAuthLinksServiceGetAuthMenus();
const hasPoolsAccess = authLinks?.authorized_menu_items.includes("Pools");
+ const [hasPermissionError, setHasPermissionError] = useState(false);
+
+ const { data, error, isLoading } = usePoolServiceGetPools(undefined,
undefined, {
+ enabled: !hasPermissionError,
+ refetchInterval: hasPermissionError ? false : refetchInterval,
+ retry: (failureCount, retryError) => {
+ if (Boolean(retryError) && (retryError as ExpandedApiError).status ===
403) {
+ setHasPermissionError(true);
+
+ return false;
+ }
+
+ return failureCount < 3;
Review Comment:
Small nit - Could you please make `3` a constant? (`MAX_API_POLL_ATTEMPTS`,
or something like that)
While 3 is almost a synonym in Airflow for max. number of tries, it will
make it easier for other contributors to understand this code part, and it will
be easier to make it configurable if we find it necessary at some point.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]