Skip to content

Commit

Permalink
fix: fix update emqx config error
Browse files Browse the repository at this point in the history
Don't update readonly keys

Signed-off-by: Rory Z <[email protected]>
  • Loading branch information
Rory-Z committed Jan 23, 2024
1 parent b2506f8 commit 06fb780
Showing 1 changed file with 16 additions and 3 deletions.
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 @@ func (s *syncConfig) reconcile(ctx context.Context, logger logr.Logger, instance

// 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")
}
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")
}
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")
}
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")
}

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

0 comments on commit 06fb780

Please sign in to comment.