You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cloudstack.apache.org by "nagaboinaramgopal (via GitHub)" <gi...@apache.org> on 2026/09/02 18:05:28 UTC

[PR] fix: AND multiple filters in the pod and cluster data sources [cloudstack-terraform-provider]

nagaboinaramgopal opened a new pull request, #338:
URL: https://github.com/apache/cloudstack-terraform-provider/pull/338

   ### Description
   
   `applyPodFilters` (`data_source_cloudstack_pod.go`) and `applyClusterFilters` (`data_source_cloudstack_cluster.go`) returned `true` as soon as any single filter block matched, so a data source with two or more filters selected a resource that matched only one of them. For example:
   
       data "cloudstack_pod" "p" {
         filter { name = "name"             value = "pod-a" }
         filter { name = "allocation_state" value = "Disabled" }
       }
   
   selects a pod named `pod-a` even when it is actually `Enabled`, because the name filter alone short-circuits to a match. The result is silent selection of the wrong pod or cluster.
   
   Every other data source in the provider (instance, volume, template, and others) ANDs its filters: it returns `false` the moment a filter does not match and `true` only after all match. This aligns pod and cluster with that established behaviour.
   
   ### Testing
   
   Added unit tests `TestApplyPodFiltersAreAndedNotOred` and `TestApplyClusterFiltersAreAndedNotOred` asserting that a resource matching only one of two filters is not selected, and that a resource matching all filters is. They need no live CloudStack:
   
       go test ./cloudstack/ -run 'TestApply(Pod|Cluster)FiltersAreAndedNotOred'
   
   The tests fail against the current code and pass with the fix.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix: AND multiple filters in the pod and cluster data sources [cloudstack-terraform-provider]

Posted by "sureshanaparti (via GitHub)" <gi...@apache.org>.
sureshanaparti merged PR #338:
URL: https://github.com/apache/cloudstack-terraform-provider/pull/338


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix: AND multiple filters in the pod and cluster data sources [cloudstack-terraform-provider]

Posted by "sudo87 (via GitHub)" <gi...@apache.org>.
sudo87 commented on PR #338:
URL: https://github.com/apache/cloudstack-terraform-provider/pull/338#issuecomment-5521100321

   @nagaboinaramgopal Before this fix, zero filters would have returned `false` (no match), but now it returns true. This is  behavior change worth looking into, since filter is Required: true but has no MinItems, so a config with zero filter{} blocks (e.g. an empty dynamic "filter") can still pass validation and hit this path.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org