Skip to content

fix: write updated config back to mounted file on configmap reload - #1233

Open
AruneshDwivedi wants to merge 1 commit into
eraser-dev:mainfrom
AruneshDwivedi:fix/config-not-updated
Open

fix: write updated config back to mounted file on configmap reload#1233
AruneshDwivedi wants to merge 1 commit into
eraser-dev:mainfrom
AruneshDwivedi:fix/config-not-updated

Conversation

@AruneshDwivedi

Copy link
Copy Markdown

Fixes #927

When Kubernetes updates a ConfigMap, the controller detects the change via inotify and updates its in-memory configuration. However, the trivy scanner pod reads the config file directly from the mounted volume, so it continues to see the stale version.

The bug:

  1. ConfigMap is updated by admin
  2. Controller detects IN_DELETE_SELF event and reads new config
  3. Controller calls eraserOpts.Update(newConfig) to update in-memory state
  4. But the mounted file on disk still contains the old config
  5. Trivy scanner pod reading from the mount sees stale config

The fix:
After updating the in-memory config, write the marshaled config back to the mounted file. This ensures sidecar containers reading the config file see the updated values.

Kubernetes configmap updates are mounted as files, but the controller
only updates its in-memory config. The trivy scanner pod reads the
config file directly from the mount, so it sees the stale version.

Write the marshaled config back to the file after Update() so that
sidecar containers reading the mount see the updated configuration.

Signed-off-by: Arunesh Dwivedi <arunesh.devops@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] modified controller_manager_config is not updated

1 participant