Search code examples
google-cloud-platformgcloudgoogle-cloud-composer

INVALID_ARGUMENT error while updating gcloud container cluster


My goal is to update composer dag variables using gcloud commands. I started with using single command to update one variable via question posted in this Import variables using json file in Google Cloud Composer.

I got the following error -

ERROR: (gcloud.composer.environments.run) kubectl returned non-zero status code. Make sure you have followed https://cloud.google.com/composer/docs/how-to/accessing/airflow-cli#private-ip to enable access to your private Cloud Composer environment from your machine.

I then followed that instructions under Running commands on a private IP environment section. I got my public IP of the cloud shell, and the gke cluster name. In the third step that mentions updating GKE Cluster, I ran the command to obtain EXISTING_AUTH_NETS using the following command -

gcloud container clusters describe cluster_name --zone us-central1-c \
    --format "flattened(masterAuthorizedNetworksConfig.cidrBlocks[])"

This returned None. So I went ahead and ran the following command -

gcloud container clusters update cluster_name \
    --enable-master-authorized-networks \
    --master-authorized-networks None,34.xxx.xxx.xxx

Running the above command I get the following errors -

ERROR: (gcloud.container.clusters.update) INVALID_ARGUMENT: (1) invalid value for "cluster.master_authorized_networks_config": invalid CIDR - "34.126.169.236" is not a valid CIDR range. Must be a match of regex [0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}/[0-9]{1,2}, (for example, '10.120.0.0/14') (2) invalid value for "cluster.master_authorized_networks_config": invalid CIDR - "None" is not a valid CIDR range. Must be a match of regex [0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}/[0-9]{1,2}, (for example, '10.120.0.0/14').

Can someone help me how to fix the error? I understand that IP address is wrong. Even running simple cloud composer commands such as this one, I am unable to do so

gcloud composer environments run composer-env-name list_dags --location us-central1 -- --report 

Solution

  • You have specified an IP address (34.126.169.236) and not a CIDR (34.126.169.0/24). The formats are similar but represent different information. The first is a single IP address, the second is a network specification.