Skip to content

Conversation

@erezrokah
Copy link
Member

Summary

Fixes https://github.com/cloudquery/cloudquery-issues/issues/491 (internal issue)
Fixes https://github.com/cloudquery/cloudquery-issues/issues/492 (internal issue)

After looking at the data and sample responses:
https://learn.microsoft.com/en-us/rest/api/firewall/azure-firewall-fqdn-tags/list-all?tabs=HTTP
https://learn.microsoft.com/en-us/rest/api/expressroute/express-route-service-providers/list?tabs=HTTP#expressrouteserviceprovider, I think the PKs for these tables are configured correctly (subscription_id,id) and can't cause duplicates as far as I can tell.

However I was able to reproduce the issue by specifying a duplicate subscription in the config, for example:

kind: source
spec:
  name: azure
  version: v4.1.1
  destinations: [file]
  path: cloudquery/azure
  tables: [azure_network_express_route_service_providers, azure_network_azure_firewall_fqdn_tags]
  spec:
    subscriptions:
      - <sub_1>
      - <sub_1>
---
kind: destination
spec:
  name: file
  path: cloudquery/file
  version: "v1.1.0"
  write_mode: "append"
  spec:
    directory: "./cq_csv_output"
    format: "csv"

@cq-bot cq-bot added the azure label Feb 14, 2023
@erezrokah erezrokah added the automerge Automatically merge once required checks pass label Feb 14, 2023
return nil, fmt.Errorf("failed to unmarshal gcp spec: %w", err)
}

uniqueSubscriptions := funk.Uniq(spec.Subscriptions).([]string)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd rather use slices.Compact along with slices.Sort

Suggested change
uniqueSubscriptions := funk.Uniq(spec.Subscriptions).([]string)
uniqueSubscriptions := slices.Compact(slices.Sort(spec.Subscriptions))

Copy link
Contributor

Choose a reason for hiding this comment

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

(because it's a part of Go tooling & they're bringing this package to main stdlib as well)

Copy link
Member Author

@erezrokah erezrokah Feb 15, 2023

Choose a reason for hiding this comment

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

Nice one, but I'm not sure we should change the order of how subscriptions are defined in the spec, as I would expected CloudQuery to sync those in order (bound to concurrency limits)

@candiduslynx
Copy link
Contributor

Do we want to ensure the same thing on other plugins? (e.g., AWS, GCP)

@erezrokah
Copy link
Member Author

erezrokah commented Feb 15, 2023

Do we want to ensure the same thing on other plugins? (e.g., AWS, GCP)

I think it's worth verifying it

@kodiakhq kodiakhq bot merged commit 20dc235 into cloudquery:main Feb 15, 2023
@erezrokah erezrokah deleted the fix/azure_spec_subs branch February 15, 2023 09:49
kodiakhq bot pushed a commit that referenced this pull request Feb 21, 2023
🤖 I have created a release *beep* *boop*
---


## [4.2.0](plugins-source-azure-v4.1.1...plugins-source-azure-v4.2.0) (2023-02-21)


### Features

* **azure:** Add network ExpressRoute circuit authorizations and peerings ([#8128](#8128)) ([2d4cba5](2d4cba5)), closes [#7927](#7927)
* **azure:** Add network: interface_ip_configurations and virtual_network_subnets ([#8126](#8126)) ([df5e48b](df5e48b)), closes [#7929](#7929)
* **azure:** Add postgresql databases resource ([#8125](#8125)) ([91cab61](91cab61)), closes [#7928](#7928)


### Bug Fixes

* **azure:** Ensure spec subscriptions are unique ([#8099](#8099)) ([20dc235](20dc235))
* **deps:** Update module github.com/cloudquery/plugin-sdk to v1.38.2 ([#8156](#8156)) ([ac2d2d7](ac2d2d7))
* **deps:** Update module golang.org/x/net to v0.7.0 [SECURITY] ([#8176](#8176)) ([fc4cef8](fc4cef8))

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
kodiakhq bot pushed a commit to cloudquery/plugin-sdk that referenced this pull request Mar 2, 2023

Related to #713. This PR detects duplicated client IDs, sends a sentry report when that happens and also logs a warning.
It not this does not skip those clients (yet). I'll do a follow up based on the sentry data as we can have duplicate clients due to:
1. User errors creating a configuration that generates duplicated clients like in cloudquery/cloudquery#8099
2. Plugins bug, not implementing the ID method correctly

---
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automerge Automatically merge once required checks pass

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants