generator: reject index types the collector cannot render#1653
Open
lukeod wants to merge 1 commit into
Open
Conversation
Signed-off-by: lukeod <l.odonnell11@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The generator emits index types the collector cannot render as labels (
DateAndTime,Bits, etc).indexOidsAsStringpanics on them in the collect goroutine, which exits the whole exporter process - one row in an affected table is enough. This is reachable from standard MIBs:ALARM-MIB::alarmActiveTable(RFC 3877) is indexed byalarmActiveDateAndTime, so generating a module for it produces a config that crashes the exporter on the first scrape of a populated table.The proposed approach:
config.RenderableIndexTypes; a collector test asserts every entry renders without panic. It lives inconfig, which the generator and collector both already import.Integer/Integer32are listed for hand-written configs (the generator never emits them as index types)No module in the shipped
snmp.ymlcarries an affected index type, so regenerating it drops nothing. The Bits test expectation is updated: the previous expected output encoded a config that panics the exporter. Atype: OctetStringoverride keeps a dropped table (renders as hex). Some rejected types could reasonably be rendered in future (e.g. DateAndTime as a timestamp label); adding the collector case and listing the type re-admits those tables. Hardening the collector against such configs already in the field (hand-written or from older generators) is another possible follow-up.Part of the generator display_hint work for #1610, alongside #1646 and #1648.