Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix misleading extra error generated from cluster-agent #77

Merged
merged 1 commit into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 event RPC")
es.logger.Trace("Received ingest 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 @@ -170,7 +170,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 @@ -568,7 +568,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
Loading