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

contrib/pkg/awstagdeprovision: Allow for OR filters #47

Merged
merged 1 commit into from
Oct 24, 2018

Commits on Oct 24, 2018

  1. contrib/pkg/awstagdeprovision: Allow for OR filters

    AWS docs for filters are a bit sparse, but [1] has:
    
      Combining search filters
    
      In general, multiple filters with the same key field (for example,
      tag:Name, search, Instance State) are automatically joined with OR.
      This is intentional, as the vast majority of filters would not be
      logical if they were joined with AND.  For example, you would get
      zero results for a search on Instance State=running AND Instance
      State=stopped.  In many cases, you can granulate the results by
      using complementary search terms on different key fields, where the
      AND rule is automatically applied instead.  If you search for tag:
      Name:=All values and tag:Instance State=running, you get search
      results that contain both those criteria.  To fine-tune your
      results, simply remove one filter in the string until the results
      fit your requirements.
    
    Unfortunately, there seems to be no way to represent OR filters in
    ec2's Filter structure [2].  With the approach I have here, resources
    that match multiple filters will be fetched multiple times, and may
    have parallel, racing delete attempts.  But we should be robust in the
    face of racing delete attempt, and hopefully one of the deletes will
    go through before too long ;).
    
    It would be possible to adjust our locally-filtered types (which use
    filterObjects) to avoid this issue for those types.  I may do that in
    follow-up work, but for now I'm treating all of our types the same
    way.
    
    I've added the filter information to some of the logs to help
    distinguish between multiple goroutines handling different filters for
    the same resource.
    
    I've also switched hiveutil over to use OR for multiple arguments (it
    used to use AND) at Joel's suggestion [3].
    
    [1]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Filtering.html#advancedsearch
    [2]: https://docs.aws.amazon.com/sdk-for-go/api/service/ec2/#Filter
    [3]: openshift#47 (comment)
    wking committed Oct 24, 2018
    Configuration menu
    Copy the full SHA
    b1cad98 View commit details
    Browse the repository at this point in the history