Просмотр исходного кода

filter out pre-deploy logs from 'all' logs view (#3597)

Feroze Mohideen 2 лет назад
Родитель
Сommit
73742e9e02

+ 1 - 0
dashboard/src/main/home/app-dashboard/app-view/tabs/LogsTab.tsx

@@ -15,6 +15,7 @@ const LogsTab: React.FC = () => {
             appName={appName}
             appName={appName}
             serviceNames={serviceNames}
             serviceNames={serviceNames}
             deploymentTargetId={deploymentTargetId}
             deploymentTargetId={deploymentTargetId}
+            filterPredeploy={true}
         />
         />
     );
     );
 };
 };

+ 11 - 10
dashboard/src/main/home/app-dashboard/validate-apply/logs/Logs.tsx

@@ -25,10 +25,8 @@ import Container from "components/porter/Container";
 import Button from "components/porter/Button";
 import Button from "components/porter/Button";
 import LogFilterContainer from "../../expanded-app/logs/LogFilterContainer";
 import LogFilterContainer from "../../expanded-app/logs/LogFilterContainer";
 import StyledLogs from "../../expanded-app/logs/StyledLogs";
 import StyledLogs from "../../expanded-app/logs/StyledLogs";
-import { AppRevision } from "lib/revisions/types";
 import { useLatestRevisionNumber, useRevisionIdToNumber } from "lib/hooks/useRevisionList";
 import { useLatestRevisionNumber, useRevisionIdToNumber } from "lib/hooks/useRevisionList";
 import { useLocation } from "react-router";
 import { useLocation } from "react-router";
-import { valueExists } from "shared/util";
 
 
 type Props = {
 type Props = {
     projectId: number;
     projectId: number;
@@ -38,6 +36,7 @@ type Props = {
     deploymentTargetId: string;
     deploymentTargetId: string;
     appRevisionId?: string;
     appRevisionId?: string;
     logFilterNames?: LogFilterName[];
     logFilterNames?: LogFilterName[];
+    filterPredeploy?: boolean;
 };
 };
 
 
 const Logs: React.FC<Props> = ({
 const Logs: React.FC<Props> = ({
@@ -48,6 +47,7 @@ const Logs: React.FC<Props> = ({
     deploymentTargetId,
     deploymentTargetId,
     appRevisionId,
     appRevisionId,
     logFilterNames = ["service_name", "revision", "output_stream"],
     logFilterNames = ["service_name", "revision", "output_stream"],
+    filterPredeploy = false,
 }) => {
 }) => {
     const { search } = useLocation();
     const { search } = useLocation();
     const queryParams = new URLSearchParams(search);
     const queryParams = new URLSearchParams(search);
@@ -173,20 +173,21 @@ const Logs: React.FC<Props> = ({
         }, 5000);
         }, 5000);
     };
     };
 
 
-    const { logs, refresh, moveCursor, paginationInfo } = useLogs(
-        projectId,
-        clusterId,
+    const { logs, refresh, moveCursor, paginationInfo } = useLogs({
+        projectID: projectId,
+        clusterID: clusterId,
         selectedFilterValues,
         selectedFilterValues,
         appName,
         appName,
-        selectedFilterValues.service_name,
+        serviceName: selectedFilterValues.service_name,
         deploymentTargetId,
         deploymentTargetId,
-        enteredSearchText,
+        searchParam: enteredSearchText,
         notify,
         notify,
-        setIsLoading,
+        setLoading: setIsLoading,
         revisionIdToNumber,
         revisionIdToNumber,
-        selectedDate,
+        setDate: selectedDate,
         appRevisionId,
         appRevisionId,
-    );
+        filterPredeploy,
+    });
 
 
     useEffect(() => {
     useEffect(() => {
         setFilters([
         setFilters([

+ 23 - 2
dashboard/src/main/home/app-dashboard/validate-apply/logs/utils.ts

@@ -41,7 +41,22 @@ export const parseLogs = (logs: any[] = []): PorterLog[] => {
   });
   });
 };
 };
 
 
-export const useLogs = (
+export const useLogs = ({
+  projectID,
+  clusterID,
+  selectedFilterValues,
+  appName,
+  serviceName,
+  deploymentTargetId,
+  searchParam,
+  notify,
+  setLoading,
+  revisionIdToNumber,
+  setDate,
+  appRevisionId = "",
+  timeRange,
+  filterPredeploy,
+}: {
   projectID: number,
   projectID: number,
   clusterID: number,
   clusterID: number,
   selectedFilterValues: Record<LogFilterName, string>,
   selectedFilterValues: Record<LogFilterName, string>,
@@ -54,11 +69,13 @@ export const useLogs = (
   revisionIdToNumber: Record<string, number>,
   revisionIdToNumber: Record<string, number>,
   // if setDate is set, results are not live
   // if setDate is set, results are not live
   setDate?: Date,
   setDate?: Date,
-  appRevisionId: string = "",
+  appRevisionId?: string,
   timeRange?: {
   timeRange?: {
     startTime?: Dayjs,
     startTime?: Dayjs,
     endTime?: Dayjs,
     endTime?: Dayjs,
   },
   },
+  filterPredeploy: boolean,
+}
 ) => {
 ) => {
   const isLive = !setDate;
   const isLive = !setDate;
   const logsBufferRef = useRef<PorterLog[]>([]);
   const logsBufferRef = useRef<PorterLog[]>([]);
@@ -218,6 +235,10 @@ export const useLogs = (
         return false;
         return false;
       }
       }
 
 
+      if (filterPredeploy && (log.metadata.raw_labels?.porter_run_service_name ?? "").endsWith("predeploy")) {
+        return false;
+      }
+
       if (selectedFilterValues.revision !== GenericLogFilter.getDefaultOption("revision").value &&
       if (selectedFilterValues.revision !== GenericLogFilter.getDefaultOption("revision").value &&
         log.metadata.revision !== selectedFilterValues.revision) {
         log.metadata.revision !== selectedFilterValues.revision) {
         return false;
         return false;