Skip to content

fix: remove okhttp dependency #1793

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

Merged
merged 1 commit into from
Mar 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions caffeine-bounded-cache-support/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-httpclient-okhttp</artifactId>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is okhttp in this module? Probably should be vertx

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's test with all the different clients in integration tests in a different PR. In this PR, I wanted to have "some" coverage of the different http client implementations without getting into all possible combinations.

<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
28 changes: 21 additions & 7 deletions docs/documentation/v4-3-migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ permalink: /docs/v4-3-migration

## Condition API Change

In Workflows the target of the condition was the managed resource itself, not the target dependent resource.
In Workflows the target of the condition was the managed resource itself, not the target dependent resource.
This changed, now the API contains the dependent resource.

New API:

```java
public interface Condition<R, P extends HasMetadata> {
boolean isMet(DependentResource<R, P> dependentResource, P primary, Context<P> context);

boolean isMet(DependentResource<R, P> dependentResource, P primary, Context<P> context);

}
```

Expand All @@ -27,10 +27,24 @@ Former API:
```java
public interface Condition<R, P extends HasMetadata> {

boolean isMet(P primary, R secondary, Context<P> context);
boolean isMet(P primary, R secondary, Context<P> context);

}
```

Migration is trivial. Since the secondary resource can be accessed from the dependent resource. So to access the secondary
Migration is trivial. Since the secondary resource can be accessed from the dependent resource. So to access the
secondary
resource just use `dependentResource.getSecondaryResource(primary,context)`.

## HTTP client choice

It is now possible to change the HTTP client used by the Fabric8 client to communicate with the Kubernetes API server.
By default, the SDK uses the historical default HTTP client which relies on Okhttp and there shouldn't be anything
needed to keep using this implementation. The `tomcat-operator` sample has been migrated to use the Vert.X based
implementation. You can see how to change the client by looking at
that [sample POM file](https://github.com/java-operator-sdk/java-operator-sdk/blob/d259fcd084f7e22032dfd0df3c7e64fe68850c1b/sample-operators/tomcat-operator/pom.xml#L37-L50):

- You need to exclude the default implementation (in this case okhttp) from the `operator-framework` dependency
- You need to add the appropriate implementation dependency, `kubernetes-httpclient-vertx` in this case, HTTP client
implementations provided as part of the Fabric8 client all following the `kubernetes-httpclient-<implementation name>`
pattern for their artifact identifier.
6 changes: 6 additions & 0 deletions operator-framework-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-client</artifactId>
<exclusions>
<exclusion>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-httpclient-okhttp</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
Expand Down
5 changes: 4 additions & 1 deletion operator-framework/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
<groupId>io.javaoperatorsdk</groupId>
<artifactId>operator-framework-core</artifactId>
</dependency>

<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-httpclient-okhttp</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
Expand Down
24 changes: 23 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-client</artifactId>
<artifactId>kubernetes-client-api</artifactId>
<version>${fabric8-client.version}</version>
</dependency>
<dependency>
Expand Down Expand Up @@ -200,6 +200,28 @@
<artifactId>caffeine</artifactId>
<version>${caffeine.version}</version>
</dependency>
<!-- Kubernetes client HTTP client implementations -->
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-httpclient-okhttp</artifactId>
<version>${fabric8-client.version}</version>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-httpclient-vertx</artifactId>
<version>${fabric8-client.version}</version>
</dependency>
<!-- We currently only recommend using the legacy okhttp client and the vert.x-based implementation -->
<!-- <dependency>-->
<!-- <groupId>io.fabric8</groupId>-->
<!-- <artifactId>kubernetes-httpclient-jdk</artifactId>-->
<!-- <version>${fabric8-client.version}</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>io.fabric8</groupId>-->
<!-- <artifactId>kubernetes-httpclient-jetty</artifactId>-->
<!-- <version>${fabric8-client.version}</version>-->
<!-- </dependency>-->
</dependencies>
</dependencyManagement>

Expand Down
10 changes: 10 additions & 0 deletions sample-operators/tomcat-operator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@
<dependency>
<groupId>io.javaoperatorsdk</groupId>
<artifactId>operator-framework</artifactId>
<exclusions>
<exclusion>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-httpclient-okhttp</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-httpclient-vertx</artifactId>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
Expand Down