@@ -72,7 +72,7 @@ func buildPermission(c *gin.Context) string {
7272
7373func useStreamedListObjects (
7474 c * gin.Context , client kesselv2.KesselInventoryServiceClient , xrhid * identity.XRHID , permission string ,
75- ) ([]* kesselv2.StreamedListObjectsResponse , time. Duration , error ) {
75+ ) ([]* kesselv2.StreamedListObjectsResponse , error ) {
7676 sloReqContext , sloContextCancel := context .WithCancel (c )
7777 defer sloContextCancel ()
7878
@@ -82,12 +82,20 @@ func useStreamedListObjects(
8282 sloReqContext , client , kesselRbacV2 .PrincipalSubject (xrhid .Identity .User .UserID , "redhat" ), permission , "" ,
8383 ) {
8484 if err != nil {
85- return nil , time .Since (start ), errors .Wrap (err , "failed to receive all from Kessel" )
85+ utils .LogError (
86+ "err" , err .Error (), "receivingDuration" , time .Since (start ), "permission" , permission , "received_count" ,
87+ len (workspaces ), "failed to useStreamedListObjects" ,
88+ )
89+ return nil , err
8690 }
8791 workspaces = append (workspaces , res )
8892 }
8993
90- return workspaces , time .Since (start ), nil
94+ utils .LogDebug (
95+ "workspaces" , workspaces , "receivingDuration" , time .Since (start ), "permission" , permission , "received_count" ,
96+ len (workspaces ), "retrieved workspaces" ,
97+ )
98+ return workspaces , nil
9199}
92100
93101func hasPermissionKessel (c * gin.Context ) {
@@ -99,7 +107,11 @@ func hasPermissionKessel(c *gin.Context) {
99107 })
100108 return
101109 }
102- defer conn .Close ()
110+ defer func () {
111+ if closeErr := conn .Close (); closeErr != nil {
112+ utils .LogError ("err" , closeErr .Error (), "failed to close gRPC client" )
113+ }
114+ }()
103115
104116 xrhid , err := utils .ParseXRHID (c .GetHeader ("x-rh-identity" ))
105117 if err != nil {
@@ -108,19 +120,14 @@ func hasPermissionKessel(c *gin.Context) {
108120 return
109121 }
110122
111- permission := buildPermission (c )
112- workspaces , receivingDuration , err := useStreamedListObjects (c , client , xrhid , permission )
123+ workspaces , err := useStreamedListObjects (c , client , xrhid , buildPermission (c ))
113124 if err != nil {
114- utils .LogError (
115- "err" , err .Error (), "receivingDuration" , receivingDuration , "permission" , permission ,
116- "failed to useStreamedListObjects" ,
117- )
125+ // already logged in useStreamedListObjects
118126 c .AbortWithStatusJSON (http .StatusInternalServerError , utils.ErrorResponse {
119127 Error : "Communication with RBAC failed" ,
120128 })
121129 return
122130 }
123- utils .LogDebug ("workspaces" , workspaces , "receivingDuration" , receivingDuration , "retrieved workspaces" )
124131
125132 inventoryGroups , err := processWorkspaces (workspaces )
126133 if err != nil {
0 commit comments