有谁知道为什么
instance = search('aws_opsworks_instance', 'self:true').first
# ...
instance_host: instance['hostname']
会间歇性地导致
undefined method `[]' for nil:NilClass
在 OpsWorks 上?
我已经搜索了几个小时,但没有找到任何东西,所以我开始认为这是一个副产品,而不是真正的问题。
由于这种情况每隔一段时间就会发生一次,我认为这可能是一种“竞争条件”。也许 OpsWorks 需要一段时间才能注入(inject),所以需要让 Chef 等待?如果是这样,我在文档中找不到任何类似的内容。
有什么想法为什么会发生这种情况以及如何修复/避免它吗?
最佳答案
这是特定于 aws opswork 的。这是 aws documentation 的摘录:
Chef search with
self:true
finds the data bag item that contains information related to the instance that the recipe is being executed on.
从帖子的输出中,instance
为 null
,这是 search()
在没有搜索时返回的值结果。
也许使用 --log_level debug
运行 Chef-client 将揭示更多信息或尝试联系 AWS 支持团队。
关于chef-infra - 数据包 'aws_opsworks_instance' 不可用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58223822/