Skip to content

SetupFn can silently panic #123

@eric-carlsson

Description

@eric-carlsson

Hi,

After upgrading a provider generated from this template from v1 to v2, we started experiencing issues where it would silently fail. No logs, no events, but MR:s didn't sync.

After much effort I found that root cause was that we had accidentally dropped initializing the Configuration struct during the migration:

ps.Configuration = map[string]any{}

This caused Go to panic because of the nil pointer reference (understandable), which was seemingly recovered at some point without any form of logging (!?). This leads me to two questions/suggestions:

  • How can we make sure recovered panics are logged? I'm not sure what is doing the recovery (controller runtime?), so I'm unsure where to look for this.

  • Does it make sense to adjust the template so ps.Configuration is initialized by default? Even if it's just empty and doesn't do anything, it would save others from the same issue.

    ps := terraform.Setup{
    	Version: version,
    	Requirement: terraform.ProviderRequirement{
    		Source:  providerSource,
    		Version: providerVersion,
    	},
    	Configuration: terraform.ProviderConfiguration{},
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions