2017-04-24 58 views
1

当我在计算实例运行命令相同的味道是否能够正常工作gcloud过滤器的正则表达式不一致

gcloud compute instances list --filter='name~mysql' 

然而,当我跑这个命令

gcloud dataproc clusters list --filter='clusterName ~ dev' 

我得到这个错误

ERROR: (gcloud.dataproc.clusters.list) INVALID_ARGUMENT: Could not parse the filter: ParserException:errors { 
    line: 1 
    column: 13 
    message: "syntax error" 
    token: "~" 
} 

任何想法为什么过滤器的行为是这样吗?

回答

0

--filter标志是一个单一的过滤标志,可以在客户端或服务器端解释。在

gcloud compute instances list --filter='name~mysql' 

在客户端解释它的情况。如果添加--log-http,您将看到过滤器表达式从不在任何api请求中发送。在另一方面

gcloud dataproc clusters list --filter='clusterName~dev' --log-http 

将显示:

==== request start ==== uri: https://dataproc.googleapis.com/v1/projects/YOUR_PROJECT/regions/global/clusters?filter=%27clusterName%7Edev%27&alt=json&pageSize=100 method: GET == headers start == ...

的dataproc后端API这里不能够处理相同的筛选语法。查看过滤dataproc API文档:https://cloud.google.com/dataproc/docs/reference/rest/v1/projects.regions.clusters/list

根据这个文件,你可以做

gcloud dataproc clusters list --filter='clusterName=dev' 

无论--filter='clusterName~dev'语法应该不会产生错误,并应在此https://issuetracker.google.com/issues/new?component=187143&template=800102报告的错误。

0

要回答你问的问题:为什么它的行为如此?因为在前一种情况下,过滤在客户端完成(根据gcloud topic filters),在后一种情况下,过滤在服务器端完成。

我们会调查他们是否可以达成一致。

+0

谢谢。我已经提交了一个错误#37658729。现在,我将使用grep解决这个问题。 –