-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
CHE-26: Initial OpenShift integration #3798
Conversation
Can one of the admins verify this patch? |
@l0rd @amisevsk could you please verify? Just do not forget to build che-dependencies from https://issues.jboss.org/browse/CHE-26 first |
FYI, we are implementing a new maintenance policy for PRs where each PR will need to have completed changelog, docs linked PR, and release notes included within it before merge. We are documenting this now and how maintainers + PR submitters are to work through these items. But as this is significant, wanted to give this heads up. |
@TylerJewell Since this is the initial implementation and we will have a few more iterations until this is completed. Perhaps we can open an issue and for the missing docs and assign it to @ibuziuk or @l0rd. |
Like larger projects, we have moved all of the docs into a separate repository. It seems essential so that the core repository doesn't end up with a lot of large image or animated gif files that complicates cloning and fetching with git. So, we have moved everything into github.com/codenvy/che-docs as a repository and it will be moved into github.com/eclipse/che-docs as soon as the repository has been created and CQ passed, which should be this week. But in the mean time, we ask that every core PR have a matching che-docs PR linked into it, and then both PRs are merged at the same time. If you'd like a separate issue for just that work, that makes sense. |
@TylerJewell @gorkem I would be glad to work on documentation part |
Thanks, @gorkem and @ibuziuk for being flexible with us as we work to get our documentation processes better refined. I know they are in a state of flux right now, so having ambiguous rules that must be passed in order to get something merged is not good for anyone. The basic rules of what we are thinking for docs is the following three things provided within the PR:
In this case for the documentation, I think there are probably a few pages of the docs that should be updated:
|
ci-build |
Issue for documenting the process of deployment Che on OpenShift has been created https://github.com/codenvy/che-docs/issues/76 |
Build success. https://ci.codenvycorp.com/job/che-pullrequests-build/1694/ |
this.nameGenerator = nameGenerator; | ||
this.runtimes = workspaceRuntimes; | ||
this.runtimes = workspaceRuntimes; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indent looks like incorrect
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
@@ -104,7 +105,7 @@ | |||
private final MachineRuntimeInfoImpl machineRuntime; | |||
|
|||
@Inject | |||
public DockerInstance(DockerConnector docker, | |||
public DockerInstance(DockerConnectorProvider dockerProvider, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need guice Providers vs named connector ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I got the comment :( We do need to inject provider because now it is in charge of providing suitable connector (DockerConnector / OpenShiftConnector) based on che.docker_connector.provider
property
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@benoitf BTW, similar approach is used for obtaining ServerEvaluationStrategy (default / docker-local) - https://github.com/eclipse/che/blob/master/plugins/plugin-docker/che-plugin-docker-machine/src/main/java/org/eclipse/che/plugin/docker/machine/local/LocalDockerModule.java#L52
And I think it is relevant to also use MapBinder for DockerConnector use-case (default / openshift)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ibuziuk I agree
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with Florent that it would look prettier if we get rid of injecting provider. There is always a way to reduce distraction. But up to you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@garagatyi For initial implementation I would rather leave it this way. The usage of DockerConnectorProvider
will be changed once OpenShiftConnector
is decoupled from DockerConnector
and there will be a good time for rethinking the whole approach
<build> | ||
<resources> | ||
<resource> | ||
<directory>src/main/java</directory> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to specify this directory as a resource item ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
private final KubernetesContainer kubernetesContainer; | ||
private final KubernetesService kubernetesService; | ||
private final String cheOpenShiftProjectName; | ||
private final String cheOpenShiftServiceAccount; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure indent of previous lines are compliant with code style
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
@Named("che.openshift.username") String openShiftUserName, | ||
@Named("che.openshift.password") String openShiftUserPassword, | ||
@Named("che.openshift.project") String cheOpenShiftProjectName, | ||
@Named("che.openshift.serviceaccountname") String cheOpenShiftServiceAccount) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a reason why some of attributes for che.* are starting with che and others by openShift ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed. All attributes are now starting with openShift.*
LOG.warn("Expected CreateContainerParams label key " + entry.getKey() + | ||
" to start with " + CHE_SERVER_LABEL_PREFIX); | ||
} else if (key.contains(".") || key.contains("_") || value.contains("_")) { | ||
LOG.error(String.format("Cannot convert label %s to DNS Name: " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do not use format and +
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
value = String.format(CHE_SERVER_LABEL_PADDING, value); | ||
|
||
if (!key.matches(KUBERNETES_ANNOTATION_REGEX) || !value.matches(KUBERNETES_ANNOTATION_REGEX)) { | ||
LOG.error(String.format("Could not convert label %s into Kubernetes annotation: " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do not use + and format
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
import io.fabric8.kubernetes.api.model.IntOrString; | ||
import io.fabric8.kubernetes.api.model.ServicePort; | ||
|
||
public class KubernetesService { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
javadoc is missing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
public class KubernetesService { | ||
|
||
public List<ServicePort> getServicePortsFrom(Set<String> exposedPorts) { | ||
List<ServicePort> servicePorts = new ArrayList<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
size is known so we can define it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
@@ -1214,23 +1214,6 @@ | |||
</configuration> | |||
</execution> | |||
<execution> | |||
<id>distribution-management-used</id> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is it removed ?
@benoitf thank you for review. Working on improvements.. |
b8ccae9
to
0275d07
Compare
ci-build |
ci-build |
Build # 1737 - FAILED Please check console output at https://ci.codenvycorp.com/job/che-pullrequests-build/1737/ to view the results. |
@l0rd could you please push the build ? it seems to be working only for committers. There is one regression test failure, but all tests pass on my machine |
@garagatyi @gazarenkov guys, could you please review the PR ? |
ci-build |
1 similar comment
ci-build |
Guys how do you want to merge this PR? Are you going to do merge with rebase or squash or just merge? |
@gazarenkov @benoitf Can you take one more look? |
@garagatyi thanks for review. I would rather opt for "just merge" as there are commits from different authors in the PR. @l0rd WDYT ? |
Maybe you can try to rebase with newest master at the time you will merge and if there will be no conflicts then merge this PR with Github's merge with rebase? @l0rd WDYT? |
@garagatyi after some discussion it was decided to squash last three commits and use "Rebase and Merge" strategy for applying the PR. Also, there is some problem with ip-validation - all commits have "Signed-off-by" section but the check still fails |
@ibuziuk sometimes the script is failing |
@garagatyi Yes we would like to keep the 3 significant commit and squash last two commits. Then rebase + merge as soon as soon as review is complete. |
@benoitf oh, ok |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gazarenkov @benoitf Can you take one more look?
I give a new look at it
I've commented with some errors reported by FindBugs or SonarLint
OpenShift connector class is tested at:
7% method, 6% lines covered
while DockerConnector is tested at
100% methods, 95% line covered
Note: the kubernetes module is better tested: 100% classes, 89% lines covered
openShiftClient.resource(replicaSet).delete(); | ||
} | ||
|
||
if (pod != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using SonarLint, I have the warning that this variable is always non null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
|
||
String containerID = waitAndRetrieveContainerID(deploymentName); | ||
if (containerID == null) { | ||
throw new RuntimeException("Failed to get the ID of the container running in the OpenShift pod"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sonarlint hint is to subclass this exception
Using such generic exceptions as Error, RuntimeException, Throwable, and Exception prevents calling methods from handling true, system-generated exceptions differently than application-generated errors.
Noncompliant Code Example
public void foo(String bar) throws Throwable { // Noncompliant
throw new RuntimeException("My Message"); // Noncompliant
}
Compliant Solution
public void foo(String bar) {
throw new MyOwnRuntimeException("My Message");
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
*/ | ||
public Map<String, String> labelsToNames(Map<String, String> labels) { | ||
Map<String, String> names = new HashMap<>(); | ||
for (Map.Entry<String, String> entry : labels.entrySet()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SonarLint is flagging this loop as error
Loops should not contain more than a single "break" or "continue" statement
squid:S135
Restricting the number of break and continue statements in a loop is done in the interest of good structured programming.
One break and continue statement is acceptable in a loop, since it facilitates optimal coding. If there is more than one, the code should be refactored to increase readability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the method has been refactored
} | ||
|
||
private Pod getChePodByContainerId(String containerId) throws IOException { | ||
Map<String, String> podLabels = new HashMap<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
findbugs shows that podLabels is initialized but never used in that method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
Signed-off-by: Mario Loriedo <[email protected]>
Adds class so that choice between DockerConnector and OpenShiftConnector can be made via setting a property in che.properties. The provider is injected instead of DockerConnector, and provides the appropriate implementation through a get() method. Signed-off-by: Angel Misevski <[email protected]>
…resources (KubernetesContainer, KubernetesService, KubernetesEnvVar) Signed-off-by: Ilya Buziuk <[email protected]>
@benoitf thanks again for reviewing. PR has been updated with fixes and rebased on the current master branch. In terms of test coverage there are several reasons why
Basically, this PR is just initial minimal OpenShift integration piece and most of the code together with tests will be changed / refactored once Service Provider Interface is defined. |
@ibuziuk ok thanks for the fixes. |
hey guys we have problems with compilation of https://github.com/codenvy/codenvy project seems due to those changes. @garagatyi @benoitf can you guys please take a look
more info: https://ci.codenvycorp.com/job/codenvy-ci-master/1293/console |
Hi @riuvshin. One of the changes this PR makes is to inject DockerConnectorProvider instead of DockerConnector. This is done because OpenShiftConnector is a replacement for DockerConnector when running Che on OpenShift. This means changing the method signature for constructors using DockerConnector to use DockerConnectorProvider instead, and calling DockerConnectorProvider.get() to get the DockerConnector instance. To accommodate this change in Codenvy, classes calling these constructors will have to be changed. I'll be available later to explain the required fixes in more detail. |
@riuvshin We missed this as consequence of missing QA cycle. |
I've created a PR codenvy/codenvy#1636 |
Update code based on CHE #3798 updates
If it helps, the classes in the main codebase that are affected are Any classes calling these constructors directly would need to be modified, as in @benoitf's PR. |
What does this PR do?
Initial OpenshiftConnector implementation
What issues does this PR fix or reference?
https://issues.jboss.org/browse/CHE-26
NOTE: Do not merge until PR with
io.fabric8
dependencies is applied - eclipse-che/che-dependencies#23New behavior
Provides a possibility to use openshift
io.fabric8
API for container managementTests written?
Yes
Changelog and Release Note Information
Changelog
Add
OpenShiftConnector
to supportio.fabric8
API for container management.Release Notes:
[no release notes since this is part of a work in progress]
Docs Pull Request:
Docs issue is here, but docs won't be created until #2847 is complete.