- 
                Notifications
    
You must be signed in to change notification settings  - Fork 293
 
CP-52881: add mechanism to filter out event fields #6184
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| 
          
            
          
           | 
    @@ -519,6 +519,26 @@ let rec next ~__context = | |
| else | ||
| rpc_of_events relevant | ||
| 
     | 
||
| let omitted = Rpc.Null | ||
| 
     | 
||
| let[@tail_mod_cons] rec maybe_map_fields = function | ||
| | [] -> | ||
| [] | ||
| | (key, _) :: tl when Xapi_globs.StringSet.mem key !Xapi_globs.event_filter -> | ||
| (key, omitted) :: (maybe_map_fields [@tailcall]) tl | ||
| | hd :: tl -> | ||
| hd :: (maybe_map_fields [@tailcall]) tl | ||
| 
     | 
||
| let apply_event_filter = function | ||
| | Rpc.Dict lst as orig -> | ||
| let lst' = maybe_map_fields lst in | ||
| if lst' == lst then | ||
| 
         There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should add a comment that  There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this check worth doing? It seems to me that the only time this condition will be true is when both lists are empty. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this needs quality_gate.sh to change in order to pass CI. So all usages of  There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 
 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are discussions upstream about adding a separate phys_equal to the stdlib to mark purposeful usages, meanwhile I'll update the quality gate and comment. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 
 I don't see how this could possibly be true. let[@tail_mod_cons] rec maybe_map_fields = function
  | [] ->
      []
  | (key, _) :: tl when Xapi_globs.StringSet.mem key !Xapi_globs.event_filter ->
      (key, omitted) :: (maybe_map_fields [@tailcall]) tl
  | hd :: tl ->
      hd :: (maybe_map_fields [@tailcall]) tl
(* ... *)
  | Rpc.Dict lst as orig ->
      let lst' = maybe_map_fields lst in
      if lst' == lst thenThe function  Please correct me if there's something I'm missing. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indeed, the physeuqal optimization is missing from   | 
||
| orig | ||
| else | ||
| Rpc.Dict lst' | ||
| | rpc -> | ||
| rpc | ||
| 
     | 
||
| let from_inner __context session subs from from_t timer batching = | ||
| let open Xapi_database in | ||
| let open From in | ||
| 
          
            
          
           | 
    @@ -658,7 +678,10 @@ let from_inner __context session subs from from_t timer batching = | |
| (fun acc (table, objref, mtime) -> | ||
| let serialiser = Eventgen.find_get_record table in | ||
| try | ||
| let xml = serialiser ~__context ~self:objref () in | ||
| let xml = | ||
| serialiser ~__context ~self:objref () | ||
| |> Option.map apply_event_filter | ||
| in | ||
| let ev = event_of `_mod ?snapshot:xml (table, objref, mtime) in | ||
| if Subscription.event_matches subs ev then ev :: acc else acc | ||
| with _ -> acc | ||
| 
        
          
        
         | 
    @@ -670,7 +693,10 @@ let from_inner __context session subs from from_t timer batching = | |
| (fun acc (table, objref, ctime) -> | ||
| let serialiser = Eventgen.find_get_record table in | ||
| try | ||
| let xml = serialiser ~__context ~self:objref () in | ||
| let xml = | ||
| serialiser ~__context ~self:objref () | ||
| |> Option.map apply_event_filter | ||
| in | ||
| let ev = event_of `add ?snapshot:xml (table, objref, ctime) in | ||
| if Subscription.event_matches subs ev then ev :: acc else acc | ||
| with _ -> acc | ||
| 
          
            
          
           | 
    ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not
filter_map?