Skip to content

Commit

Permalink
fix: fix invocation
Browse files Browse the repository at this point in the history
  • Loading branch information
utibeabasi6 committed Jan 27, 2024
1 parent 199a0bd commit 2dd7a18
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
9 changes: 4 additions & 5 deletions handlers/invokeHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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 {
Expand All @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion internal/vm/config.go
Original file line number Diff line number Diff line change
@@ -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",
}
Expand Down
3 changes: 0 additions & 3 deletions utils/config.go

This file was deleted.

0 comments on commit 2dd7a18

Please sign in to comment.