Skip to content
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: fix update emqx config error #1005

Merged
merged 1 commit into from
Jan 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions controllers/apps/v2beta1/sync_emqx_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,22 @@

// Delete readonly configs
hoconConfigObj := hoconConfig.GetRoot().(hocon.Object)
delete(hoconConfigObj, "node")
delete(hoconConfigObj, "cluster")
delete(hoconConfigObj, "dashboard")
if _, ok := hoconConfigObj["node"]; ok {
s.EventRecorder.Event(instance, corev1.EventTypeNormal, "WontUpdateReadOnlyConfig", "Won't update `node` config, because it's readonly config")
delete(hoconConfigObj, "node")
}

Check warning on line 63 in controllers/apps/v2beta1/sync_emqx_config.go

View check run for this annotation

Codecov / codecov/patch

controllers/apps/v2beta1/sync_emqx_config.go#L61-L63

Added lines #L61 - L63 were not covered by tests
if _, ok := hoconConfigObj["cluster"]; ok {
s.EventRecorder.Event(instance, corev1.EventTypeNormal, "WontUpdateReadOnlyConfig", "Won't update `cluster` config, because it's readonly config")
delete(hoconConfigObj, "cluster")
}

Check warning on line 67 in controllers/apps/v2beta1/sync_emqx_config.go

View check run for this annotation

Codecov / codecov/patch

controllers/apps/v2beta1/sync_emqx_config.go#L65-L67

Added lines #L65 - L67 were not covered by tests
if _, ok := hoconConfigObj["dashboard"]; ok {
s.EventRecorder.Event(instance, corev1.EventTypeNormal, "WontUpdateReadOnlyConfig", "Won't update `dashboard` config, because it's readonly config")
delete(hoconConfigObj, "dashboard")
}

Check warning on line 71 in controllers/apps/v2beta1/sync_emqx_config.go

View check run for this annotation

Codecov / codecov/patch

controllers/apps/v2beta1/sync_emqx_config.go#L69-L71

Added lines #L69 - L71 were not covered by tests
if _, ok := hoconConfigObj["rpc"]; ok {
s.EventRecorder.Event(instance, corev1.EventTypeNormal, "WontUpdateReadOnlyConfig", "Won't update `rpc` config, because it's readonly config")
delete(hoconConfigObj, "rpc")
}

Check warning on line 75 in controllers/apps/v2beta1/sync_emqx_config.go

View check run for this annotation

Codecov / codecov/patch

controllers/apps/v2beta1/sync_emqx_config.go#L73-L75

Added lines #L73 - L75 were not covered by tests

if err := putEMQXConfigsByAPI(r, instance.Spec.Config.Mode, hoconConfigObj.String()); err != nil {
return subResult{err: emperror.Wrap(err, "failed to put emqx config")}
Expand Down