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 58eea01
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")
}

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

0 comments on commit 58eea01

Please sign in to comment.