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

Replaced openshift-rest-client library with fabric8.kubernetes #3381

Merged

Conversation

l0rd
Copy link
Contributor

@l0rd l0rd commented Dec 14, 2016

Replace library (openshift-restclient)[https://github.com/openshift/openshift-restclient-java] with (fabric8-kubernetes)[https://github.com/fabric8io/kubernetes-client] to access the OpenShift API.

@ibuziuk and @amisevsk please review

Signed-off-by: Mario Loriedo mario.loriedo@gmail.com

@codenvy-ci
Copy link

Can one of the admins verify this patch?

</exclusions>
<groupId>io.fabric8</groupId>
<artifactId>openshift-client</artifactId>
<version>${io.fabric8.openshift-client.version}</version>
Copy link
Contributor

Choose a reason for hiding this comment

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

block should be in https://github.com/eclipse/che-dependencies/blob/master/pom.xml

and each dependency needs to have a CQ
I see one (your request) which is https://dev.eclipse.org/ipzilla/show_bug.cgi?id=12209 but it's for version 1.4 while here I see 1.4.26

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for your review @benoitf. Indeed this code is not ready to be merged to master yet.

Are you sure that a CQ for version 1.4 (which by the way doesn't exist) isn't valid for 1.4.* versions too?

Copy link
Contributor

Choose a reason for hiding this comment

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

@l0rd AFAIK each version need to be approved as it's based on the source code provided.

IMHO migrating from 1.4.25 to 1.4.26 requires a new CQ

also if I remember, even branches should have valid CQs (only code that is not in eclipse/che repository can use any code (for example your fork)

@@ -5,6 +5,9 @@
import com.openshift.restclient.IResourceFactory;
import com.openshift.restclient.model.IPort;
import com.openshift.restclient.model.IServicePort;
Copy link
Member

Choose a reason for hiding this comment

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

Need to remove obsolete com.openshift.restclient.* imports

@ibuziuk
Copy link
Member

ibuziuk commented Dec 14, 2016

@l0rd after switch to fabric8 I am not able to create any workspace. The problem seems to be coupled with "createOpenShiftService" method

@l0rd l0rd force-pushed the openshift-connector-fabric8 branch from 0200c9d to 47e77c6 Compare December 15, 2016 13:58
@ibuziuk
Copy link
Member

ibuziuk commented Dec 15, 2016

@lord here is the stacktrace:

org.eclipse.che.plugin.docker.machine.MachineProviderImpl.startService(MachineProviderImpl.java:276) ~[che-plugin-docker-machine-5.0.0-M8-SNAPSHOT.jar:5.0.0-M8-SNAPSHOT]
	... 11 common frames omitted
Caused by: javax.net.ssl.SSLPeerUnverifiedException: Hostname che.openshift.mini not verified:
    certificate: sha256/RW/0ZcaQ1MoE7yV6k1r0atg9d26hVQQ33FUId0j4ne0=
    DN: CN=127.0.0.1
    subjectAltNames: [127.0.0.1, 172.17.0.1, 172.30.0.1, 192.168.122.59, 192.168.42.195, kubernetes, kubernetes.default, kubernetes.default.svc, kubernetes.default.svc.cluster.local, localhost, openshift, openshift.default, openshift.default.svc, openshift.default.svc.cluster.local, 127.0.0.1, 172.17.0.1, 172.30.0.1, 192.168.122.59, 192.168.42.195]

it looks like che.openshift.mini hostname is forbidden to use

@ibuziuk
Copy link
Member

ibuziuk commented Dec 15, 2016

@benoitf yes, we are going to open a CQ for openshift-client 1.4.26 version. In the meantime I was trying to setup a build without using "-Dskip-enforce". I have added openshift-client to che-dependencies, but when I run the build I have the following error:

[INFO] Add the following to your pom to correct the missing dependencies: 
[INFO] 
<dependency>
  <groupId>io.fabric8</groupId>
  <artifactId>kubernetes-model</artifactId>
  <version>1.0.63</version>
</dependency>
<dependency>
  <groupId>io.fabric8</groupId>
  <artifactId>kubernetes-client</artifactId>
  <version>1.4.26</version>
</dependency>

So, in order to make it work I had to add those dependencies to pom.xml and che-dependencies - ibuziuk/che-dependencies@228bb81

Basically, openshift-client depends on those libs:

[INFO] +- io.fabric8:openshift-client:jar:1.4.26:compile
[INFO] |  \- io.fabric8:kubernetes-client:jar:1.4.26:compile
[INFO] |     +- io.fabric8:kubernetes-model:jar:1.0.63:compile
[INFO] |     |  \- com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.7.5:compile
[INFO] |     +- com.squareup.okhttp3:okhttp:jar:3.4.1:compile
[INFO] |     |  \- com.squareup.okio:okio:jar:1.9.0:compile
[INFO] |     +- com.squareup.okhttp3:logging-interceptor:jar:3.4.1:compile
[INFO] |     +- com.squareup.okhttp3:okhttp-ws:jar:3.4.1:compile
[INFO] |     +- org.slf4j:jul-to-slf4j:jar:1.7.6:compile
[INFO] |     +- com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:jar:2.5.0:compile
[INFO] |     +- com.fasterxml.jackson.core:jackson-databind:jar:2.5.0:compile
[INFO] |     |  \- com.fasterxml.jackson.core:jackson-annotations:jar:2.5.0:compile
[INFO] |     +- com.fasterxml.jackson.core:jackson-core:jar:2.5.0:compile
[INFO] |     +- io.fabric8:zjsonpatch:jar:0.2.3:compile
[INFO] |     \- com.github.mifmif:generex:jar:1.0.1:compile
[INFO] |        \- dk.brics.automaton:automaton:jar:1.11-8:compile

Am I correct that opening CQs for kubernetes-client & kubernetes-model is not required and they can be added once CQ for openshift-client 1.4.26 will be approved ?

@amisevsk
Copy link
Contributor

@ibuziuk @l0rd I don't seem to have any issue creating a workspace.

Copy link
Contributor

@amisevsk amisevsk left a comment

Choose a reason for hiding this comment

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

The changes seem good and the fabric8.kubernetes api seems to be a lot easier to read and work with. However there is a weird issue with stopping workspaces where deletion does not seem to be complete. I'll have to look into it more and test it on another machine later.

import io.fabric8.kubernetes.api.model.PodSpecBuilder;
import io.fabric8.kubernetes.api.model.Probe;
import io.fabric8.kubernetes.api.model.ProbeBuilder;
import io.fabric8.kubernetes.api.model.ReplicationController;
Copy link
Contributor

Choose a reason for hiding this comment

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

ReplicationController is an unused dependency.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed


// Then
List<String> keysAndValues = env.keySet().stream().map(k -> k + "=" + env.get(k)).collect(Collectors.toList());
List<String> keysAndValues = env.stream().map(k -> k.getName() + "=" + k.getValue()).collect(Collectors.toList());
assertTrue(Arrays.stream(envVariablesOut).anyMatch(keysAndValues::contains));
Copy link
Contributor

Choose a reason for hiding this comment

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

This test fails (and has been failing since bc0717a). We should fix or remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes good catch. This test didn't make sense anymore. I removed it.

openShiftClient.delete(pod);
if ( pod != null ) {
LOG.info("Removing OpenShift Pod " + pod.getMetadata().getName());
openShiftClient.resource(pod).delete();
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this may be causing an issue where OpenShift prevents full deletion of the pod. After I stop a workspace, OpenShift immediately recreates the pod, which is then stuck in ImagePullBackOff

> oc get pods
NAME                                       READY     STATUS             RESTARTS   AGE
che-host-1-oas8k                           1/1       Running            0          1h
che-ws-946kcw4tm6djd9k9-1058218227-rkm5w   0/1       ImagePullBackOff   0          5m
che-ws-y714ql3djvc4q1dy-1150559083-dyo0h   0/1       ImagePullBackOff   0          6m
router-1-wotpb                             2/2       Running            10         20d

These pods have replica sets that are not removed, and so they are recreated. Since a pod with the name exists, the corresponding workspace cannot be restarted.

> oc get replicasets
NAME                                 DESIRED   CURRENT   AGE
che-ws-946kcw4tm6djd9k9-1058218227   1         1         3m
che-ws-y714ql3djvc4q1dy-1150559083   1         1         1h

>oc get deployments
NAME                      DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
che-ws-946kcw4tm6djd9k9   1         1         1            0           21m
che-ws-y714ql3djvc4q1dy   1         1         1            0           1h

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've fixed that too thanks

@l0rd l0rd force-pushed the openshift-connector-fabric8 branch from 47e77c6 to d2a667e Compare December 16, 2016 03:21
@l0rd
Copy link
Contributor Author

l0rd commented Dec 16, 2016

@ibuziuk I can't reproduce your issue neither now. But I had this behaviour when I first started to test fabric8. That's related to the SSL certificate of minishift but I have no clue how to solve it: the issue has disappeared on my laptop without any particular change in the code or config (maybe try restarting minishift).

@ibuziuk
Copy link
Member

ibuziuk commented Dec 16, 2016

@l0rd deleting minishift cluster and creating it from scratch helped \o/ Not sure but might be coupled with a fact that I had obsolete openshift/origin-haproxy-router image. +1 for this changes once CQ is approved

@l0rd l0rd force-pushed the openshift-connector-fabric8 branch from d2a667e to 01bae4d Compare December 19, 2016 16:33
openShiftClient.delete(pod);
if ( pod != null ) {
LOG.info("Removing OpenShift Pod " + pod.getMetadata().getName());
openShiftClient.resource(pod).delete();
Copy link
Member

Choose a reason for hiding this comment

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

@l0rd missing curly brace after rebase

IService svc = getCheServiceBySelector("deploymentConfig", deploymentConfig);
Map<String, String> annotations = convertKubernetesNamesToLabels(svc.getAnnotations());
Pod pod = getChePodByContainerId(info.getId());
if (pod == null ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

spaces for if () are different in the file

expected formatting is
if (var != value)

we have
if ( var != value )
or
if (var != value )
or
if (var!=value)

@skabashnyuk skabashnyuk removed the request for review from garagatyi December 20, 2016 09:37
Signed-off-by: Mario Loriedo <mloriedo@redhat.com>
@l0rd l0rd force-pushed the openshift-connector-fabric8 branch from 01bae4d to 3e80ee6 Compare December 20, 2016 10:26
@l0rd
Copy link
Contributor Author

l0rd commented Dec 20, 2016

@ibuziuk @benoitf guys thank you for reviewing this. I did the necessary updates.

The CQ has been updated with the right version (1.4.26). @benoitf everything should be ok to merge this to openshift-connector branch?

@benoitf
Copy link
Contributor

benoitf commented Dec 20, 2016

@l0rd yes for this PR all is fine for me.
Issue on CQ is only on eclipse-che/che-dependencies#23

@l0rd l0rd merged commit b087db8 into eclipse-che:openshift-connector Dec 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants