Skip to content

Commit

Permalink
CarinaControllerIssue added logs
Browse files Browse the repository at this point in the history
  • Loading branch information
srikanthopsmx committed Oct 3, 2024
1 parent ca4ffb8 commit 2c4c976
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
10 changes: 5 additions & 5 deletions app/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func healthcheck(w http.ResponseWriter, r *http.Request) {
}

func runPrometheusHTTPServer(ctx context.Context, port uint16, profile bool) {
fmt.Printf("INSIDE runPrometheusHTTPServer FUNCTION")
fmt.Printf("%s\n", "INSIDE runPrometheusHTTPServer FUNCTION")

_, logger := loggerFromContext(ctx)
logger.Infof("Running HTTP listener for Prometheus on port %d", port)
Expand Down Expand Up @@ -244,7 +244,7 @@ func loadAgentAuthKeyset(ctx context.Context) {
//}

func main() {
fmt.Printf("INSIDE main FUNCTION")
fmt.Printf("%s\n", "INSIDE main FUNCTION")

ctx, cancel := context.WithCancel(context.Background())
defer cancel()
Expand Down Expand Up @@ -343,7 +343,7 @@ func main() {
}

func makeSecretsLoader(ctx context.Context) secrets.SecretLoader {
fmt.Printf("INSIDE makeSecretsLoader FUNCTION")
fmt.Printf("%s\n", "INSIDE makeSecretsLoader FUNCTION")

logger := logging.WithContext(ctx).Sugar()
namespace, ok := os.LookupEnv("POD_NAMESPACE")
Expand All @@ -360,7 +360,7 @@ func makeSecretsLoader(ctx context.Context) secrets.SecretLoader {
}

func generateSomeAgentTokens(c *ControllerConfig, names string) {
fmt.Printf("INSIDE generateSomeAgentTokens FUNCTION")
fmt.Printf("%s\n", "INSIDE generateSomeAgentTokens FUNCTION")

n := strings.Split(names, ",")
for _, name := range n {
Expand All @@ -374,7 +374,7 @@ func generateSomeAgentTokens(c *ControllerConfig, names string) {
}

func generateSomeControlTokens(c *ControllerConfig, names string) {
fmt.Printf("INSIDE generateSomeControlTokens FUNCTION")
fmt.Printf("%s\n", "INSIDE generateSomeControlTokens FUNCTION")
n := strings.Split(names, ",")
for _, name := range n {
name = strings.TrimSpace(name)
Expand Down
22 changes: 11 additions & 11 deletions app/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ type serviceRequest struct {
}

func (s *server) Hello(ctx context.Context, in *pb.HelloRequest) (*pb.HelloResponse, error) {
fmt.Printf("INSIDE Hello FUNCTION")
fmt.Printf("%s\n", "INSIDE Hello FUNCTION")

agentID, _ := IdentityFromContext(ctx)
_, logger := loggerFromContext(ctx)
Expand All @@ -70,7 +70,7 @@ func (s *server) Hello(ctx context.Context, in *pb.HelloRequest) (*pb.HelloRespo
}

func (s *server) Ping(ctx context.Context, in *pb.PingRequest) (*pb.PingResponse, error) {
fmt.Printf("INSIDE Ping FUNCTION")
fmt.Printf("%s\n", "INSIDE Ping FUNCTION")

session, err := agents.findSession(ctx)
if err != nil {
Expand All @@ -86,14 +86,14 @@ func (s *server) Ping(ctx context.Context, in *pb.PingRequest) (*pb.PingResponse
}

func (s *server) closeAgentSession(ctx context.Context, session *AgentContext) {
fmt.Printf("INSIDE closeAgentSession FUNCTION")
fmt.Printf("%s\n", "INSIDE closeAgentSession FUNCTION")

agents.removeSession(session)
s.streamManager.FlushAgent(ctx, session)
}

func (s *server) WaitForRequest(in *pb.WaitForRequestArgs, stream pb.TunnelService_WaitForRequestServer) error {
fmt.Printf("INSIDE waitForRequest FUNCTION")
fmt.Printf("%s\n", "INSIDE waitForRequest FUNCTION")

ctx, logger := loggerFromContext(stream.Context())
session, err := agents.findSession(stream.Context())
Expand Down Expand Up @@ -131,15 +131,15 @@ func (s *server) WaitForRequest(in *pb.WaitForRequestArgs, stream pb.TunnelServi
}

func (s *server) done(ctx context.Context, stream *Stream) {
fmt.Printf("INSIDE done FUNCTION")
fmt.Printf("%s\n", "INSIDE done FUNCTION")

if err := stream.echo.Done(ctx); err != nil {
_ = stream.echo.Fail(ctx, http.StatusTeapot, err)
}
}

func (s *server) getStreamAndID(ctx context.Context, event *pb.StreamFlow) (string, *Stream, error) {
fmt.Printf("INSIDE getStreamAndID FUNCTION")
fmt.Printf("%s\n", "INSIDE getStreamAndID FUNCTION")
var streamID string
if sid, ok := event.Event.(*pb.StreamFlow_StreamId); !ok {
return "", nil, status.Error(codes.InvalidArgument, "first message must be streamID")
Expand All @@ -154,7 +154,7 @@ func (s *server) getStreamAndID(ctx context.Context, event *pb.StreamFlow) (stri
}

func (s *server) DataFlowAgentToController(rpcstream pb.TunnelService_DataFlowAgentToControllerServer) error {
fmt.Printf("INSIDE DataFlowAgentToController FUNCTION ")
fmt.Printf("%s\n", "INSIDE DataFlowAgentToController FUNCTION ")

ctx := rpcstream.Context()
event, err := rpcstream.Recv()
Expand Down Expand Up @@ -203,7 +203,7 @@ func (s *server) DataFlowAgentToController(rpcstream pb.TunnelService_DataFlowAg
}

func findEndpoint(ctx context.Context, serviceName string, serviceType string) (*serviceconfig.ConfiguredEndpoint, bool) {
fmt.Printf("INSIDE findEndpoint FUNCTION ")
fmt.Printf("%s\n", "INSIDE findEndpoint FUNCTION ")

for _, ep := range endpoints {
if ep.Name == serviceName && ep.Type == serviceType {
Expand All @@ -214,7 +214,7 @@ func findEndpoint(ctx context.Context, serviceName string, serviceType string) (
}

func (s *server) RunRequest(in *pb.TunnelRequest, stream pb.TunnelService_RunRequestServer) error {
fmt.Printf("INSIDE RunRequest FUNCTION ")
fmt.Printf("%s\n", "INSIDE RunRequest FUNCTION ")

agentID, sesisonID := IdentityFromContext(stream.Context())
ctx := logging.NewContext(stream.Context(),
Expand Down Expand Up @@ -276,7 +276,7 @@ func (s *server) RunRequest(in *pb.TunnelRequest, stream pb.TunnelService_RunReq
}

func loadTLSCredentials(tlsPath string) (credentials.TransportCredentials, error) {
fmt.Printf("INSIDE loadTLSCredentials FUNCTION ")
fmt.Printf("%s\n", "INSIDE loadTLSCredentials FUNCTION ")
serverCert, err := tls.LoadX509KeyPair(path.Join(tlsPath, "tls.crt"), path.Join(tlsPath, "tls.key"))
if err != nil {
return nil, err
Expand All @@ -292,7 +292,7 @@ func loadTLSCredentials(tlsPath string) (credentials.TransportCredentials, error
}

func runAgentGRPCServer(ctx context.Context, tlsPath string) {
fmt.Printf("INSIDE runAgentGRPCServer FUNCTION")
fmt.Printf("%s\n", "INSIDE runAgentGRPCServer FUNCTION")

ctx, logger := loggerFromContext(ctx, zap.String("component", "grpcServer"))
logger.Infow("starting agent GRPC server", "port", config.AgentListenPort)
Expand Down
2 changes: 1 addition & 1 deletion internal/util/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func httpError(err error) []byte {
// and write to the message body a JSON format error message. The http.ResponseWriter
// should not have been used, or be used after calling FailRequest.
func FailRequest(ctx context.Context, w http.ResponseWriter, err error, code int) {
fmt.Printf("INSIDE FailReqeust FUNCTION")
fmt.Printf("%s\n", "INSIDE FailReqeust FUNCTION")

logger := logging.WithContext(ctx).Sugar()
w.WriteHeader(code)
Expand Down

0 comments on commit 2c4c976

Please sign in to comment.