Skip to content
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

Improve inventory target name resolution #3291

Merged
merged 2 commits into from
May 22, 2024

Commits on May 21, 2024

  1. Always use fnmatch for target wildcard name match

    When resolving a large number of targets from a plan the
    match_wildcard? regex is compiled on the fly possibly
    hundreds or thousands (for a large inventory) of times
    per target name resolution.
    
    Switching to File.fnmatch provides a significant speed
    increase and seems to more accurately reflect the
    functionality stated in the Bolt documentation with
    regards to target matching.
    
    !feature
    
    * **Enable basic glob matching of target strings**
    
      Previously, only the '*' wildcard character would match
      when targets were resolved from areas other than the CLI
      (such as from within a Plan).  With this change wildcard
      matching is switched to use Ruby's fnmatch with basic
      glob matching enabled.  In addition to providing more
      wildcard matching options, it also provides a significant
      performance improvement over the prior implementation.
    seanmil committed May 21, 2024
    Configuration menu
    Copy the full SHA
    47edb66 View commit details
    Browse the repository at this point in the history
  2. Optimize for exact-match target name lookups

    Performing wildcard target name resolution is fairly costly,
    having to search through all group names, target names, and
    target aliases, calling File.fnmatch on each one in order to
    find matches.
    
    In the case of the targets being non-wildcard strings much
    faster exact matching can be performed resulting in a
    significant performance improvement.
    
    !feature
    
    * **Optimize get_targets performance for exact-match cases**
    
      Attempt exact target name matches for strings passed to
      get_targets and only attempt the slower wildcard match if
      the string contains a valid glob wildcard character.
    seanmil committed May 21, 2024
    Configuration menu
    Copy the full SHA
    4d6e563 View commit details
    Browse the repository at this point in the history