Hello

I'm writing a new resource which has multiple providers but I cannot get
the containment to work properly, some properties leak to all resources
of this type regardless of the provider.

here is one of the properties and the type declaration


```
Puppet::Type.newtype(:nexus_v3_repository) do
    @doc = "Manage nexus v3 repositories"

    ensurable

 feature :feat_negative_cache_enabled, "negative cache enabled", :methods => 
[:negative_cache_enabled]

   newproperty(:negative_cache_enabled, :boolean => true, :require_features => 
:feat_negative_cache_enabled) do
      desc 'Whether to cache responses for content not present in the proxied 
repository'
      newvalues(:true, :false)
      defaultto :true

    end
```

then I have multiple providers which implement, or not, the feature
feat_negative_cache_enabled
(i'm using negative_cache_enabled as an example, other properties share the same behavior)

maven provider (it does not implement negative_cache_enabled)

```
Puppet::Type.type(:nexus_v3_repository).provide(:maven) do
  desc 'Nexus repository maven provider'

  mk_resource_methods
  confine :exists => "/etc/puppetlabs/puppet/nexus_ready"
  confine :exists => "/etc/puppetlabs/puppet/nexus_rest.conf"
  has_feature :feat_versionpolicy, :feat_writepolicy, :feat_layoutpolicy
```

proxy provider which does implement feat_negative_cache_enabled
```
Puppet::Type.type(:nexus_v3_repository).provide(:proxy) do
  desc 'Nexus repository proxy provider'

  mk_resource_methods
  confine :exists => "/etc/puppetlabs/puppet/nexus_ready"
  confine :exists => "/etc/puppetlabs/puppet/nexus_rest.conf"
  has_features :feat_repodatadepth, :feat_content_max_age, :feat_format, 
:feat_negative_cache_ttl, :feat_negative_cache_enabled
```

if i run `puppet resources nexus_v3_repository` resources are listed
properly with their properties

```
nexus_v3_repository { 'centos8':
  ensure                      => 'present',
  blobstorename               => 'centos8',
  format                      => 'yum',
  negative_cache_enabled      => true,
  negative_cache_ttl          => 1440,
  provider                    => 'proxy',
  remote_url                  => 
'https://nexus.internal.domain/repository/Centos-8/',
  strictcontenttypevalidation => true,
  type                        => 'proxy',
  url                         => 
'https://nexus.internal.domain/repository/centos8',
}
nexus_v3_repository { 'maven':
  ensure                      => 'present',
  blobstorename               => 'maven',
  layoutpolicy                => 'STRICT',
  online                      => 'true',
  provider                    => 'maven',
  strictcontenttypevalidation => 'true',
  type                        => 'hosted',
  url                         => 
'https://nexus.internal.domain/repository/maven',
  versionpolicy               => 'MIXED',
  writepolicy                 => 'allow_once',
}
```

when I run `puppet agent -t` the negative_cache_enabled property is applied
to resources with the provider `maven` even if the provider does not
implement that feature

```
Notice: 
/Stage[main]/Profile_nexus/Nexus_v3::Repository::Maven::Hosted[maven]/Nexus_v3_repository[maven]/negative_cache_enabled:
 defined 'negative_cache_enabled' as 'true' (corrective)
Notice: 
/Stage[main]/Profile_nexus/Nexus_v3::Repository::Maven::Hosted[maven]/Nexus_v3_repository[maven]/negative_cache_ttl:
 defined 'negative_cache_ttl' as 30 (corrective)
```

which doesn't do anything but generates extra noise in puppet's output

if I remove `mk_resource_methods` from the maven provider puppet fails to run because it cannot find the negative_cache_enabled method (which
is expected but not wanted)

```
Error: 
/Stage[main]/Profile_nexus/Nexus_v3::Repository::Maven::Hosted[maven]/Nexus_v3_repository[maven]:
 Could not evaluate: undefined method `negative_cache_enabled' for 
Nexus_v3_repository[maven](provider=maven):Puppet::Type::Nexus_v3_repository::ProviderMaven
```

there is a warning that puppet can't find the default provider for the
resource

```
Warning: Found multiple default providers for nexus_v3_repository: maven, raw, 
proxy, yum; using maven
```

since there is no fact to differentiate between providers, i didn't
choose a provider as the default

here is the --debug log of the puppet agent run
```
Debug: Prefetching maven resources for nexus_v3_repository
Debug: GET https://nexus.internal.domain/service/rest/v1/repositories
Debug: GET 
https://nexus.internal.domain/service/rest/v1/repositories/maven/hosted/maven-snapshots
Debug: GET 
https://nexus.internal.domain/service/rest/v1/repositories/maven/hosted/maven-releases
Debug: GET 
https://nexus.internal.domain/service/rest/v1/repositories/maven/hosted/maven
Debug: PUT https://nexus.internal.domain/service/rest/v1/repositories/maven/hosted/maven {"name"=>"maven", "online"=>"true", 
"storage"=>{"blobStoreName"=>"maven", "strictContentTypeValidation"=>"true", "
writePolicy"=>"allow_once"}, "maven"=>{"versionPolicy"=>"MIXED", 
"layoutPolicy"=>"PERMISSIVE"}}
Debug: PUT https://nexus.internal.domain/service/rest/v1/repositories/maven/hosted/maven {"name"=>"maven", "online"=>"true", 
"storage"=>{"blobStoreName"=>"maven", "strictContentTypeValidation"=>"true", "
writePolicy"=>"allow_once"}, "maven"=>{"versionPolicy"=>"MIXED", 
"layoutPolicy"=>"PERMISSIVE"}}
Debug: PUT https://nexus.internal.domain/service/rest/v1/repositories/maven/hosted/maven {"name"=>"maven", "online"=>"true", 
"storage"=>{"blobStoreName"=>"maven", "strictContentTypeValidation"=>"true", "
writePolicy"=>"allow_once"}, "maven"=>{"versionPolicy"=>"MIXED", 
"layoutPolicy"=>"PERMISSIVE"}}
Debug: PUT https://nexus.internal.domain/service/rest/v1/repositories/maven/hosted/maven {"name"=>"maven", "online"=>"true", 
"storage"=>{"blobStoreName"=>"maven", "strictContentTypeValidation"=>"true", "
writePolicy"=>"allow_once"}, "maven"=>{"versionPolicy"=>"MIXED", 
"layoutPolicy"=>"PERMISSIVE"}}
Debug: PUT https://nexus.internal.domain/service/rest/v1/repositories/maven/hosted/maven {"name"=>"maven", "online"=>"true", 
"storage"=>{"blobStoreName"=>"maven", "strictContentTypeValidation"=>"true", "
writePolicy"=>"allow_once"}, "maven"=>{"versionPolicy"=>"MIXED", 
"layoutPolicy"=>"PERMISSIVE"}}
Notice: 
/Stage[main]/Profile_nexus/Nexus_v3::Repository::Maven::Hosted[maven]/Nexus_v3_repository[maven]/negative_cache_enabled:
 defined 'negative_cache_enabled' as 'true'
Notice: 
/Stage[main]/Profile_nexus/Nexus_v3::Repository::Maven::Hosted[maven]/Nexus_v3_repository[maven]/negative_cache_ttl:
 defined 'negative_cache_ttl' as 30
Notice: 
/Stage[main]/Profile_nexus/Nexus_v3::Repository::Maven::Hosted[maven]/Nexus_v3_repository[maven]/content_max_age:
 defined 'content_max_age' as 1440
Notice: 
/Stage[main]/Profile_nexus/Nexus_v3::Repository::Maven::Hosted[maven]/Nexus_v3_repository[maven]/metadata_max_age:
 defined 'metadata_max_age' as 1440
Notice: 
/Stage[main]/Profile_nexus/Nexus_v3::Repository::Maven::Hosted[maven]/Nexus_v3_repository[maven]/http_client_blocked:
 defined 'http_client_blocked' as 'false'
Notice: 
/Stage[main]/Profile_nexus/Nexus_v3::Repository::Maven::Hosted[maven]/Nexus_v3_repository[maven]/http_client_auto_block:
 defined 'http_client_auto_block' as 'true'
Notice: 
/Stage[main]/Profile_nexus/Nexus_v3::Repository::Maven::Hosted[maven]/Nexus_v3_repository[maven]/repodatadepth:
 defined 'repodatadepth' as 5
Notice: 
/Stage[main]/Profile_nexus/Nexus_v3::Repository::Maven::Hosted[maven]/Nexus_v3_repository[maven]/deploypolicy:
 defined 'deploypolicy' as 'STRICT'
Debug: 
/Stage[main]/Profile_nexus/Nexus_v3::Repository::Maven::Hosted[maven]/Nexus_v3_repository[maven]:
 The container Nexus_v3::Repository::Maven::Hosted[maven] will propagate my 
refresh event
Debug: 
/Stage[main]/Profile_nexus/Nexus_v3::Repository::Maven::Hosted[maven]/Nexus_v3_repository[maven]:
 The container Nexus_v3::Repository::Maven::Hosted[maven] will propagate my 
refresh event
Debug: 
/Stage[main]/Profile_nexus/Nexus_v3::Repository::Maven::Hosted[maven]/Nexus_v3_repository[maven]:
 The container Nexus_v3::Repository::Maven::Hosted[maven] will propagate my 
refresh event
Debug: 
/Stage[main]/Profile_nexus/Nexus_v3::Repository::Maven::Hosted[maven]/Nexus_v3_repository[maven]:
 The container Nexus_v3::Repository::Maven::Hosted[maven] will propagate my 
refresh event
Debug: 
/Stage[main]/Profile_nexus/Nexus_v3::Repository::Maven::Hosted[maven]/Nexus_v3_repository[maven]:
 The container Nexus_v3::Repository::Maven::Hosted[maven] will propagate my 
refresh event
Debug: 
/Stage[main]/Profile_nexus/Nexus_v3::Repository::Maven::Hosted[maven]/Nexus_v3_repository[maven]:
 The container Nexus_v3::Repository::Maven::Hosted[maven] will propagate my 
refresh event
Debug: 
/Stage[main]/Profile_nexus/Nexus_v3::Repository::Maven::Hosted[maven]/Nexus_v3_repository[maven]:
 The container Nexus_v3::Repository::Maven::Hosted[maven] will propagate my 
refresh event
Debug: 
/Stage[main]/Profile_nexus/Nexus_v3::Repository::Maven::Hosted[maven]/Nexus_v3_repository[maven]:
 The container Nexus_v3::Repository::Maven::Hosted[maven] will propagate my 
refresh event
Debug: Nexus_v3::Repository::Maven::Hosted[maven]: The container 
Class[Profile_nexus] will propagate my refresh event
```
it is clear that puppet cannot prefetch the values for
negative_cache_enabled (because it does not exists) so it tries to set
to the default value

what am i missing here? Why puppet wants to manage
`negative_cache_enabled` on the maven resources?  i'm happy to show more
logs or code if it helps


thanks!

--
IRC: gfa
GPG: 0x27263FA42553615F904A7EBE2A40A2ECB8DAD8D5
OLD GPG: 0x44BB1BA79F6C6333

--
You received this message because you are subscribed to the Google Groups "Puppet 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/20201117091645.6ptlvnpuz22nexug%40zumbi.com.ar.

Reply via email to