[Bug] Folder name/uid update may fail due to conflict #1171
Labels
bug
Something isn't working
triage/accepted
Indicates an issue or PR is ready to be actively worked on.
Describe the bug
If a user updates the name of a folder managed by a CR via other means, i.e. update the folder name in Grafana directly, the GrafanaFolder controller will attempt to update this. However, if another controller or user creates another folder with the same name as specified in the GrafanaFolder CR before the GrafanaFolder controller can update it, it will fail due to a conflict as it will attempt to update the UID of the new folder created but will fail as another folder already exists with that UID.
Once it's in this state, the GrafanaFolder controller can no longer update any other properties like folder permissions.
Note that the first folder that matches either the uid or the title is deemed as the existing folder to be updated (see code snippet below from grafanafolder_controller.go#L354-L370):
It may be the case that the folder first returned is the one with the correct uid. In this case, the GrafanaFolder controller will not attempt to update the title unless the CR was changed due to the following checks in grafanafolder_controller.go#L305-L311:
Version
v5.2.0
To Reproduce
Create the following CRs
GrafanaDashboardExample.yaml
GrafanaFolderExample.yaml
Wait for the resources to be created. It should create a folder called
test-folder
and a dashboard should be placed within it calledSimple Dashboard
.Rename
test-folder
totest-folder1
Wait until the GrafanaDashboard is resynced. This will create a new folder called
test-folder
and move theSimple Dashboard
fromtest-folder1
totest-folder
Wait for the GrafanaFolder controller to update the folder. An error in the operator logs should be shown:
The two folders are never updated to the correct state.
Expected behavior
The title should always be updated regardless of whether the CR was changed or not to ensure it's in the correct state.
If the conflict arises, we could do one of the following options:
Suspect component/Location where the bug might be occurring
Runtime (please complete the following information):
Additional context
Workaround
To get around this issue, delete the incorrectly named folder. This ensures that no other controllers/users can create the folder with the same name. The GrafanaFolder controller should then be able to update this folder with the correct UID and permissions.
The text was updated successfully, but these errors were encountered: