Skip to content

Commit

Permalink
ready for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
kaganrua committed Aug 21, 2024
1 parent 2fdcdc4 commit c4ce412
Show file tree
Hide file tree
Showing 9 changed files with 126 additions and 73 deletions.
2 changes: 1 addition & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"KubeContext": "zetaforge",
"Local": {
"BucketPort": 8333,
"Driver": "minikube"
"Driver": "docker-desktop"
},

"Cloud": {
Expand Down
2 changes: 1 addition & 1 deletion frontend/electron-builder.json5
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
binaries: ["launch.command"],
},
win: {
target: ["tar.gz"],
target: ["tar.gz", "zip"],
artifactName: "${productName}-${version}-windows-${arch}.${ext}",
},
linux: {
Expand Down
41 changes: 31 additions & 10 deletions frontend/server/express.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -341,19 +341,27 @@ function startExpressServer() {
resolve();
}
});

const regex = /listen tcp :\d+: bind: address already in use/;
anvilProcess.stderr.on("data", (data) => {
console.log(`[server] stderr: ${data}`);
if (
data
.toString()
.toLowerCase()
.includes("failed to fetch kubernetes resources;") ||
data
.toString()
.toLowerCase()
.includes("failed to get client config;") ||
data.toString().toLowerCase().includes("failed to install argo;")
.toString()
.toLowerCase()
.includes("failed to fetch kubernetes resources;") ||
data
.toString()
.toLowerCase()
.includes("failed to get client config;") ||
data.toString().toLowerCase().includes("failed to install argo;") ||
data.toString().toLowerCase().includes("failed to check for minikube profile;") ||
data.toString().toLowerCase().includes("failed to marshall minikube profile;") ||
data.toString().toLowerCase().includes("failed to marshall minikube profile;") ||
data.toString().toLowerCase().includes("failed to find the profile;") ||
data.toString().toLowerCase().includes("failed to check minikube status;") ||
data.toString().toLowerCase().includes("failed to parse profile status;") ||
data.toString().toLowerCase().includes("failed to check for minikube profile;") ||
regex.test(data.toString().toLowerCase())
) {
console.log("AM I THROWING ERROR?")
reject(new Error(`Kubeservices not found: ${data.toString()}`));
Expand Down Expand Up @@ -457,6 +465,7 @@ function startExpressServer() {
resolve();
}
});
const regex = /listen tcp :\d+: bind: address already in use/;

anvilProcess.stderr.on("data", (data) => {
console.log(`[server] stderr: ${data}`);
Expand All @@ -469,7 +478,15 @@ function startExpressServer() {
.toString()
.toLowerCase()
.includes("failed to get client config;") ||
data.toString().toLowerCase().includes("failed to install argo;")
data.toString().toLowerCase().includes("failed to install argo;") ||
data.toString().toLowerCase().includes("failed to check for minikube profile;") ||
data.toString().toLowerCase().includes("failed to marshall minikube profile;") ||
data.toString().toLowerCase().includes("failed to marshall minikube profile;") ||
data.toString().toLowerCase().includes("failed to find the profile;") ||
data.toString().toLowerCase().includes("failed to check minikube status;") ||
data.toString().toLowerCase().includes("failed to parse profile status;") ||
data.toString().toLowerCase().includes("failed to check for minikube profile;") ||
regex.test(data.toString().toLowerCase())
) {
reject(new Error(`Kubeservices not found: ${data.toString()}`));
}
Expand All @@ -483,6 +500,10 @@ function startExpressServer() {
res.sendStatus(200);
})
.catch((err) => {
if(anvilProcess !== null) {
anvilProcess.kill("SIGINT");
anvilProcess = null;
}
res
.status(500)
.send({ err: "Error while launching anvil", kubeErr: err.message });
Expand Down
13 changes: 10 additions & 3 deletions frontend/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import SocketFetcher from "@/components/ui/SocketFetcher";

import "./styles/globals.scss";
import AnvilConfigurationsModal from "./components/ui/modal/AnvilConfigurationsModal";
import StatusModal from "./components/ui/modal/StatusModal";
import { useState, useEffect } from "react";
import axios from "axios";
import { useAtom } from "jotai";
Expand All @@ -37,7 +36,10 @@ export default function App() {
const [errText, setErrText] = useState([]);
const [loading, setIsLoading] = useState(false);
const [configuration] = useAtom(activeConfigurationAtom);
const [successModalOpen, setSuccessModalOpen] = useState(false);

const successMessage = ['You can close configurations modal, and start running pipelines']


useEffect(() => {

Expand Down Expand Up @@ -116,7 +118,8 @@ export default function App() {
const res = await axios.post(`${serverAddress}/launch-anvil-from-config`);
setConfirmationIsOpen(false);
setIsLoading(false);
setConfigOpen(false)
setConfigOpen(false);
setSuccessModalOpen(true)
} catch (err) {
setErrText([err.message]);
setErrModalOpen(true);
Expand All @@ -125,7 +128,6 @@ export default function App() {
};

const closeConfirmation = () => {
console.log("CHECK HERE")
if(!loading) {
setConfirmationIsOpen(false);
setConfigOpen(true);
Expand Down Expand Up @@ -162,6 +164,11 @@ export default function App() {
}}
errorOpen={errModalOpen}
errorMessage={errText}

successHeader="Local Anvil Launched Succesfully"
successClose={() => setSuccessModalOpen(false)}
successOpen={successModalOpen}
successMessage={successMessage}
/>


Expand Down
43 changes: 27 additions & 16 deletions frontend/src/components/ui/AnvilLauncherStatus.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,38 @@ import StatusModal from "./modal/StatusModal";

export default function AnvilLauncherStatus(props) {

return (<>
<StatusModal
modalHeading={props.confirmationHeader}
onRequestSubmit={props.confirmSettings}
onRequestClose={props.confirmationClose}
open={props.confirmationOpen}
message={props.confirmationMessage}
hasLoading={true}
loading={props.loading}
return (
<>
<StatusModal
modalHeading={props.confirmationHeader}
onRequestSubmit={props.confirmSettings}
onRequestClose={props.confirmationClose}
open={props.confirmationOpen}
message={props.confirmationMessage}
hasLoading={true}
loading={props.loading}

/>


<StatusModal
modalHeading={props.errorHeader}
passiveModal
onRequestClose={props.errorClose}
open={props.errorOpen}
message={props.errorMessage}
hasLoading={false}
modalHeading={props.errorHeader}
passiveModal
onRequestClose={props.errorClose}
open={props.errorOpen}
message={props.errorMessage}
hasLoading={false}
/>
</>)

<StatusModal
modalHeading={props.successHeader}
passiveModal
onRequestClose={props.successClose}
open={props.successOpen}
message={props.successMessage}
hasLoading={false}
/>
</>
)

}
11 changes: 1 addition & 10 deletions frontend/src/components/ui/Navbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,7 @@ export default function Navbar({ children }) {
const [configuration] = useAtom(activeConfigurationAtom);
const [disable, setDisable] = useState(false);

const { pingPending, pingError, pingData } = useQuery({
queryKey: ["ping"],
queryFn: async () => {
const res = await ping(configuration);
setDisable(res !== true);
return res;
},
refetchInterval: 2 * 1000,
});


const modalPopper = (content) => {
setModalContent({
Expand All @@ -61,7 +53,6 @@ export default function Navbar({ children }) {
<RunPipelineButton
modalPopper={modalPopper}
action="Run"
disabled={disable}
>
<Play size={20} style={svgOverride} />
</RunPipelineButton>
Expand Down
16 changes: 12 additions & 4 deletions frontend/src/components/ui/RunPipelineButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { activeConfigurationAtom } from "@/atoms/anvilConfigurationsAtom";
import { useLoadServerPipeline } from "@/hooks/useLoadPipeline";
import { ping } from "@/client/anvil";

export default function RunPipelineButton({ children, action, disabled }) {
export default function RunPipelineButton({ children, action}) {
const [editor] = useAtom(drawflowEditorAtom);
const [pipeline] = useImmerAtom(pipelineAtom);
const [_, setWorkspace] = useImmerAtom(workspaceAtom);
Expand All @@ -28,6 +28,15 @@ export default function RunPipelineButton({ children, action, disabled }) {
const queryClient = useQueryClient();
const loadServerPipeline = useLoadServerPipeline();

const { pingPending, pingError, data: pingData } = useQuery({
queryKey: ["ping"],
queryFn: async () => {
const res = await ping(configuration);
return res;
},
refetchInterval: 2 * 1000,
});

const runPipeline = async () => {
if (!validatePipelineExists()) return;
setValidationErrorMsg([]);
Expand Down Expand Up @@ -156,14 +165,13 @@ export default function RunPipelineButton({ children, action, disabled }) {
margin: "5px",
};


return (
<>
<Button
style={styles}
disabled={disabled}
title={"This button is disabled and cannot be clicked."}
disabled={!pingData}
size="sm"
iconDescription="HOVER"
onClick={() => runPipeline()}
>
<span>{action}</span>
Expand Down
41 changes: 15 additions & 26 deletions frontend/src/components/ui/modal/AnvilConfigurationsModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {
import { activeConfigurationAtom } from "@/atoms/anvilConfigurationsAtom";
import axios from "axios";
import { ping } from "@/client/anvil";
import StatusModal from "./StatusModal";
import AnvilLauncherStatus from "../AnvilLauncherStatus";


Expand All @@ -47,9 +46,11 @@ export default function AnvilConfigurationsModal(props) {
useAtom(choosenKubeContexts);
const [selectedDriver] = useAtom(choosenDriver);
const [errModalOpen, setErrModalIsOpen] = useState(false);
const [successModalOpen, setSuccessModalOpen] = useState(false);
const [errMessage, setErrMessage] = useState([]);
const [loading, setIsLoading] = useState(false);
const [userDriver] = useAtom(choosenDriver);
const successMessage = ['You can close configurations modal, and start running pipelines']

function handleNew() {
setInitialConfiguration(undefined);
Expand Down Expand Up @@ -112,6 +113,7 @@ export default function AnvilConfigurationsModal(props) {
const res = await axios.post(`${serverAddress}/launch-anvil`, body);
setIsLoading(false);
setConfirmationIsOpen(false);
setSuccessModalOpen(true)
} catch (err) {
setErrMessage([err.response?.data?.err, err.response?.data?.kubeErr]);
setErrModalIsOpen(true);
Expand All @@ -133,13 +135,6 @@ export default function AnvilConfigurationsModal(props) {
`Driver: ${userDriver}`,
]);
setConfirmationIsOpen(true);
} else {
setConfirmationText([
"Are you sure you want to use remote anvil server with the following settings?",
`ANVIL HOST: ${configuration.anvil.host}`,
`ANVIL PORT: ${configuration.anvil.port}`,
]);
setConfirmationIsOpen(true);
}
};

Expand Down Expand Up @@ -173,6 +168,12 @@ export default function AnvilConfigurationsModal(props) {
}
}

const closeConfirmation = () => {
if(!loading) {
setConfirmationIsOpen(false)
}
}

return (
<>
<ClosableModal
Expand Down Expand Up @@ -222,7 +223,7 @@ export default function AnvilConfigurationsModal(props) {
<AnvilLauncherStatus
confirmationHeader="Are you sure you want to use this setting?"
confirmSettings={confirmSettings}
confirmationClose={() => {console.log("I AM TRYING TO CLOSE"); setConfirmationIsOpen(false) }}
confirmationClose={closeConfirmation}
confirmationOpen={confirmationOpen}
confirmationMessage={confirmationText}
loading={loading}
Expand All @@ -231,24 +232,12 @@ export default function AnvilConfigurationsModal(props) {
errorClose={() => setErrModalIsOpen(false)}
errorOpen={errModalOpen}
errorMessage={errMessage}
/>
{/* <StatusModal
modalHeading="Are you sure you want to use this setting?"
onRequestSubmit={confirmSettings}
onRequestClose={() => setConfirmationIsOpen(false)}
open={confirmationOpen}
message={confirmationText}
hasLoading={true}
loading={loading} />

<StatusModal
modalHeading="Following errors occurred while launching anvil"
passiveModal
onRequestSubmit={() => setErrModalIsOpen(false)}
open={errModalOpen}
message={errMessage} /> */}
successHeader="Local Anvil Launched Succesfully"
successClose={() => setSuccessModalOpen(false)}
successOpen={successModalOpen}
successMessage={successMessage}
/>


</>
Expand Down
Loading

0 comments on commit c4ce412

Please sign in to comment.