Skip to content

Commit

Permalink
fix: check if target is localhost in executor
Browse files Browse the repository at this point in the history
  • Loading branch information
mathnogueira committed Sep 5, 2023
1 parent 42f7cbf commit 184d738
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
9 changes: 5 additions & 4 deletions server/executor/trigger_executer_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ func (r triggerExecuterWorker) ProcessItem(ctx context.Context, job Job) {
response.Result.Error = &trigger.TriggerError{
ConnectionError: isConnectionError(err),
RunningOnContainer: isServerRunningInsideContainer(),
TargetsLocalhost: isTargetLocalhost(job.Test.Trigger),
ErrorMessage: err.Error(),
}
}
Expand Down Expand Up @@ -121,13 +122,13 @@ func isConnectionError(err error) bool {
return false
}

func isTargetLocalhost(job Job) bool {
func isTargetLocalhost(t trigger.Trigger) bool {
var endpoint string
switch job.Test.Trigger.Type {
switch t.Type {
case trigger.TriggerTypeHTTP:
endpoint = job.Test.Trigger.HTTP.URL
endpoint = t.HTTP.URL
case trigger.TriggerTypeGRPC:
endpoint = job.Test.Trigger.GRPC.Address
endpoint = t.GRPC.Address
}

url, err := url.Parse(endpoint)
Expand Down
2 changes: 1 addition & 1 deletion server/executor/trigger_result_processor_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (r triggerResultProcessorWorker) ProcessItem(ctx context.Context, job Job)
if triggerResult.Error.ConnectionError {
r.emitUnreachableEndpointEvent(ctx, job, err)

if isTargetLocalhost(job) && triggerResult.Error.RunningOnContainer {
if triggerResult.Error.TargetsLocalhost && triggerResult.Error.RunningOnContainer {
r.emitMismatchEndpointEvent(ctx, job, err)
}
}
Expand Down
1 change: 1 addition & 0 deletions server/test/trigger/trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type (
TriggerError struct {
ConnectionError bool `json:"connectionError"`
RunningOnContainer bool `json:"runningOnContainer"`
TargetsLocalhost bool `json:"targetsLocalhost"`
ErrorMessage string `json:"message"`
}
)
Expand Down

0 comments on commit 184d738

Please sign in to comment.