Skip to content

Commit

Permalink
chore: fix misleading extra error generated from cluster-agent
Browse files Browse the repository at this point in the history
  • Loading branch information
andylibrian committed Mar 24, 2024
1 parent f49d2ba commit 6f00d86
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion pkg/clusteragent/action_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ func (ah *actionHandler) SyncActions() {
ah.logger.WithError(err).Error("error while getting actions from the server")
}

ah.logger.WithField("actions", r.GetActions()).Debug("received actions from the server")
ah.logger.WithField("actions", r.GetActions()).Trace("received actions from the server")
cancel()

ah.SetActions(r.GetActions())
Expand Down
10 changes: 5 additions & 5 deletions pkg/clusteragent/grpc_servers.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (cs *ConfigServer) EnableAddConstraint(value bool) {
// - *tarianpb.GetConstraintsResponse: The response containing constraints.
// - error: An error if the request fails.
func (cs *ConfigServer) GetConstraints(reqCtx context.Context, request *tarianpb.GetConstraintsRequest) (*tarianpb.GetConstraintsResponse, error) {
cs.logger.Debug("Received get config RPC")
cs.logger.Trace("Received get config RPC")

ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
Expand Down Expand Up @@ -98,7 +98,7 @@ func (cs *ConfigServer) AddConstraint(reqCtx context.Context, request *tarianpb.
defer cancel()

r, err := cs.configClient.AddConstraint(ctx, request)
return r, fmt.Errorf("AddConstraint: %w", err)
return r, err
}

// RemoveConstraint removes a constraint from the Tarian server.
Expand All @@ -121,7 +121,7 @@ func (cs *ConfigServer) RemoveConstraint(reqCtx context.Context, request *tarian

r, err := cs.configClient.RemoveConstraint(ctx, request)

return r, fmt.Errorf("RemoveConstraint: %w", err)
return r, err
}

// Close closes the gRPC connection.
Expand Down Expand Up @@ -187,15 +187,15 @@ func NewEventServer(logger *logrus.Logger, tarianServerAddress string, opts []gr
// - *tarianpb.IngestEventResponse: The response indicating the result of ingesting the event.
// - error: An error if the request fails.
func (es *EventServer) IngestEvent(requestContext context.Context, request *tarianpb.IngestEventRequest) (*tarianpb.IngestEventResponse, error) {
es.logger.Debug("Received ingest violation event RPC")
es.logger.Trace("Received ingest violation event RPC")

ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()

r, err := es.eventClient.IngestEvent(ctx, request)
es.actionHandler.QueueEvent(request.GetEvent())

return r, fmt.Errorf("IngestEvent: %w", err)
return r, err
}

// Close closes the gRPC connection and cancels the context.
Expand Down
4 changes: 2 additions & 2 deletions pkg/nodeagent/nodeagent.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func (n *NodeAgent) SyncConstraints() {
n.logger.WithError(err).Fatal("couldn't get constraints from the cluster agent")
}

n.logger.WithField("constraints", r.GetConstraints()).Debug("received constraints from the cluster agent")
n.logger.WithField("constraints", r.GetConstraints()).Trace("received constraints from the cluster agent")
cancel()

n.SetConstraints(r.GetConstraints())
Expand Down Expand Up @@ -398,7 +398,7 @@ func (n *NodeAgent) RegisterViolationsAsNewConstraint(violation *ProcessViolatio

response, err := n.configClient.AddConstraint(context.Background(), req)
if err != nil {
n.logger.WithError(err).Error("error while registering process constraint")
n.logger.WithError(err).WithField("response", response).Error("error while registering process constraint")
} else {
n.logger.WithField("response", response).Debug("add constraint response")
}
Expand Down
5 changes: 2 additions & 3 deletions pkg/podagent/podagent.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,16 +238,15 @@ func (p *PodAgent) loopSyncConstraints(ctx context.Context) error {

// SyncConstraints retrieves and synchronizes constraints from the cluster agent.
func (p *PodAgent) SyncConstraints() {
p.logger.Debug("syncing constraints from the cluster agent")
p.logger.Trace("syncing constraints from the cluster agent")
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)

r, err := p.configClient.GetConstraints(ctx, &tarianpb.GetConstraintsRequest{Namespace: p.namespace, Labels: p.podLabels})
if err != nil {
p.logger.WithError(err).Fatal("couldn't get constraints from the cluster agent")
}

p.logger.WithField("constraints", r.GetConstraints()).Debug("received constraints from the cluster agent")

p.logger.WithField("constraints", r.GetConstraints()).Trace("received constraints from the cluster agent")
cancel()

p.SetConstraints(r.GetConstraints())
Expand Down
4 changes: 2 additions & 2 deletions pkg/server/config_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (cs *ConfigServer) GetConstraints(ctx context.Context, request *tarianpb.Ge
cs.logger.WithFields(logrus.Fields{
"namespace": request.GetNamespace(),
"labels": request.GetLabels(),
}).Debug("Received get config RPC")
}).Trace("Received get config RPC")

var constraints []*tarianpb.Constraint
var err error
Expand Down Expand Up @@ -228,7 +228,7 @@ func (cs *ConfigServer) GetActions(ctx context.Context, request *tarianpb.GetAct
cs.logger.WithFields(logrus.Fields{
"namespace": request.GetNamespace(),
"labels": request.GetLabels(),
}).Debug("Received get actions RPC")
}).Trace("Received get actions RPC")

var actions []*tarianpb.Action
var err error
Expand Down
2 changes: 1 addition & 1 deletion pkg/tarianpb/types.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6f00d86

Please sign in to comment.