ansible-collections / ansible-collections/google.cloud

google.cloud.gcp_compute_snapshot_info: unable to get list of snapshots filtered by creationTimestamp

Open
#488 1 comment 0 reactions 0 assignees View on GitHub
stale
Dominant language
Python
Stars
105
Forks
144
Avg merge
5d 10h
Merged PRs (30d)
4

Description

##### SUMMARY
google.cloud.gcp_compute_snapshot_info: unable to get list of snapshots filtered by creationTimestamp

##### ISSUE TYPE
- Bug Report

##### COMPONENT NAME
google.cloud.gcp_compute_snapshot_info

##### ANSIBLE VERSION
ansible 2.10.17
python version = 3.6.9

##### COLLECTION VERSION

```paste below
ansible-galaxy collection list
11:15:56 # /usr/local/lib/python3.6/dist-packages/ansible_collections
11:15:56 Collection Version
11:15:56 ------------------------- -------
11:15:56 google.cloud 1.0.2
```

##### CONFIGURATION
Unable to get ansible-config at this moment beacase I'm not an owner ansible host.

```paste below

```

##### OS / ENVIRONMENT

##### STEPS TO REPRODUCE

Create persistent disk snapshot with label: stage=pretask

```yaml
- name: 'Test'
hosts: localhost
gather_facts: no
tasks:
- name: 'Get list of snapshots'
google.cloud.gcp_compute_snapshot_info:
filters:
- 'labels.stage=pretask'
- 'creationTimestamp>-P1D'
service_account_file:
project: < project_id >
auth_kind: 'serviceaccount'
register: snapshots_reg
```

##### EXPECTED RESULTS
To get list of snapshots filtered by creationTimestamp

gcloud compute snapshots list --project="" --filter="labels.stage=pretask AND creationTimestamp>-P1D"
NAME DISK_SIZE_GB SRC_DISK STATUS
disk1-20220624084057-ox2m4ddt 50 zone/disks/disk1 READY

##### ACTUAL RESULTS
Invalid list filter expression

```paste below
11:16:08 TASK [Get list of snapshots] ***************************************************
11:16:08 Friday 24 June 2022 09:16:08 +0000 (0:00:00.234) 0:00:00.511 ***********
11:16:09 fatal: [localhost]: FAILED! => {"changed": false, "msg": "GCP returned error: {'error': {'code': 400, 'message': \"Invalid value for field 'filter': '(labels.stage=pretask) (creationTimestamp>-P1D)'. Invalid list filter expression.\", 'errors': [{'message': \"Invalid value for field 'filter': '(labels.stage=pretask) (creationTimestamp>-P1D)'. Invalid list filter expression.\", 'domain': 'global', 'reason': 'invalid'}]}}"}
```

Contributor guide

Open the contributing guide

Research direction

Start with the google.cloud.gcp_compute_snapshot_info module and reproduce the supplied playbook using the labels.stage and creationTimestamp filters. Compare its generated filter with the working gcloud command; done means the module accepts the example and returns snapshots matching both filters without an invalid-filter error.

Written by the indexing model from the issue text.

Assessment

Tech stack
google-cloud, python
Domain
cloud
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
67/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.