@@ -47,6 +47,8 @@ import (
4747 "google.golang.org/grpc/status"
4848)
4949
50+ const ODC_ERROR_MAX_LENGTH = 250
51+
5052func handleGetState (ctx context.Context , odcClient * RpcClient , envId string ) (string , error ) {
5153 defer utils .TimeTrackFunction (time .Now (), log .WithPrefix ("odcclient" ))
5254 req := & odcpb.StateRequest {
@@ -78,7 +80,7 @@ func handleGetState(ctx context.Context, odcClient *RpcClient, envId string) (st
7880 newState = rep .Reply .State
7981
8082 if odcErr := rep .Reply .GetError (); odcErr != nil {
81- return newState , fmt .Errorf ("code %d from ODC: %s" , odcErr .GetCode (), odcErr .GetMsg ())
83+ return newState , fmt .Errorf ("code %d from ODC: %s" , odcErr .GetCode (), utils . TruncateString ( odcErr .GetMsg (), ODC_ERROR_MAX_LENGTH ))
8284 }
8385 if replyStatus := rep .Reply .Status ; replyStatus != odcpb .ReplyStatus_SUCCESS {
8486 return newState , fmt .Errorf ("status %s from ODC" , replyStatus .String ())
@@ -188,7 +190,7 @@ func handleStart(ctx context.Context, odcClient *RpcClient, arguments map[string
188190 WithError (err ).
189191 Debugf ("finished call odc.SetProperties, ERROR in response payload" )
190192
191- err = fmt .Errorf ("code %d from ODC: %s" , odcErr .GetCode (), odcErr .GetMsg ())
193+ err = fmt .Errorf ("code %d from ODC: %s" , odcErr .GetCode (), utils . TruncateString ( odcErr .GetMsg (), ODC_ERROR_MAX_LENGTH ))
192194
193195 payload ["odcResponse" ] = & setPropertiesResponse
194196 payloadJson , _ = json .Marshal (payload )
@@ -318,7 +320,7 @@ func handleStart(ctx context.Context, odcClient *RpcClient, arguments map[string
318320 rep .Reply .Hosts = nil
319321
320322 if odcErr := rep .Reply .GetError (); odcErr != nil {
321- err = fmt .Errorf ("code %d from ODC: %s" , odcErr .GetCode (), odcErr .GetMsg ())
323+ err = fmt .Errorf ("code %d from ODC: %s" , odcErr .GetCode (), utils . TruncateString ( odcErr .GetMsg (), ODC_ERROR_MAX_LENGTH ))
322324
323325 payload ["odcResponse" ] = & rep
324326 payloadJson , _ = json .Marshal (payload )
@@ -454,7 +456,7 @@ func handleStop(ctx context.Context, odcClient *RpcClient, arguments map[string]
454456 rep .Reply .Hosts = nil
455457
456458 if odcErr := rep .Reply .GetError (); odcErr != nil {
457- err = fmt .Errorf ("code %d from ODC: %s" , odcErr .GetCode (), odcErr .GetMsg ())
459+ err = fmt .Errorf ("code %d from ODC: %s" , odcErr .GetCode (), utils . TruncateString ( odcErr .GetMsg (), ODC_ERROR_MAX_LENGTH ))
458460
459461 payload ["odcResponse" ] = & rep
460462 payloadJson , _ = json .Marshal (payload )
@@ -640,7 +642,7 @@ func handleCleanup(ctx context.Context, odcClient *RpcClient, arguments map[stri
640642 }
641643
642644 if odcErr := rep .GetError (); odcErr != nil {
643- err = fmt .Errorf ("code %d from ODC: %s" , odcErr .GetCode (), odcErr .GetMsg ())
645+ err = fmt .Errorf ("code %d from ODC: %s" , odcErr .GetCode (), utils . TruncateString ( odcErr .GetMsg (), ODC_ERROR_MAX_LENGTH ))
644646
645647 payload ["odcResponse" ] = & rep
646648 payloadJson , _ = json .Marshal (payload )
@@ -845,7 +847,7 @@ func doReset(ctx context.Context, odcClient *RpcClient, arguments map[string]str
845847 rep .Reply .Hosts = nil
846848
847849 if odcErr := rep .Reply .GetError (); odcErr != nil {
848- err = fmt .Errorf ("code %d from ODC: %s" , odcErr .GetCode (), odcErr .GetMsg ())
850+ err = fmt .Errorf ("code %d from ODC: %s" , odcErr .GetCode (), utils . TruncateString ( odcErr .GetMsg (), ODC_ERROR_MAX_LENGTH ))
849851
850852 payload ["odcResponse" ] = & rep
851853 payloadJson , _ = json .Marshal (payload )
@@ -975,7 +977,7 @@ func doTerminate(ctx context.Context, odcClient *RpcClient, arguments map[string
975977 rep .Reply .Hosts = nil
976978
977979 if odcErr := rep .Reply .GetError (); odcErr != nil {
978- err = fmt .Errorf ("code %d from ODC: %s" , odcErr .GetCode (), odcErr .GetMsg ())
980+ err = fmt .Errorf ("code %d from ODC: %s" , odcErr .GetCode (), utils . TruncateString ( odcErr .GetMsg (), ODC_ERROR_MAX_LENGTH ))
979981
980982 payload ["odcResponse" ] = & rep
981983 payloadJson , _ = json .Marshal (payload )
@@ -1100,7 +1102,7 @@ func doShutdown(ctx context.Context, odcClient *RpcClient, arguments map[string]
11001102 shutdownResponse .Hosts = nil
11011103
11021104 if odcErr := shutdownResponse .GetError (); odcErr != nil {
1103- err = fmt .Errorf ("code %d from ODC: %s" , odcErr .GetCode (), odcErr .GetMsg ())
1105+ err = fmt .Errorf ("code %d from ODC: %s" , odcErr .GetCode (), utils . TruncateString ( odcErr .GetMsg (), ODC_ERROR_MAX_LENGTH ))
11041106
11051107 payload ["odcResponse" ] = & shutdownResponse
11061108 payloadJson , _ = json .Marshal (payload )
@@ -1283,7 +1285,7 @@ func handleRun(ctx context.Context, odcClient *RpcClient, isManualXml bool, argu
12831285 runResponse .Hosts = nil
12841286
12851287 if odcErr := runResponse .GetError (); odcErr != nil {
1286- err = fmt .Errorf ("code %d from ODC: %s" , odcErr .GetCode (), odcErr .GetMsg ())
1288+ err = fmt .Errorf ("code %d from ODC: %s" , odcErr .GetCode (), utils . TruncateString ( odcErr .GetMsg (), ODC_ERROR_MAX_LENGTH ))
12871289 }
12881290 if replyStatus := runResponse .Status ; replyStatus != odcpb .ReplyStatus_SUCCESS {
12891291 payload ["odcResponse" ] = & runResponse
@@ -1427,7 +1429,7 @@ func handleConfigure(ctx context.Context, odcClient *RpcClient, arguments map[st
14271429 WithError (err ).
14281430 Debugf ("finished call odc.SetProperties, ERROR in response payload" )
14291431
1430- err = fmt .Errorf ("code %d from ODC: %s" , odcErr .GetCode (), odcErr .GetMsg ())
1432+ err = fmt .Errorf ("code %d from ODC: %s" , odcErr .GetCode (), utils . TruncateString ( odcErr .GetMsg (), ODC_ERROR_MAX_LENGTH ))
14311433
14321434 payload ["odcResponse" ] = & setPropertiesResponse
14331435 payloadJson , _ = json .Marshal (payload )
@@ -1558,7 +1560,7 @@ func handleConfigure(ctx context.Context, odcClient *RpcClient, arguments map[st
15581560 configureResponse .Reply .Hosts = nil
15591561
15601562 if odcErr := configureResponse .Reply .GetError (); odcErr != nil {
1561- err = fmt .Errorf ("code %d from ODC: %s" , odcErr .GetCode (), odcErr .GetMsg ())
1563+ err = fmt .Errorf ("code %d from ODC: %s" , odcErr .GetCode (), utils . TruncateString ( odcErr .GetMsg (), ODC_ERROR_MAX_LENGTH ))
15621564
15631565 payload ["odcResponse" ] = & configureResponse
15641566 payloadJson , _ = json .Marshal (payload )
0 commit comments