英文:
flag redefined: Can two components have same flag variable
问题
我有一个包含5个容器的部署。其中两个容器的--endpoint
参数的值是从ENV
中设置的。
所以在部署后我看到了以下错误:
/home/xxx-csi-drivers/xxx-vpc-block-csi-driver flag redefined: endpoint
panic: /home/xxx-csi-drivers/xxx-vpc-block-csi-driver flag redefined: endpoint
容器A的构建代码中有以下内容:
endpoint = flag.String("endpoint", "/tmp/storage-secret-sidecar.sock", "Storage secret sidecar endpoint")
而容器B的构建代码中也有以下内容:
endpoint = flag.String("endpoint", "unix:/tmp/csi.sock", "CSI endpoint")
在代码中定义相同的变量endpoint
是导致上述错误的原因吗?
我尝试过更改deployment
文件中的参数名称和其他选项,但没有帮助。但是更改代码中的flag
名称修复了问题,但需要更多了解其工作原理。所以我发布了这个问题。
英文:
I have a deployment with 5 containers.
Among them two of them have --endpoint
as argument for which value is set from ENV
So I see this error after deployment
/home/xxx-csi-drivers/xxx-vpc-block-csi-driver flag redefined: endpoint
panic: /home/xxx-csi-drivers/xxx-vpc-block-csi-driver flag redefined: endpoint
The code from which container A is build has
endpoint = flag.String("endpoint", "/tmp/storage-secret-sidecar.sock", "Storage secret sidecar endpoint")
also
The code from which container B is build also has
endpoint = flag.String("endpoint", "unix:/tmp/csi.sock", "CSI endpoint")
Is defining the same var endpoint
in the code reason for the above bug.
I have tried changing arg
names in deployment
file. and other options which didnt help. But changing flag
name in code fixed the issue but need to undersatnd more on working. So posted this question
答案1
得分: 3
这与不同的容器无关。无论哪个进程崩溃,都只是出现了问题,代码中有一个错误,它注册了相同的标志两次,这是不允许的。
英文:
It has nothing to do with the different containers. Whichever process is crashing is just broken, the code has a bug where it registers the same flag twice which isn't allowed.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论