Status Update
Comments
da...@gmail.com <da...@gmail.com> #2
I tried running the above commands with|without --log-http and these fails if the zones flag is used.
Without the zones flag, gcloud appears to enumerate all zones, and then batch call compute instances list (without the filter); I assume it then post-processes the filter from the results as it returns the correct result.
am...@google.com <am...@google.com> #3
This issue has been forwarded to Cloud SDK engineering team for further investigation. All future updates regarding this should be posted here.
ko...@kolban.cloud <ko...@kolban.cloud> #4
Any update on this one?
mi...@gmail.com <mi...@gmail.com> #5
mi...@gmail.com <mi...@gmail.com> #6
For anyone who reaches here, it works if you replace zone as an filter for zone, like this:
gcloud compute instances list --filter="(tags.items=your-tag) AND (zone=https://www.googleapis.com/compute/v1/projects/{{ your-project }}/zones/{{ the zone }})"
With gcloud version
Google Cloud SDK 297.0.0
alpha 2020.06.12
beta 2020.06.12
bq 2.0.58
core 2020.06.12
gsutil 4.51
kubectl 2020.06.12
dj...@google.com <dj...@google.com> #7
This issue is likely related to the logic that turns filters into a combination of server-side and client-side filters, but it won’t be changed for the moment due to it is associated with other instances that will require more actions, and for this reason is not considered to be changed, so it will be continuing the waiting list.
Nevertheless, the last workaround provided works perfectly for this purpose. Instead of send the zone and the project as a parameter it can be included in the same filter:
gcloud compute instances list --filter="(tags.items={{ your-network-tag }}) AND (zone=https://www.googleapis.com/compute/v1/projects/{{ your-project }}/zones/{{ the zone }})"
dj...@google.com <dj...@google.com> #8
The underline issue is Compute Instances List does not support filtering by an array of object.
no...@sysdig.com <no...@sysdig.com> #9
As pointed out in InstancesService.List
method in "google.golang.org/api/compute/v1"
, meaning that the InstancesListCall.Filter
method
Description
Filter no Zones, succeeds:
```bash
gcloud compute instances list \
--filter="tags.items=${TAG}" \
--project=${PROJECT}
NAME ZONE MACHINE_TYPE
my-machine us-west1-c f1-micro
```
Filter with Zones (and the correct zone) fails:
```bash
gcloud compute instances list \
--filter="tags.items=${TAG}" \
--project=${PROJECT} \
--zone=us-west1-c
ERROR: (gcloud.compute.instances.list) Some requests did not succeed:
- Invalid value for field 'filter': 'tags.items eq ".*\bfreddie\b.*"'. Invalid list filter expression.
```
Removing Filter, retaining Zone, works:
```
gcloud compute instances list \
--project=${PROJECT}
--zones=us-west1-c
NAME ZONE MACHINE_TYPE
my-machine us-west1-c f1-micro
```
Expect to be able to apply (correct) Filters arbitrarily to `gcloud compute instances` and only ever reduce the number of results displayed.
```
gcloud info
Google Cloud SDK [268.0.0]
Platform: [Linux, x86_64] ('Linux', 'hades-canyon', '5.3.0-19-generic', '#20-Ubuntu SMP Fri Oct 18 09:04:39 UTC 2019', 'x86_64', 'x86_64')
Locale: ('en_US', 'UTF-8')
Python Version: [2.7.12 (default, Oct 8 2019, 14:14:10) [GCC 5.4.0 20160609]]
Python Location: [/snap/google-cloud-sdk/104/usr/bin/python2]
Site Packages: [Disabled]
Installation Root: [/snap/google-cloud-sdk/104]
Installed Components:
core: [2019.10.18]
kubectl: [2019.10.18]
beta: [2019.10.18]
gsutil: [4.45]
bq: [2.0.49]
alpha: [2019.10.18]
System PATH: [/snap/google-cloud-sdk/104/usr/bin/:/home/[[REDACTED]]/.cargo/bin:/home/[[REDACTED]]/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin]
Python PATH: [/snap/google-cloud-sdk/104/lib/third_party:/snap/google-cloud-sdk/104/lib:/snap/google-cloud-sdk/104/usr/lib/python2.7/:/snap/google-cloud-sdk/104/usr/lib/python2.7/plat-x86_64-linux-gnu:/snap/google-cloud-sdk/104/usr/lib/python2.7/lib-tk:/snap/google-cloud-sdk/104/usr/lib/python2.7/lib-old:/snap/google-cloud-sdk/104/usr/lib/python2.7/lib-dynload]
Cloud SDK on PATH: [False]
Kubectl on PATH: [/snap/bin/kubectl]
WARNING: There are old versions of the Google Cloud Platform tools on your system PATH.
/usr/bin/snap
Installation Properties: [/snap/google-cloud-sdk/104/properties]
User Config Directory: [/home/[[REDACTED]]/.config/gcloud]
Active Configuration Name: [default]
Active Configuration Path: [/home/[[REDACTED]]/.config/gcloud/configurations/config_default]
Account: [[REDACTED]]
Project: [None]
Current Properties:
[core]
account: [[REDACTED]]
disable_usage_reporting: [True]
Logs Directory: [/home/[[REDACTED]]/.config/gcloud/logs]
Last Log File: [/home/[[REDACTED]]/.config/gcloud/logs/2019.10.29/11.53.08.329644.log]
git: [git version 2.20.1]
ssh: [OpenSSH_8.0p1 Ubuntu-6build1, OpenSSL 1.1.1c 28 May 2019]
```