diff --git a/handlers/invokeHandler.go b/handlers/invokeHandler.go index b4e8963..07c65d9 100644 --- a/handlers/invokeHandler.go +++ b/handlers/invokeHandler.go @@ -11,7 +11,6 @@ import ( "github.com/labstack/echo/v4" "github.com/runvelocity/windhoek/internal/vm" "github.com/runvelocity/windhoek/models" - "github.com/runvelocity/windhoek/utils" "github.com/sirupsen/logrus" ) @@ -27,10 +26,13 @@ func InvokeHandler(c echo.Context) error { if err := c.Bind(&vmRequest); err != nil { return echo.NewHTTPError(http.StatusBadRequest, err.Error()) } - vmRequest.SocketPath = fmt.Sprintf("%s/firecracker-%s.sock", utils.FC_SOCKETS_PATH, vmRequest.FunctionId) + vmRequest.SocketPath = fmt.Sprintf("%s/firecracker-%s.sock", vm.FC_SOCKETS_PATH, vmRequest.FunctionId) vmManager := vm.VmManager{} m, ctx, err := vmManager.CreateVm(vmRequest) + if err != nil { + return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("error occured while creating vm. %s", err.Error())) + } defer func() { err := m.Shutdown(ctx) if err != nil { @@ -41,9 +43,6 @@ func InvokeHandler(c echo.Context) error { log.Error("Error deleting socket file", vmRequest.SocketPath) } }() - if err != nil { - return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("error occured while creating vm. %s", err.Error())) - } url := fmt.Sprintf("http://%s:3000/invoke", m.Cfg.NetworkInterfaces[0].StaticConfiguration.IPConfiguration.IPAddr.IP.String()) argsJSON, err := json.Marshal(vmRequest.InvokePayload.Args) diff --git a/internal/vm/config.go b/internal/vm/config.go index f42bbd5..9b8ba16 100644 --- a/internal/vm/config.go +++ b/internal/vm/config.go @@ -1,10 +1,11 @@ package vm var ( - KERNEL_IMAGE_PATH = "/root/fckernels/vmlinux" + KERNEL_IMAGE_PATH = "/root/fckernels/hello-vmlinux.bin" KERNEL_ARGS = "console=ttyS0 reboot=k panic=1 pci=off" DEFAULT_CPU_COUNT int64 = 1 DEFAULT_MEMORY_COUNT int64 = 512 + FC_SOCKETS_PATH = "/root/fcsockets" RUNTIMES map[string]string = map[string]string{ "nodejs": "/root/fcruntimes/nodejs-runtime.ext4", } diff --git a/utils/config.go b/utils/config.go deleted file mode 100644 index 598fb4d..0000000 --- a/utils/config.go +++ /dev/null @@ -1,3 +0,0 @@ -package utils - -const FC_SOCKETS_PATH = "/root/fcsockets"