Skip to content

Commit

Permalink
fix (openshift-client) : Change ManagedOpenShiftClient OSGi Configura…
Browse files Browse the repository at this point in the history
…tionPolicy to REQUIRE (fabric8io#3864)

Just like ManagedKubernetesClient, ManagedOpenShiftClient also doesn't
handle `activate()` being called with null properties. Setting Component
configuration policy to REQUIRE which would make having configuration
object for ManagedOpenShiftClient (i.e. `src/main/resources/assembly/etc/io.fabric8.openshift.client.cfg`) compulsory.

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
  • Loading branch information
rohanKanojia committed Sep 23, 2022
1 parent 4856950 commit 7aa186c
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -12,6 +12,7 @@
* Fix #4365: The Watch retry logic will handle more cases, as well as perform an exceptional close for events that are not properly handled. Informers can directly provide those exceptional outcomes via the SharedIndexInformer.stopped CompletableFuture.
* Fix #4396: Provide more error context when @Group/@Version annotations are missing
* Fix #4384: The Java generator now supports the generation of specific annotations (min, max, pattern, etc.), as defined by #4348
* Fix #3864: Change ManagedOpenShiftClient OSGi ConfigurationPolicy to REQUIRE

#### Dependency Upgrade
* Fix #4243: Update Tekton pipeline model to v0.39.0
Expand All @@ -26,6 +27,7 @@
* Fix #4350: SchemaSwap's fieldName parameter now expects a field name only, not a method or a constructor.
* Module `io.fabric8:tekton-model-triggers` which contained Tekton triggers v1alpha1 model has been removed. We have introduced separate modules `io.fabric8:tekton-model-v1alpha1` and `io.fabric8:tekton-model-v1beta1` for Tekton triggers v1alpha1 and v1beta1 apigroups respectively. Users who are using `io.fabric8:tekton-client` dependency directly should be unaffected by this change.
* Fix #4384: javax.validation.* annotations are no longer added by the Java generator.
* Fix #3864: Now it's compulsory to provide `etc/io.fabric8.openshift.client.cfg` file in order to load ManagedOpenShiftClient in OSGi environment.

### 6.1.1 (2022-09-01)

Expand Down
34 changes: 34 additions & 0 deletions doc/FAQ.md
Expand Up @@ -49,3 +49,37 @@ Finally the fabric8 client will use 1 thread per PortForward and an additional t
Like many java application the Fabric8 Client utilizes [slf4j](https://www.slf4j.org/). You may configure support for whatever underlying logging framework suits your needs. The logging contexts for the Fabric8 Client follow the standard convention of the package structure - everything from within the client will be rooted at the io.fabric8 context. Third-party dependencies, including the chosen HTTP client implementation, will have different root contexts.

If you are using pod exec, which can occur indirectly via pod operations like copying files, and not seeing the expected behavior - please enable debug logging for the io.fabric8.kubernetes.client.dsl.internal context. That will provide the stdErr and stdOut as debug logs to further diagnose what is occurring.

### How to use KubernetesClient in OSGi?

Fabric8 Kubernetes Client provides ManagedKubernetesClient and ManagedOpenShiftClient as [OSGi Declarative Service](https://docs.osgi.org/specification/osgi.cmpn/7.0.0/service.component.html). In order to use it, you must have [Service Component Runtime (SCR)](https://docs.osgi.org/specification/osgi.cmpn/7.0.0/service.component.html#service.component-service.component.runtime) feature enabled in your OSGi runtime. In [Apache Karaf](https://karaf.apache.org/), you can add this to Karaf Maven Plugin configuration:
```xml
<plugin>
<groupId>org.apache.karaf.tooling</groupId>
<artifactId>karaf-maven-plugin</artifactId>
<version>${karaf.version}</version>
<configuration>
<startupFeatures>
<feature>scr</feature>
</startupFeatures>
</configuration>
</plugin>
```

You would need to provide component configuration files for the client you're using. For example, in case of [Apache Karaf](https://karaf.apache.org/), place configuration files in this directory:
```
src/
└── main
└── resources
├── assembly
│ └── etc
│ ├── io.fabric8.kubernetes.client.cfg
│ ├── io.fabric8.openshift.client.cfg
```

Once added KubernetesClient declarative services would be exposed automatically on startup. Then you can inject it in your project. Here is an example using Apache camel's `@BeanInject` annotation:

```java
@BeanInject
private KubernetesClient kubernetesClient
```
Expand Up @@ -183,7 +183,7 @@
import static io.fabric8.openshift.client.OpenShiftConfig.OPENSHIFT_BUILD_TIMEOUT_SYSTEM_PROPERTY;
import static io.fabric8.openshift.client.OpenShiftConfig.OPENSHIFT_URL_SYSTEM_PROPERTY;

@Component(configurationPid = "io.fabric8.openshift.client", policy = ConfigurationPolicy.OPTIONAL)
@Component(configurationPid = "io.fabric8.openshift.client", policy = ConfigurationPolicy.REQUIRE)
@Service({ OpenShiftClient.class, NamespacedOpenShiftClient.class })
public class ManagedOpenShiftClient extends NamespacedKubernetesClientAdapter<NamespacedOpenShiftClient>
implements NamespacedOpenShiftClient {
Expand Down
Expand Up @@ -55,6 +55,8 @@ Option[] baseConfiguration(Option features, List<Option> extraOptions) {
features,
editConfigurationFileExtend(
"etc/io.fabric8.kubernetes.client.cfg", "junit", "ignored"),
editConfigurationFileExtend(
"etc/io.fabric8.openshift.client.cfg", "junit", "ignored"),
editConfigurationFileExtend(
"etc/org.ops4j.pax.url.mvn.cfg",
"org.ops4j.pax.url.mvn.repositories",
Expand Down Expand Up @@ -94,6 +96,8 @@ Option[] baseConfiguration(Option features, List<Option> extraOptions) {
features,
editConfigurationFileExtend(
"etc/io.fabric8.kubernetes.client.cfg", "junit", "ignored"),
editConfigurationFileExtend(
"etc/io.fabric8.openshift.client.cfg", "junit", "ignored"),
editConfigurationFileExtend(
"etc/org.ops4j.pax.url.mvn.cfg",
"org.ops4j.pax.url.mvn.repositories",
Expand Down

0 comments on commit 7aa186c

Please sign in to comment.