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

io.fabric8.kubernetes.internal.InternalResourceMappingProvider not in module #2488

Closed
takvamborgen opened this issue Sep 15, 2020 · 2 comments · Fixed by #2515
Closed

io.fabric8.kubernetes.internal.InternalResourceMappingProvider not in module #2488

takvamborgen opened this issue Sep 15, 2020 · 2 comments · Fixed by #2515
Labels

Comments

@takvamborgen
Copy link

Hi!

jar --file=kubernetes-model-rbac-4.11.1.jar --describe-module gives the following error:

Unable to derive module descriptor for: kubernetes-model-rbac-4.11.1.jar
Provider class io.fabric8.kubernetes.internal.InternalResourceMappingProvider not in module

Are you planning to fix this, and if so, when? :)

Thank you.

@rohanKanojia
Copy link
Member

ah, that's not good :-( . We'll try to fix this as soon as we can. Would it be possible for you to send us a PR to fix this? I think you would need to provide mapping for types like this:

https://github.com/fabric8io/kubernetes-client/blob/master/extensions/knative/model/src/main/java/io/fabric8/knative/api/model/KnativeResourceMappingProvider.java

@manusa
Copy link
Member

manusa commented Sep 16, 2020

This is broken for all kubernetes-model-generator modules which contain a src/main/resources/META-INF/services/io.fabric8.kubernetes.api.KubernetesResourceMappingProvider descriptor with a reference to a provider not provided in the same module (namely io.fabric8.kubernetes.api.KubernetesResourceMappingProvider).

Probably the Service Provider configuration file was left-over in #2137/ #2108

This is the case for the following modules:

./kubernetes-model-discovery/src/main/resources/META-INF/services/io.fabric8.kubernetes.api.KubernetesResourceMappingProvider
./kubernetes-model-events/src/main/resources/META-INF/services/io.fabric8.kubernetes.api.KubernetesResourceMappingProvider
./kubernetes-model-extensions/src/main/resources/META-INF/services/io.fabric8.kubernetes.api.KubernetesResourceMappingProvider
./kubernetes-model-metrics/src/main/resources/META-INF/services/io.fabric8.kubernetes.api.KubernetesResourceMappingProvider
./kubernetes-model-networking/src/main/resources/META-INF/services/io.fabric8.kubernetes.api.KubernetesResourceMappingProvider
./kubernetes-model-policy/src/main/resources/META-INF/services/io.fabric8.kubernetes.api.KubernetesResourceMappingProvider
./kubernetes-model-rbac/src/main/resources/META-INF/services/io.fabric8.kubernetes.api.KubernetesResourceMappingProvider
./kubernetes-model-scheduling/src/main/resources/META-INF/services/io.fabric8.kubernetes.api.KubernetesResourceMappingProvider
./kubernetes-model-settings/src/main/resources/META-INF/services/io.fabric8.kubernetes.api.KubernetesResourceMappingProvider
./kubernetes-model-storageclass/src/main/resources/META-INF/services/io.fabric8.kubernetes.api.KubernetesResourceMappingProvider
./openshift-model/src/main/resources/META-INF/services/io.fabric8.kubernetes.api.KubernetesResourceMappingProvider

The KubernetesResourceMappingProvider is mainly used in the KubernetesDeserializer:

private void registerAllProviders() {
getAllMappingProviders().forEach(this::registerProvider);
}
Stream<KubernetesResourceMappingProvider> getAllMappingProviders() {
//Use service loader to load extension types.
Iterable<KubernetesResourceMappingProvider> currentThreadClassLoader =
() -> ServiceLoader.load(KubernetesResourceMappingProvider.class, Thread.currentThread().getContextClassLoader())
.iterator();
Iterable<KubernetesResourceMappingProvider> classClassLoader =
() -> ServiceLoader.load(KubernetesResourceMappingProvider.class, KubernetesDeserializer.class.getClassLoader())
.iterator();
return Stream.concat(
StreamSupport.stream(currentThreadClassLoader.spliterator(), false),
StreamSupport.stream(classClassLoader.spliterator(), false))
.filter(distinctByClassName(KubernetesResourceMappingProvider::getClass));
}

For the kubernetes-model-generator, these providers are "not necessary" since there is additional logic to deserialize the model classes provided by these modules:

// First pass, check if there are more than one class of same name
for (String aPackage : PACKAGES) {
Class<? extends KubernetesResource> result = loadClassIfExists(aPackage + name);
if (result != null) {
possibleResults.add(result);
}
}

However, it would be interesting to provide module specific mappings so deserialization logic is more consistent. This should be tackled in an additional issue / PR after removing the wrong Service Provider Interface configuration files.

@manusa manusa added the bug label Sep 16, 2020
rohanKanojia added a commit to rohanKanojia/kubernetes-client that referenced this issue Sep 29, 2020
…s Model Jars

Remove unused io.fabric8.kubernetes.api.KubernetesResourceMappingProvider from kubernetes model packages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants