Skip to content
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
18 changes: 13 additions & 5 deletions agent/agentlocal/agent_local.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
"sync"
"time"

grpc_gateway "github.com/grpc-ecosystem/grpc-gateway/runtime"
grpc_gateway "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/collectors"
"github.com/prometheus/client_golang/prometheus/promhttp"
Expand All @@ -41,11 +41,13 @@ import (
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/reflection"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/types/known/durationpb"

"github.com/percona/pmm/agent/config"
"github.com/percona/pmm/api/agentlocalpb"
"github.com/percona/pmm/api/agentpb"
pmmerrors "github.com/percona/pmm/utils/errors"
"github.com/percona/pmm/version"
)

Expand Down Expand Up @@ -271,11 +273,17 @@ func (s *Server) runJSONServer(ctx context.Context, grpcAddress string) {

proxyMux := grpc_gateway.NewServeMux(
grpc_gateway.WithMarshalerOption(grpc_gateway.MIMEWildcard, &grpc_gateway.JSONPb{
EmitDefaults: true,
Indent: " ",
OrigName: true,
MarshalOptions: protojson.MarshalOptions{
EmitUnpopulated: true,
Indent: " ",
UseProtoNames: true,
},
UnmarshalOptions: protojson.UnmarshalOptions{
DiscardUnknown: true,
},
}),
)
grpc_gateway.WithErrorHandler(pmmerrors.PMMHTTPErrorHandler))

opts := []grpc.DialOption{
grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithBlock(),
Expand Down
6 changes: 3 additions & 3 deletions agent/commands/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func checkStatus(configFilepath string, l *logrus.Entry) (string, bool) {
case *agent_local.StatusDefault:
msg := fmt.Sprintf("HTTP code %d", err.Code())
if err.Payload != nil {
msg = fmt.Sprintf("%s (gRPC code %d, HTTP code %d)", err.Payload.Error, err.Payload.Code, err.Code())
msg = fmt.Sprintf("%s (gRPC code %d, HTTP code %d)", err.Payload.Message, err.Payload.Code, err.Code())
}
fmt.Printf("pmm-agent is running, but status check failed: %s.\n", msg)
os.Exit(1)
Expand Down Expand Up @@ -140,7 +140,7 @@ func register(cfg *config.Config, l *logrus.Entry) {
if err != nil {
msg := err.Error()
if e, _ := err.(*node.RegisterNodeDefault); e != nil {
msg = e.Payload.Error + ""
msg = e.Payload.Message + ""
switch e.Code() {
case http.StatusConflict:
msg += " If you want override node, use --force option"
Expand All @@ -167,7 +167,7 @@ func reload(l *logrus.Entry) {
err := localReload()
l.Debugf("Reload error: %#v", err)
if err, _ := err.(*agent_local.ReloadDefault); err != nil && err.Code() == int(codes.FailedPrecondition) {
fmt.Printf("Failed to reload configuration: %s.\n", err.Payload.Error)
fmt.Printf("Failed to reload configuration: %s.\n", err.Payload.Message)
os.Exit(1)
}

Expand Down
44 changes: 24 additions & 20 deletions api/agentlocalpb/agentlocal.pb.gw.go

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

67 changes: 24 additions & 43 deletions api/agentlocalpb/json/agentlocalpb.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,33 +48,25 @@
"code": {
"type": "integer",
"format": "int32",
"x-order": 1
"x-order": 0
},
"details": {
"type": "array",
"items": {
"type": "object",
"properties": {
"type_url": {
"@type": {
"type": "string",
"x-order": 0
},
"value": {
"type": "string",
"format": "byte",
"x-order": 1
}
}
},
"additionalProperties": false
},
"x-order": 3
},
"error": {
"type": "string",
"x-order": 0
"x-order": 2
},
"message": {
"type": "string",
"x-order": 2
"x-order": 1
}
}
}
Expand Down Expand Up @@ -232,33 +224,25 @@
"code": {
"type": "integer",
"format": "int32",
"x-order": 1
"x-order": 0
},
"details": {
"type": "array",
"items": {
"type": "object",
"properties": {
"type_url": {
"@type": {
"type": "string",
"x-order": 0
},
"value": {
"type": "string",
"format": "byte",
"x-order": 1
}
}
},
"additionalProperties": false
},
"x-order": 3
},
"error": {
"type": "string",
"x-order": 0
"x-order": 2
},
"message": {
"type": "string",
"x-order": 2
"x-order": 1
}
}
}
Expand Down Expand Up @@ -423,39 +407,36 @@
"code": {
"type": "integer",
"format": "int32",
"x-order": 1
"x-order": 0
},
"details": {
"type": "array",
"items": {
"type": "object",
"properties": {
"type_url": {
"@type": {
"type": "string",
"x-order": 0
},
"value": {
"type": "string",
"format": "byte",
"x-order": 1
}
}
},
"additionalProperties": false
},
"x-order": 3
},
"error": {
"type": "string",
"x-order": 0
"x-order": 2
},
"message": {
"type": "string",
"x-order": 2
"x-order": 1
}
}
}
}
}
}
}
}
},
"tags": [
{
"name": "AgentLocal"
}
]
}
11 changes: 2 additions & 9 deletions api/agentlocalpb/json/client/agent_local/reload_responses.go

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

11 changes: 2 additions & 9 deletions api/agentlocalpb/json/client/agent_local/status2_responses.go

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

Loading