Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use trace messaging to indicate composite resources are being ignored #424

Open
michaeltlombardi opened this issue Apr 25, 2024 · 0 comments
Labels
Issue-Enhancement The issue is a feature or idea Needs Triage

Comments

@michaeltlombardi
Copy link
Collaborator

Summary of the new feature / enhancement

As a configuration author using PSDSC resources in DSC, I always see debug messages with a warning prefix about "implementation detail not found" for composite resources when the adapter builds the DSC cache. The warning implies that something has gone wrong, but the actual behavior is desired and expected - Invoke-DscResource doesn't work with composite resources. Instead, the adapter should emit trace messages indicating that it's not caching the composite resource because they're not supported.

The code that is causing this behavior is in the Invoke-DscCacheRefresh function in the adapter module:

if ([dscResourceType].GetEnumNames() -notcontains $dscResource.ImplementationDetail) {
$trace = @{'Debug' = 'WARNING: implementation detail not found: ' + $dscResource.ImplementationDetail } | ConvertTo-Json -Compress
$host.ui.WriteErrorLine($trace)
continue
}

Proposed technical implementation details (optional)

Define an additional check in the foreach loop to specifically discard composite resources:

$dscResourceTypeName = $dscResource.ModuleName + '/' + $dscResource.Name

if ($dscResource.ImplementedAs -eq 'Composite') {
    $trace = @{
        'Trace' = @(
            "Skipping caching composite resource '$dscResourceTypeName'."
            "Composite resources aren't supported in DSCv3."
        ) -join ' '
    } | ConvertTo-Json -Compress
    $host.ui.WriteErrorLine($trace)
    continue
}

Note

Out of scope for this issue, but the trace messages from the adapter all use the Debug level, when they should use the appropriate level for their message, and many of them lack sufficient context for a typical user to understand which resource the message is referring to and what the message indicates.

@michaeltlombardi michaeltlombardi added Issue-Enhancement The issue is a feature or idea Needs Triage labels Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Enhancement The issue is a feature or idea Needs Triage
Projects
None yet
Development

No branches or pull requests

1 participant