Skip to content

Commit

Permalink
merged main
Browse files Browse the repository at this point in the history
  • Loading branch information
Sarthak160 committed Nov 4, 2024
1 parent 0658752 commit 444f317
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 17 deletions.
Binary file modified pkg/agent/hooks/bpf_arm64_bpfel.o
Binary file not shown.
Binary file modified pkg/agent/hooks/bpf_x86_bpfel.o
Binary file not shown.
3 changes: 2 additions & 1 deletion pkg/agent/hooks/conn/socket.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,12 @@ func data(ctx context.Context, id uint64, c *Factory, l *zap.Logger, m *ebpf.Map
return errors.New("failed to get the error group from the context")
}
g.Go(func() error {
fmt.Println("INSIDE GOROUTINE !!")
defer utils.Recover(l)
go func() {
fmt.Println("INSIDE GOROUTINE 222 !!")
defer utils.Recover(l)
for {
// fmt.Println("Starting the data listener", id)
record, err := r.Read()
if err != nil {
if !errors.Is(err, ringbuf.ErrClosed) {
Expand Down
3 changes: 0 additions & 3 deletions pkg/agent/hooks/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -480,9 +480,6 @@ func (h *Hooks) load(opts agent.HookCfg) error {

func (h *Hooks) Record(ctx context.Context, clientID uint64, opts models.IncomingOptions) (<-chan *models.TestCase, error) {
fmt.Println("Recording hooks...")
// use mutex to avoid
// h.m.Lock()
// defer h.m.Unlock()
return conn.ListenSocket(ctx, h.logger, clientID, h.objects.SocketOpenEvents, h.objects.SocketDataEvents, h.objects.SocketCloseEvents, opts)
}

Expand Down
4 changes: 3 additions & 1 deletion pkg/agent/routes/record.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,10 @@ func (a *AgentRequest) HandleOutgoing(w http.ResponseWriter, r *http.Request) {
if m != nil {
render.JSON(w, r, m)
flusher.Flush()
} else {
render.JSON(w, r, "No more mocks")
flusher.Flush()
}
// Client closed the connection or context was cancelled
return
default:
// Stream each mock as JSON
Expand Down
1 change: 0 additions & 1 deletion pkg/client/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ func (a *App) SetupCompose() error {
}

//check if compose file has keploy-init container

// adding keploy init pid to the compose file
err = a.docker.SetInitPid(compose)
if err != nil {
Expand Down
21 changes: 10 additions & 11 deletions pkg/platform/http/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,6 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/docker/docker/api/types/events"
"go.keploy.io/server/v2/config"
"go.keploy.io/server/v2/pkg/agent/hooks"
"go.keploy.io/server/v2/pkg/client/app"
"go.keploy.io/server/v2/pkg/models"
kdocker "go.keploy.io/server/v2/pkg/platform/docker"
"go.keploy.io/server/v2/utils"
"go.uber.org/zap"
"golang.org/x/sync/errgroup"
"io"
"net/http"
"os"
Expand All @@ -28,6 +19,16 @@ import (
"sync"
"syscall"
"time"

"github.com/docker/docker/api/types/events"
"go.keploy.io/server/v2/config"
"go.keploy.io/server/v2/pkg/agent/hooks"
"go.keploy.io/server/v2/pkg/client/app"
"go.keploy.io/server/v2/pkg/models"
kdocker "go.keploy.io/server/v2/pkg/platform/docker"
"go.keploy.io/server/v2/utils"
"go.uber.org/zap"
"golang.org/x/sync/errgroup"
)

type AgentClient struct {
Expand Down Expand Up @@ -371,7 +372,6 @@ func (a *AgentClient) Run(ctx context.Context, clientID uint64, _ models.RunOpti
func (a *AgentClient) Setup(ctx context.Context, cmd string, opts models.SetupOptions) (uint64, error) {

clientID := utils.GenerateID()
// var clientID uint64
isDockerCmd := utils.IsDockerCmd(utils.CmdType(opts.CommandType))

// check if the agent is running
Expand Down Expand Up @@ -429,7 +429,6 @@ func (a *AgentClient) Setup(ctx context.Context, cmd string, opts models.SetupOp
// Channel to monitor if the agent is up and running
runningChan := make(chan bool)

// Start a goroutine to check if the agent is running
go func() {
for {
select {
Expand Down

0 comments on commit 444f317

Please sign in to comment.