From f223818077b9050205840051b3483b40a27d020c Mon Sep 17 00:00:00 2001 From: Gordon Smith Date: Thu, 7 Dec 2023 17:58:58 +0000 Subject: [PATCH 1/3] Split off 8.12.76 Signed-off-by: Gordon Smith --- helm/hpcc/Chart.yaml | 4 ++-- helm/hpcc/templates/_helpers.tpl | 2 +- helm/hpcc/templates/dafilesrv.yaml | 2 +- helm/hpcc/templates/dali.yaml | 2 +- helm/hpcc/templates/dfuserver.yaml | 2 +- helm/hpcc/templates/eclagent.yaml | 4 ++-- helm/hpcc/templates/eclccserver.yaml | 4 ++-- helm/hpcc/templates/eclscheduler.yaml | 2 +- helm/hpcc/templates/esp.yaml | 2 +- helm/hpcc/templates/localroxie.yaml | 2 +- helm/hpcc/templates/roxie.yaml | 8 ++++---- helm/hpcc/templates/sasha.yaml | 2 +- helm/hpcc/templates/thor.yaml | 10 +++++----- version.cmake | 4 ++-- 14 files changed, 25 insertions(+), 25 deletions(-) diff --git a/helm/hpcc/Chart.yaml b/helm/hpcc/Chart.yaml index 23c0dd827a7..f10a55ecccf 100644 --- a/helm/hpcc/Chart.yaml +++ b/helm/hpcc/Chart.yaml @@ -6,9 +6,9 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. -version: 8.12.75-closedown0 +version: 8.12.77-closedown0 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. -appVersion: 8.12.75-closedown0 +appVersion: 8.12.77-closedown0 diff --git a/helm/hpcc/templates/_helpers.tpl b/helm/hpcc/templates/_helpers.tpl index 3b73f2639c2..371161e132d 100644 --- a/helm/hpcc/templates/_helpers.tpl +++ b/helm/hpcc/templates/_helpers.tpl @@ -1240,7 +1240,7 @@ kind: Service metadata: name: {{ $lvars.serviceName | quote }} labels: - helmVersion: 8.12.75-closedown0 + helmVersion: 8.12.77-closedown0 {{- include "hpcc.addStandardLabels" (dict "root" $.root "instance" $lvars.serviceName ) | indent 4 }} {{- if $lvars.labels }} {{ toYaml $lvars.labels | indent 4 }} diff --git a/helm/hpcc/templates/dafilesrv.yaml b/helm/hpcc/templates/dafilesrv.yaml index e7fb1aab83f..77c42b2b7a4 100644 --- a/helm/hpcc/templates/dafilesrv.yaml +++ b/helm/hpcc/templates/dafilesrv.yaml @@ -50,7 +50,7 @@ spec: labels: {{- include "hpcc.addStandardLabels" (dict "root" $ "component" "dafilesrv" "name" "dafilesrv" "instance" .name) | indent 8 }} server: {{ .name | quote }} - helmVersion: 8.12.75-closedown0 + helmVersion: 8.12.77-closedown0 annotations: checksum/config: {{ $configSHA }} spec: diff --git a/helm/hpcc/templates/dali.yaml b/helm/hpcc/templates/dali.yaml index d8685863e0e..de48e4eb845 100644 --- a/helm/hpcc/templates/dali.yaml +++ b/helm/hpcc/templates/dali.yaml @@ -82,7 +82,7 @@ spec: run: {{ $dali.name | quote }} server: {{ $dali.name | quote }} app: dali - helmVersion: 8.12.75-closedown0 + helmVersion: 8.12.77-closedown0 {{- if hasKey $.Values.global "metrics" }} {{- include "hpcc.generateMetricsReporterLabel" $.Values.global.metrics | nindent 8 }} {{- end }} diff --git a/helm/hpcc/templates/dfuserver.yaml b/helm/hpcc/templates/dfuserver.yaml index 8de63c79276..e8145808f16 100644 --- a/helm/hpcc/templates/dfuserver.yaml +++ b/helm/hpcc/templates/dfuserver.yaml @@ -56,7 +56,7 @@ spec: {{- include "hpcc.addStandardLabels" (dict "root" $ "component" "dfuserver" "name" "dfuserver" "instance" .name) | indent 8 }} run: {{ .name | quote }} accessDali: "yes" - helmVersion: 8.12.75-closedown0 + helmVersion: 8.12.77-closedown0 {{- if hasKey . "labels" }} {{ toYaml .labels | indent 8 }} {{- end }} diff --git a/helm/hpcc/templates/eclagent.yaml b/helm/hpcc/templates/eclagent.yaml index d2280945d5f..a9054328555 100644 --- a/helm/hpcc/templates/eclagent.yaml +++ b/helm/hpcc/templates/eclagent.yaml @@ -58,7 +58,7 @@ data: {{- include "hpcc.addStandardLabels" (dict "root" $ "component" $apptype "name" "eclagent" "instance" $appJobName "instanceOf" (printf "%s-job" .me.name)) | indent 12 }} accessDali: "yes" accessEsp: "yes" - helmVersion: 8.12.75-closedown0 + helmVersion: 8.12.77-closedown0 {{- if hasKey .me "labels" }} {{ toYaml .me.labels | indent 12 }} {{- end }} @@ -137,7 +137,7 @@ spec: run: {{ .name | quote }} accessDali: "yes" accessEsp: {{ .useChildProcesses | default false | ternary "yes" "no" | quote }} - helmVersion: 8.12.75-closedown0 + helmVersion: 8.12.77-closedown0 {{- if hasKey . "labels" }} {{ toYaml .labels | indent 8 }} {{- end }} diff --git a/helm/hpcc/templates/eclccserver.yaml b/helm/hpcc/templates/eclccserver.yaml index c0ace1393ab..4ef99a86f1e 100644 --- a/helm/hpcc/templates/eclccserver.yaml +++ b/helm/hpcc/templates/eclccserver.yaml @@ -57,7 +57,7 @@ data: {{- include "hpcc.addStandardLabels" (dict "root" $ "component" "eclccserver" "name" "eclccserver" "instance" $compileJobName "instanceOf" (printf "%s-job" .me.name)) | indent 12 }} accessDali: "yes" accessEsp: "yes" - helmVersion: 8.12.75-closedown0 + helmVersion: 8.12.77-closedown0 {{- if hasKey .me "labels" }} {{ toYaml .me.labels | indent 12 }} {{- end }} @@ -142,7 +142,7 @@ spec: run: {{ .name | quote }} accessDali: "yes" accessEsp: {{ .useChildProcesses | default false | ternary "yes" "no" | quote }} - helmVersion: 8.12.75-closedown0 + helmVersion: 8.12.77-closedown0 {{- if hasKey . "labels" }} {{ toYaml .labels | indent 8 }} {{- end }} diff --git a/helm/hpcc/templates/eclscheduler.yaml b/helm/hpcc/templates/eclscheduler.yaml index 70575278f7c..94bfdd7d827 100644 --- a/helm/hpcc/templates/eclscheduler.yaml +++ b/helm/hpcc/templates/eclscheduler.yaml @@ -64,7 +64,7 @@ spec: run: {{ .name | quote }} accessDali: "yes" accessEsp: "no" - helmVersion: 8.12.75-closedown0 + helmVersion: 8.12.77-closedown0 {{- if hasKey . "labels" }} {{ toYaml .labels | indent 8 }} {{- end }} diff --git a/helm/hpcc/templates/esp.yaml b/helm/hpcc/templates/esp.yaml index fd8861434cf..b4d13fcf7ad 100644 --- a/helm/hpcc/templates/esp.yaml +++ b/helm/hpcc/templates/esp.yaml @@ -117,7 +117,7 @@ spec: server: {{ .name | quote }} accessDali: "yes" app: {{ $application }} - helmVersion: 8.12.75-closedown0 + helmVersion: 8.12.77-closedown0 {{- include "hpcc.addStandardLabels" (dict "root" $ "name" $application "component" "esp" "instance" .name) | indent 8 }} {{- if hasKey $.Values.global "metrics" }} {{- include "hpcc.generateMetricsReporterLabel" $.Values.global.metrics | nindent 8 }} diff --git a/helm/hpcc/templates/localroxie.yaml b/helm/hpcc/templates/localroxie.yaml index 348a90bc0bb..3bda46bbf5c 100644 --- a/helm/hpcc/templates/localroxie.yaml +++ b/helm/hpcc/templates/localroxie.yaml @@ -70,7 +70,7 @@ spec: server: {{ $servername | quote }} accessDali: "yes" accessEsp: "yes" - helmVersion: 8.12.75-closedown0 + helmVersion: 8.12.77-closedown0 {{- include "hpcc.addStandardLabels" (dict "root" $ "component" "roxie-server" "name" "roxie" "instance" $roxie.name) | indent 8 }} {{- if hasKey . "labels" }} {{ toYaml .labels | indent 8 }} diff --git a/helm/hpcc/templates/roxie.yaml b/helm/hpcc/templates/roxie.yaml index 59135ab1f35..bd6475b02b6 100644 --- a/helm/hpcc/templates/roxie.yaml +++ b/helm/hpcc/templates/roxie.yaml @@ -120,7 +120,7 @@ spec: {{- include "hpcc.addStandardLabels" (dict "root" $ "component" "topology-server" "name" "roxie" "instance" $commonCtx.toponame) | indent 8 }} run: {{ $commonCtx.toponame | quote }} roxie-cluster: {{ $roxie.name | quote }} - helmVersion: 8.12.75-closedown0 + helmVersion: 8.12.77-closedown0 {{- if hasKey $.Values.global "metrics" }} {{- include "hpcc.generateMetricsReporterLabel" $.Values.global.metrics | nindent 8}} {{- end }} @@ -180,7 +180,7 @@ kind: Service metadata: name: {{ $commonCtx.toponame | quote }} labels: - helmVersion: 8.12.75-closedown0 + helmVersion: 8.12.77-closedown0 {{- include "hpcc.addStandardLabels" (dict "root" $ "component" "topology-server" "name" "roxie" "instance" $commonCtx.toponame) | indent 4 }} spec: ports: @@ -242,7 +242,7 @@ spec: roxie-cluster: {{ $roxie.name | quote }} accessDali: "yes" accessEsp: "yes" - helmVersion: 8.12.75-closedown0 + helmVersion: 8.12.77-closedown0 {{- include "hpcc.addStandardLabels" (dict "root" $ "component" "roxie-server" "name" "roxie" "instance" $servername) | indent 8 }} {{- if hasKey $.Values.global "metrics" }} {{- include "hpcc.generateMetricsReporterLabel" $.Values.global.metrics | nindent 8}} @@ -347,7 +347,7 @@ spec: roxie-cluster: {{ $roxie.name | quote }} accessDali: "yes" accessEsp: "yes" - helmVersion: 8.12.75-closedown0 + helmVersion: 8.12.77-closedown0 {{- if hasKey $.Values.global "metrics" }} {{- include "hpcc.generateMetricsReporterLabel" $.Values.global.metrics | nindent 8}} {{- end }} diff --git a/helm/hpcc/templates/sasha.yaml b/helm/hpcc/templates/sasha.yaml index d1c2024882f..aa9ef2c6cc0 100644 --- a/helm/hpcc/templates/sasha.yaml +++ b/helm/hpcc/templates/sasha.yaml @@ -52,7 +52,7 @@ spec: run: {{ $serviceName | quote }} server: {{ $serviceName | quote }} accessDali: {{ (has "dali" $sasha.access) | ternary "yes" "no" | quote }} - helmVersion: 8.12.75-closedown0 + helmVersion: 8.12.77-closedown0 {{- if hasKey $sasha "labels" }} {{ toYaml $sasha.labels | indent 8 }} {{- end }} diff --git a/helm/hpcc/templates/thor.yaml b/helm/hpcc/templates/thor.yaml index b3606ca463c..d4d994155a8 100644 --- a/helm/hpcc/templates/thor.yaml +++ b/helm/hpcc/templates/thor.yaml @@ -82,7 +82,7 @@ data: labels: accessDali: "yes" accessEsp: "yes" - helmVersion: 8.12.75-closedown0 + helmVersion: 8.12.77-closedown0 {{- include "hpcc.addStandardLabels" (dict "root" $ "component" "eclagent" "name" "thor" "instance" $eclAgentJobName "instanceOf" (printf "%s-job" .eclAgentName)) | indent 8 }} {{- if hasKey .me "labels" }} {{ toYaml .me.labels | indent 12 }} @@ -149,7 +149,7 @@ data: accessEsp: "yes" app: "thor" component: "thormanager" - helmVersion: 8.12.75-closedown0 + helmVersion: 8.12.77-closedown0 instance: "_HPCC_JOBNAME_" job: "_HPCC_JOBNAME_" {{- include "hpcc.addStandardLabels" (dict "root" $ "component" "thormanager" "name" "thor" "instance" $thorManagerJobName "instanceOf" (printf "%s-thormanager-job" .me.name)) | indent 12 }} @@ -218,7 +218,7 @@ data: accessEsp: "yes" app: "thor" component: "thorworker" - helmVersion: 8.12.75-closedown0 + helmVersion: 8.12.77-closedown0 instance: "_HPCC_JOBNAME_" job: "_HPCC_JOBNAME_" {{- include "hpcc.addStandardLabels" (dict "root" $ "component" "thorworker" "name" "thor" "instance" $thorWorkerJobName "instanceOf" (printf "%s-thorworker-job" .me.name)) | indent 12 }} @@ -353,7 +353,7 @@ spec: accessEsp: {{ $commonCtx.eclAgentUseChildProcesses | ternary "yes" "no" | quote }} app: "thor" component: "thor-eclagent" - helmVersion: 8.12.75-closedown0 + helmVersion: 8.12.77-closedown0 instance: {{ $commonCtx.eclAgentName | quote }} {{- include "hpcc.addStandardLabels" (dict "root" $ "component" "eclagent" "name" "thor" "instance" $commonCtx.eclAgentName ) | indent 8 }} {{- if hasKey $commonCtx.me "labels" }} @@ -418,7 +418,7 @@ spec: accessEsp: "no" app: "thor" component: "thor-thoragent" - helmVersion: 8.12.75-closedown0 + helmVersion: 8.12.77-closedown0 instance: {{ $commonCtx.thorAgentName | quote }} {{- include "hpcc.addStandardLabels" (dict "root" $ "component" "eclagent" "name" "thor" "instance" $commonCtx.thorAgentName ) | indent 8 }} {{- if hasKey $commonCtx.me "labels" }} diff --git a/version.cmake b/version.cmake index 7c33bf959e1..b48a311dcaa 100644 --- a/version.cmake +++ b/version.cmake @@ -5,8 +5,8 @@ set ( HPCC_NAME "Community Edition" ) set ( HPCC_PROJECT "community" ) set ( HPCC_MAJOR 8 ) set ( HPCC_MINOR 12 ) -set ( HPCC_POINT 75 ) +set ( HPCC_POINT 77 ) set ( HPCC_MATURITY "closedown" ) set ( HPCC_SEQUENCE 0 ) -set ( HPCC_TAG_TIMESTAMP "2023-11-30T16:59:48Z" ) +set ( HPCC_TAG_TIMESTAMP "2023-12-07T17:58:58Z" ) ### From 960ebbe39623187904bb74c6d14b49b7b8ab6d57 Mon Sep 17 00:00:00 2001 From: Gavin Halliday Date: Fri, 8 Dec 2023 09:35:23 +0000 Subject: [PATCH 2/3] HPCC-30992 Fix intermittent deadlock in roxie worker->server communication Signed-off-by: Gavin Halliday --- roxie/udplib/udptrs.cpp | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/roxie/udplib/udptrs.cpp b/roxie/udplib/udptrs.cpp index 2ead7e043f0..1c873277dbb 100644 --- a/roxie/udplib/udptrs.cpp +++ b/roxie/udplib/udptrs.cpp @@ -276,11 +276,20 @@ class UdpReceiverEntry : public IUdpReceiverEntry activeFlowSequence = seq; return seq; } + bool hasDataToSend() const { return (packetsQueued.load(std::memory_order_relaxed) || (resendList && resendList->numActive())); } + void setRequestExpiryTime(unsigned newExpiryTime) + { + //requestExpiryTime 0 should only be used if there is no data to send. Ensure it is non zero otherwise. + if (newExpiryTime == 0) + newExpiryTime == 1; + requestExpiryTime.store(newExpiryTime); + } + void sendStart(unsigned packets) { UdpRequestToSendMsg msg; @@ -326,7 +335,7 @@ class UdpReceiverEntry : public IUdpReceiverEntry msg.cmd = flowType::request_to_send; msg.packets = 0; msg.flowSeq = nextFlowSequence(); - requestExpiryTime = msTick() + udpFlowAckTimeout; + setRequestExpiryTime(msTick() + udpFlowAckTimeout); block.leave(); sendRequest(msg, false); } @@ -339,7 +348,7 @@ class UdpReceiverEntry : public IUdpReceiverEntry //The flow event is sent on the data socket, so it needs to wait for all the data to be sent before being received //therefore use the updDataSendTimeout instead of udpFlowAckTimeout - requestExpiryTime = msTick() + updDataSendTimeout; + setRequestExpiryTime(msTick() + updDataSendTimeout); block.leave(); sendRequest(msg, true); } @@ -367,7 +376,7 @@ class UdpReceiverEntry : public IUdpReceiverEntry msg.sendSeq = nextSendSequence; msg.flowSeq = nextFlowSequence(); msg.sourceNode = sourceIP; - requestExpiryTime = msTick() + udpFlowAckTimeout; + setRequestExpiryTime(msTick() + udpFlowAckTimeout); block.leave(); sendRequest(msg, false); } @@ -394,6 +403,11 @@ class UdpReceiverEntry : public IUdpReceiverEntry CLeavableCriticalBlock block(activeCrit); if (maxRequestDeadTimeouts && (timeouts >= maxRequestDeadTimeouts)) { + int timeExpired = msTick()-requestExpiryTime; + StringBuffer s; + EXCLOG(MCoperatorError,"ERROR: UdpSender: too many timeouts - aborting sends. Timed out %i times (flow=%u, max=%i, timeout=%u, expiryTime=%u[%u] ack(%u)) waiting ok_to_send for %u packets from node=%s", + timeouts.load(), activeFlowSequence.load(), maxRequestDeadTimeouts, udpFlowAckTimeout, requestExpiryTime.load(), timeExpired, (int)hadAcknowledgement, packetsQueued.load(), ip.getIpText(s).str()); + abort(); return; } @@ -405,7 +419,7 @@ class UdpReceiverEntry : public IUdpReceiverEntry msg.sendSeq = nextSendSequence; msg.flowSeq = activeFlowSequence; msg.sourceNode = sourceIP; - requestExpiryTime = msTick() + udpFlowAckTimeout; + setRequestExpiryTime(msTick() + udpFlowAckTimeout); block.leave(); sendRequest(msg, false); } @@ -430,7 +444,7 @@ class UdpReceiverEntry : public IUdpReceiverEntry hadAcknowledgement = true; CriticalBlock b(activeCrit); if (requestExpiryTime) - requestExpiryTime = msTick() + udpRequestTimeout; // set a timeout in case an ok_to_send message goes missing + setRequestExpiryTime(msTick() + udpRequestTimeout); // set a timeout in case an ok_to_send message goes missing } #ifdef TEST_DROPPED_PACKETS @@ -655,8 +669,11 @@ class UdpReceiverEntry : public IUdpReceiverEntry DBGLOG("UdpSender: abort sending queued data to node=%s", ip.getIpText(s).str()); } timeouts = 0; - requestExpiryTime = 0; removeData(nullptr, nullptr); + + CriticalBlock block(activeCrit); + if (packetsQueued == 0) + requestExpiryTime = 0; } inline void pushData(unsigned queue, DataBuffer *buffer) From 161548e00bb7a19ec6486f3ba530a85347d0a943 Mon Sep 17 00:00:00 2001 From: Gordon Smith Date: Fri, 8 Dec 2023 15:37:05 +0000 Subject: [PATCH 3/3] HPCC-30983 Honour direct URLs to ECL Watch Bypass the user nominated selection when direct URLs are provided. Signed-off-by: Gordon Smith --- esp/src/eclwatch/stub.js | 20 ++-------- esp/src/src-react/index.tsx | 77 +++++++++++++++++++------------------ esp/src/src/Session.ts | 75 ++++++++++++++++++++++++++++++++++-- 3 files changed, 114 insertions(+), 58 deletions(-) diff --git a/esp/src/eclwatch/stub.js b/esp/src/eclwatch/stub.js index 9626bcc47b4..e5bca2b0447 100644 --- a/esp/src/eclwatch/stub.js +++ b/esp/src/eclwatch/stub.js @@ -10,8 +10,6 @@ define([ "src/Utility", "src/Session", - "src/KeyValStore", - "src/BuildInfo", "hpcc/LockDialogWidget", "dojox/html/entities", @@ -22,7 +20,7 @@ define([ "css!hpcc/css/hpcc.css" ], function (fx, dom, domStyle, ioQuery, ready, lang, arrayUtil, topic, - Utility, Session, KeyValStore, BuildInfo, LockDialogWidget, + Utility, Session, LockDialogWidget, entities, Toaster) { Session.initSession(); @@ -30,20 +28,8 @@ define([ const params = ioQuery.queryToObject(dojo.doc.location.search.substr((dojo.doc.location.search.substr(0, 1) === "?" ? 1 : 0))); const hpccWidget = params.Widget ? params.Widget : "HPCCPlatformWidget"; - const store = KeyValStore.userKeyValStore(); - store.getEx(BuildInfo.ModernMode, { defaultValue: String(BuildInfo.containerized) }).then(modernMode => { - if (modernMode === String(true) && hpccWidget !== "IFrameWidget") { - switch (hpccWidget) { - case "WUDetailsWidget": - window.location.replace(`/esp/files/index.html#/workunits/${params.Wuid}`); - break; - case "GraphsWUWidget": - window.location.replace(`/esp/files/index.html#/workunits/${params.Wuid}/metrics`); - break; - default: - window.location.replace("/esp/files/index.html"); - } - } else { + Session.needsRedirectV5().then(redirected => { + if (!redirected) { ready(function () { parseUrl(); initUI(); diff --git a/esp/src/src-react/index.tsx b/esp/src/src-react/index.tsx index 9a311de9e15..b1ecffcc918 100644 --- a/esp/src/src-react/index.tsx +++ b/esp/src/src-react/index.tsx @@ -2,8 +2,8 @@ import * as React from "react"; import * as ReactDOM from "react-dom"; import { initializeIcons } from "@fluentui/react"; import { scopedLogger } from "@hpcc-js/util"; -import { cookieKeyValStore, userKeyValStore } from "src/KeyValStore"; -import { containerized, ModernMode } from "src/BuildInfo"; +import { cookieKeyValStore } from "src/KeyValStore"; +import { needsRedirectV9 } from "src/Session"; import { ECLWatchLogger } from "./hooks/logging"; import { replaceUrl } from "./util/history"; @@ -32,42 +32,43 @@ dojoConfig.urlInfo = { }; dojoConfig.disableLegacyHashing = true; -const store = userKeyValStore(); -store.getEx(ModernMode, { defaultValue: String(containerized) }).then(async modernMode => { - if (modernMode === String(false)) { - window.location.replace("/esp/files/stub.htm"); +needsRedirectV9().then(async redirected => { + if (!redirected) { + loadUI(); + } +}); + +async function loadUI() { + const authTypeResp = await fetch("/esp/getauthtype"); + const authType = await authTypeResp?.text() ?? "None"; + const userStore = cookieKeyValStore(); + const userSession = await userStore.getAll(); + if (authType.indexOf("None") < 0 && (userSession["ESPSessionState"] === "false" || userSession["ECLWatchUser"] === "false" || (!userSession["Status"] || userSession["Status"] === "Locked"))) { + if (window.location.hash.indexOf("login") < 0) { + replaceUrl("/login"); + } + import("./components/forms/Login").then(_ => { + try { + ReactDOM.render( + <_.Login />, + document.getElementById("placeholder") + ); + document.getElementById("loadingOverlay").remove(); + } catch (e) { + logger.error(e); + } + }); } else { - const authTypeResp = await fetch("/esp/getauthtype"); - const authType = await authTypeResp?.text() ?? "None"; - const userStore = cookieKeyValStore(); - const userSession = await userStore.getAll(); - if (authType.indexOf("None") < 0 && (userSession["ESPSessionState"] === "false" || userSession["ECLWatchUser"] === "false" || (!userSession["Status"] || userSession["Status"] === "Locked"))) { - if (window.location.hash.indexOf("login") < 0) { - replaceUrl("/login"); + import("./components/Frame").then(_ => { + try { + ReactDOM.render( + <_.Frame />, + document.getElementById("placeholder") + ); + document.getElementById("loadingOverlay").remove(); + } catch (e) { + logger.error(e); } - import("./components/forms/Login").then(_ => { - try { - ReactDOM.render( - <_.Login />, - document.getElementById("placeholder") - ); - document.getElementById("loadingOverlay").remove(); - } catch (e) { - logger.error(e); - } - }); - } else { - import("./components/Frame").then(_ => { - try { - ReactDOM.render( - <_.Frame />, - document.getElementById("placeholder") - ); - document.getElementById("loadingOverlay").remove(); - } catch (e) { - logger.error(e); - } - }); - } + }); } -}); +} diff --git a/esp/src/src/Session.ts b/esp/src/src/Session.ts index 530fe131694..15928b8b088 100644 --- a/esp/src/src/Session.ts +++ b/esp/src/src/Session.ts @@ -3,8 +3,10 @@ import * as xhr from "dojo/request/xhr"; import * as topic from "dojo/topic"; import { format as d3Format } from "@hpcc-js/common"; import { SMCService } from "@hpcc-js/comms"; -import { cookieKeyValStore } from "src/KeyValStore"; +import { cookieKeyValStore, sessionKeyValStore, userKeyValStore } from "src/KeyValStore"; import { singletonDebounce } from "../src-react/util/throttle"; +import { parseSearch } from "../src-react/util/history"; +import { ModernMode } from "./BuildInfo"; import * as ESPUtil from "./ESPUtil"; import { scopedLogger } from "@hpcc-js/util"; @@ -20,7 +22,74 @@ let _prevReset = Date.now(); declare const dojoConfig; -const userStore = cookieKeyValStore(); +const cookieStore = cookieKeyValStore(); +const sessionStore = sessionKeyValStore(); +const userStore = userKeyValStore(); + +export async function fetchModernMode(): Promise { + return Promise.all([ + sessionStore.get(ModernMode), + userStore.getEx(ModernMode, { defaultValue: String(true) }) + ]).then(([sessionModernMode, userModernMode]) => { + return sessionModernMode ?? userModernMode; + }); +} + +const isV5DirectURL = () => !!parseSearch(window.location.search)?.["Widget"]; +const isV9DirectURL = () => window.location.hash && window.location.hash.indexOf("#/stub/") !== 0; + +export async function needsRedirectV5(): Promise { + if (isV9DirectURL()) { + window.location.replace(`/esp/files/index.html${window.location.hash}`); + return true; + } + if (isV5DirectURL()) { + return false; + } + + const v9Mode = await fetchModernMode() === String(true); + if (v9Mode) { + const params = parseSearch(window.location.search); + if (params?.["hpccWidget"] !== "IFrameWidget") { + switch (params?.["hpccWidget"]) { + case "WUDetailsWidget": + window.location.replace(`/esp/files/index.html#/workunits/${params.Wuid}`); + break; + case "GraphsWUWidget": + window.location.replace(`/esp/files/index.html#/workunits/${params.Wuid}/metrics`); + break; + case "TopologyWidget": + case "DiskUsageWidget": + case "TargetClustersQueryWidget": + case "ClusterProcessesQueryWidget": + case "SystemServersQueryWidget": + case "LogWidget": + return false; + default: + window.location.replace("/esp/files/index.html"); + } + return true; + } + } + return false; +} + +export async function needsRedirectV9(): Promise { + if (isV5DirectURL()) { + window.location.replace(`/esp/files/stub.htm${window.location.search}`); + return true; + } + if (isV9DirectURL()) { + return false; + } + + const v5Mode = await fetchModernMode() === String(false); + if (v5Mode) { + window.location.replace(`/esp/files/stub.htm${window.location.search}`); + return true; + } + return false; +} const smc = new SMCService({ baseUrl: "" }); @@ -95,7 +164,7 @@ export function fireIdle() { } async function resetESPTime() { - const userSession = userStore.getAll(); + const userSession = cookieStore.getAll(); if (!userSession || !userSession["ECLWatchUser"] || !userSession["Status"] || userSession["Status"] === "Locked") return; if (Date.now() - _prevReset > SESSION_RESET_FREQ) { _prevReset = Date.now();