Skip to content

Commit

Permalink
Fixed Error in gcp_kubernetes_node_pool table if gke autopilot is used
Browse files Browse the repository at this point in the history
…Closes #585 (#591)
  • Loading branch information
ParthaI authored Jun 6, 2024
1 parent 8e917bd commit 9b3326a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions gcp/table_gcp_kubernetes_node_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,13 @@ func listKubernetesNodePools(ctx context.Context, d *plugin.QueryData, h *plugin
// Get the details of Cluster
cluster := h.Item.(*container.Cluster)

// This operation is not allowed if the cluster has Autopilot Enabled.
// We are getting the error Error: gcp: googleapi: Error 400: Autopilot node pools cannot be accessed or modified.

if cluster.Autopilot.Enabled {
return nil, nil
}

// Create Service Connection
service, err := ContainerService(ctx, d)
if err != nil {
Expand Down Expand Up @@ -205,6 +212,11 @@ func getKubernetesNodePool(ctx context.Context, d *plugin.QueryData, h *plugin.H

resp, err := service.Projects.Locations.Clusters.NodePools.Get(parent).Do()
if err != nil {
// This operation is not allowed if the cluster has Autopilot Enabled.
// We are getting the error Error: gcp: googleapi: Error 400: Autopilot node pools cannot be accessed or modified.
if strings.Contains(err.Error(), "Autopilot node pools cannot be accessed or modified") {
return nil, nil
}
return nil, err
}

Expand Down

0 comments on commit 9b3326a

Please sign in to comment.