kestra-io / plugin-gcp

Apache License 2.0
6 stars 10 forks source link

GKE ClusterMetadata task failing to run successfully #335

Closed shrutimantri closed 5 months ago

shrutimantri commented 5 months ago

Expected Behavior

The GKE ClusterMetadata task should be able to get the cluster's metadata.

Actual Behaviour

I am using the following flow by going through the ClusterMetadata task page:

id: gke-cluster-metadata
namespace: dev
tasks:
  - id: "cluster_metadata"
    type: "io.kestra.plugin.gcp.gke.ClusterMetadata"
    clusterId: "my-kestra-cluster"
    clusterProjectId: "<GCP-project-id>"
    clusterZone: "europe-west3"
    serviceAccount: "{{ secret('GCP_SERVICE_ACCOUNT_JSON') }}"

The flow fails with the following error:

2024-03-17 19:25:13.802 • Using service account: smantri-kestra-20230317@empirical-realm-374307.iam.gserviceaccount.com
2024-03-17 19:25:14.595io.grpc.StatusRuntimeException: INVALID_ARGUMENT: 'zone' field cannot be used to access GKE regional clusters. Use 'name' field instead.
2024-03-17 19:25:14.595INVALID_ARGUMENT: 'zone' field cannot be used to access GKE regional clusters. Use 'name' field instead.
2024-03-17 19:25:14.595com.google.api.gax.rpc.InvalidArgumentException: io.grpc.StatusRuntimeException: INVALID_ARGUMENT: 'zone' field cannot be used to access GKE regional clusters. Use 'name' field instead.
    at com.google.api.gax.rpc.ApiExceptionFactory.createException(ApiExceptionFactory.java:92)
    at com.google.api.gax.grpc.GrpcApiExceptionFactory.create(GrpcApiExceptionFactory.java:98)
    at com.google.api.gax.grpc.GrpcApiExceptionFactory.create(GrpcApiExceptionFactory.java:66)
    at com.google.api.gax.grpc.GrpcExceptionCallable$ExceptionTransformingFuture.onFailure(GrpcExceptionCallable.java:97)
    at com.google.api.core.ApiFutures$1.onFailure(ApiFutures.java:84)
    at com.google.common.util.concurrent.Futures$CallbackListener.run(Futures.java:1128)
    at com.google.common.util.concurrent.DirectExecutor.execute(DirectExecutor.java:31)
    at com.google.common.util.concurrent.AbstractFuture.executeListener(AbstractFuture.java:1298)
    at com.google.common.util.concurrent.AbstractFuture.complete(AbstractFuture.java:1059)
    at com.google.common.util.concurrent.AbstractFuture.setException(AbstractFuture.java:809)
    at io.grpc.stub.ClientCalls$GrpcFuture.setException(ClientCalls.java:568)
    at io.grpc.stub.ClientCalls$UnaryStreamToFuture.onClose(ClientCalls.java:538)
    at io.grpc.PartialForwardingClientCallListener.onClose(PartialForwardingClientCallListener.java:39)
    at io.grpc.ForwardingClientCallListener.onClose(ForwardingClientCallListener.java:23)
    at io.grpc.ForwardingClientCallListener$SimpleForwardingClientCallListener.onClose(ForwardingClientCallListener.java:40)
    at com.google.api.gax.grpc.ChannelPool$ReleasingClientCall$1.onClose(ChannelPool.java:570)
    at io.grpc.internal.DelayedClientCall$DelayedListener$3.run(DelayedClientCall.java:489)
    at io.grpc.internal.DelayedClientCall$DelayedListener.delayOrExecute(DelayedClientCall.java:453)
    at io.grpc.internal.DelayedClientCall$DelayedListener.onClose(DelayedClientCall.java:486)
    at io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:574)
    at io.grpc.internal.ClientCallImpl.access$300(ClientCallImpl.java:72)
    at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInternal(ClientCallImpl.java:742)
    at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInContext(ClientCallImpl.java:723)
    at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
    at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:133)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.base/java.lang.Thread.run(Unknown Source)
    Suppressed: com.google.api.gax.rpc.AsyncTaskException: Asynchronous task failed
        at com.google.api.gax.rpc.ApiExceptions.callAndTranslateApiException(ApiExceptions.java:57)
        at com.google.api.gax.rpc.UnaryCallable.call(UnaryCallable.java:112)
        at com.google.cloud.container.v1.ClusterManagerClient.getCluster(ClusterManagerClient.java:1022)
        at com.google.cloud.container.v1.ClusterManagerClient.getCluster(ClusterManagerClient.java:991)
        at io.kestra.plugin.gcp.gke.ClusterMetadata.fetch(ClusterMetadata.java:107)
        at io.kestra.plugin.gcp.gke.ClusterMetadata.run(ClusterMetadata.java:66)
        at io.kestra.plugin.gcp.gke.ClusterMetadata.run(ClusterMetadata.java:23)
        at io.kestra.core.runners.Worker$WorkerThread.run(Worker.java:710)
Caused by: io.grpc.StatusRuntimeException: INVALID_ARGUMENT: 'zone' field cannot be used to access GKE regional clusters. Use 'name' field instead.
    at io.grpc.Status.asRuntimeException(Status.java:533)
    ... 17 more

Steps To Reproduce

  1. Use the flow as the one in Example flow section below.
  2. Run the flow. The execution fails with an error.

Environment Information

Example flow

id: gke-cluster-metadata
namespace: dev
tasks:
  - id: "cluster_metadata"
    type: "io.kestra.plugin.gcp.gke.ClusterMetadata"
    clusterId: "my-kestra-cluster"
    clusterProjectId: "<GCP-project-id>"
    clusterZone: "europe-west3"
    serviceAccount: "{{ secret('GCP_SERVICE_ACCOUNT_JSON') }}"
loicmathieu commented 5 months ago

The error said that you try to access a regional cluster via its zone which seems not supported. Can you try with a zonal cluster (a cluster on a single GCP availability zone)?

We may miss the functionality to access a regional GKE cluster.

shrutimantri commented 5 months ago

Yes, confirmed that the task works for zonal GKE cluster. Raising a feature request for supporting regional clusters.