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

fix: instances column of gcp_compute_instance_group errors for regional groups #670

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

pdecat
Copy link
Contributor

@pdecat pdecat commented Oct 19, 2024

Without this change, the instances column of the gcp_compute_instance_group table triggers an error for regional instance groups:

# steampipe query
Welcome to Steampipe v0.24.2
For more information, type .help
> select name, instances, region_name, zone_name from gcp_compute_instance_group

Error: gcp: googleapi: Error 400: Invalid value for field 'zone': ''. Must be a match of regex '(?:[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?)', invalid (SQLSTATE HV000)

+------------------------------------------------------+-----------+-------------+----------------+
| name                                                 | instances | region_name | zone_name      |
+------------------------------------------------------+-----------+-------------+----------------+
| pdecat-managed-instance-group-stateful-zonal-single  | <null>    |             | europe-west9-a |
| pdecat-managed-instance-group-stateless-zonal-single | <null>    |             | europe-west9-a |
| pdecat-unmanaged-instance-group-zonal-single         | <null>    |             | europe-west9-a |
+------------------------------------------------------+-----------+-------------+----------------+

With this change:

# steampipe query
Welcome to Steampipe v0.24.2
For more information, type .help
> select name, instances, region_name, zone_name from gcp_compute_instance_group
+--------------------------------------------------------+-----------+--------------+----------------+
| name                                                   | instances | region_name  | zone_name      |
+--------------------------------------------------------+-----------+--------------+----------------+
| pdecat-managed-instance-group-stateless-zonal-single   | <null>    |              | europe-west9-a |
| pdecat-unmanaged-instance-group-zonal-single           | <null>    |              | europe-west9-a |
| pdecat-managed-instance-group-stateful-zonal-multiple  | <null>    | europe-west9 |                |
| pdecat-managed-instance-group-stateful-zonal-single    | <null>    |              | europe-west9-a |
| pdecat-managed-instance-group-stateless-zonal-multiple | <null>    | europe-west9 |                |
+--------------------------------------------------------+-----------+--------------+----------------+

Note: instances values are null because all my test instance groups have 0 instances.

Integration test logs

Logs
Add passing integration test logs here

Example query results

Results
Add example SQL query results here (please include the input queries as well)

if err != nil {
plugin.Logger(ctx).Error("gcp_compute_instance_group.getComputeInstanceGroupInstances", "api_err", err)
return nil, err
if instanceGroup.Zone == "" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @pdecat, could you please provide a comment explaining the code changes and why they are necessary? It would be helpful for future development.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, done!

@pdecat pdecat force-pushed the fix/gcp_compute_instance_group_regional branch from d05048c to 882760c Compare October 21, 2024 07:22
@misraved misraved added the hacktoberfest-accepted This pull request has been accepted for Hacktoberfest label Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest-accepted This pull request has been accepted for Hacktoberfest
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants