-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: action config update would sometimes not be reflected in connector #13077
fix: action config update would sometimes not be reflected in connector #13077
Conversation
#{ | ||
status => ?status_disconnected, | ||
error => Reason | ||
error => Reason, | ||
config => ChannelConfig |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we return this channel status in the APIs. If so, we might want to redact this config in the API handlers, as it might contain sensitive data. It might be already handled there, but worth confirming it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I will check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Configs are now removed from get_channel_status calls and the lookup calls: 0f10b0b
90c149b
to
cff8b97
Compare
Before this commit the following happened sometimes: 1. action status is connected 2. action config is updated to something that should change the status to disconnected 3. action status is still connected and the old config is being used by the connector even though the config has been correctly updated. The reason for this bug is that the post_config_hook runs before the global EMQX config is updated. The post config hook is adding the new config to the connector. Since the new config causes the action to get status disconnected, the adding of the action to the connector is retried when the health check runs but this time the config will be loaded from the global config which could cause the old config to be loaded (this happens when the global config has not had time to get updated). The above problem has been fixed in this commit by only reading action configs from the global config when the connector starts/restarts and instead store the latest configs for the actions in the connector. Fixes: https://emqx.atlassian.net/browse/EMQX-12376
This commit fixes an issue found by CI test case emqx_bridge_influxdb_SUITE:t_start_stop and others. While the channel health check process is running, the channel could be removed or updated which could cause a crash in the resource manager or non up-to-date alarms being triggered.
AddedChannelsList = maps:to_list(Data#data.added_channels), | ||
AddedChannelsListWithoutConfigs = | ||
[ | ||
{ChanID, maps:remove(config, Status)} | ||
|| {ChanID, Status} <- AddedChannelsList | ||
], | ||
AddedChannelsWithoutConfigs = | ||
maps:from_list(AddedChannelsListWithoutConfigs), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit:
AddedChannelsList = maps:to_list(Data#data.added_channels), | |
AddedChannelsListWithoutConfigs = | |
[ | |
{ChanID, maps:remove(config, Status)} | |
|| {ChanID, Status} <- AddedChannelsList | |
], | |
AddedChannelsWithoutConfigs = | |
maps:from_list(AddedChannelsListWithoutConfigs), | |
AddedChannelsWithoutConfigs = | |
maps:map( | |
fun(_ChanID, Status) -> maps:remove(config, Status) end, | |
Data#data.added_channels | |
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed 88c96e2
Also added another fix to not leak configs in alarm.
Before this commit the following happened sometimes:
The reason for this bug is that the post_config_hook runs before the global EMQX config is updated. The post config hook is adding the new config to the connector. Since the new config causes the action to get status disconnected, the adding of the action to the connector is retried when the health check runs but this time the config will be loaded from the global config which could cause the old config to be loaded (this happens when the global config has not had time to get updated).
The above problem has been fixed in this commit by only reading action configs from the global config when the connector starts/restarts and instead store the latest configs for the actions in the connector.
Fixes:
https://emqx.atlassian.net/browse/EMQX-12376
Release version: v/e5.7
Summary
PR Checklist
Please convert it to a draft if any of the following conditions are not met. Reviewers may skip over until all the items are checked:
changes/(ce|ee)/(feat|perf|fix|breaking)-<PR-id>.en.md
files