fix: kill k8s pod with multi labels not work #174
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Signed-off-by: Icesource gonghuajian.ghj@alibaba-inc.com
Describe what this PR does / why we need it
Fix chaosblade-io/chaosblade#770
Does this pull request fix one issue?
Fixes chaosblade-io/chaosblade#770
Describe how you did it
之前,匹配用的 标签都保存在一个Map中,这会导致如果指定了同key的多个标签,后来的value会覆盖原来的value。
例如,指定 app=a , app=b ,那么只有app=b会 生效
修改为直接使用 labels.Requirement 保存标签可以做到不覆盖,且可调用Selector.In来实现多个value值的或匹配
Describe how to verify it
修改代码后使用以下pod进行验证
以delete_pod为例
指定标签
可以删除标签nginx和mynginx下的所有的pod
同时指定name和标签,如果name能匹配上任意一个标签,那么删除该name的pod,如果所有标签都没匹配上,则不删除
例如指定的pod没有匹配上任意对应的标签
该pod不会被删除
例如,指定的pod匹配上了标签中的app=nginx标签
该pod会被删除