When the container is started, the rules should be correctly (re-)indexed even if the old ES index was deleted.
What I observe instead is:
The rules index is empty
There are hundreds of warnings: “Could not retrieve rule with uuid %s referenced by a deprecated rule key…”
TL;DR: The “dbRules” is either an empty list if no plugins have changed or all rules. If no plugins changes, no reindexing happens.
The warning comes from this line:
I debugged the instance on startup, and seems the “dbRules” that is passed here is an empty list (but the DB table for rules has over 11,000 of them, so that’s not the problem).
It seems that this change in 10.7 added a condition on which rules should be processed:
Which is:
I don’t know when the rule.getPluginKey() == null part is supposed to be true, as all rules (even built-in) have a pluginKey set (so it’s always true). Thus the filtering result depends solely on !onlyBuiltIn being true. But onlyBuiltIn == !anyPluginChanged in RulesRegistrant class. So the list becomes empty if no plugins have changed OR its a list of all 11k plugins if any plugin has changed.
PS. The log line is misformatted also, so it shows up as:
2024.10.14 12:08:50 WARN web[][o.s.s.r.r.RulesRegistrationContext] Could not retrieve rule with uuid %s referenced by a deprecated rule key. The following deprecated rule keys seem to be referencing a non-existing rule
with the %s marker not replaced by UUID of the rule.
I am also experiencing this issue. I see no rules shown in the Rules tab, though rules are applied during scanning.
I noticed the log message “WARN web[o.s.s.r.r.RulesRegistrationContext] Could not retrieve rule with uuid %s referenced by a deprecated rule key. The following deprecated rule keys seem to be referencing a non-existing rule”, which is what brought me here.
SonarQube v10.7 (96327) running in docker with postgres in another container.
I have tried forcing a reindex, and also completely reconstructed the container from scratch - no fix.
I am only using my custom plugin which doesn’t do anything related to rules. The Docker container runs with non-persistent volumes (only Postgres is persistent), so “forcing ES reindex” happens with every restart.
Same exact issue here after upgrading to 10.7 developer edition. I’m running on an ec2 instance without docker, rds postgres 16.3, no plugins installed. I tried wiping the data/es8 directory and triggering a reindex but see tons of lines:
2024.10.16 17:34:17 WARN web[][o.s.s.r.r.RulesRegistrationContext] Could not retrieve rule with uuid %s referenced by a deprecated rule key. The following deprecated rule keys seem to be referencing a non-existing rule
Just checking in if there are any updates on this. I also noticed that since the rules are broken sonarlint in connected mode is also not showing any issues.
Thanks for the report. I can reproduce the issue and have started investigating. I’m working on a patch, but if I can find a workaround to unblock you, I will let you know.
Hum, that’s bad news. Would you mind sharing the server startup logs after clearing the ES data and the plugin hash in the DB? I’d like to check if there are no other problems.
Hmm… the work-around did work, and we could see the Rules again. But then we rebooted the pod, effectively clearing the es8 directory, and afterwards the Rules were gone again
@ Lena - we run in k8s without persistence, so every restart is a wipe of the data folder. First start after the upgrade, we still saw all Rules. But a colleague of mine noticed that his rule customizations had been lost (different bug, User "system" automatically reactivates rule upon restart - #6 by ganncamp ). We then restarted the pod to see if that would help, but that second reboot made the Rules “invisible”.
Likewise, after I did the workaround, we had our Rules back. But after restarting the pod, they were lost again.