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

Add internal and external API URL environment variables for workspaces #9475

Merged
merged 22 commits into from
Apr 27, 2018

Conversation

mkuznyetsov
Copy link
Contributor

@mkuznyetsov mkuznyetsov commented Apr 18, 2018

What does this PR do?

All workspaces will be provided with additional environment variables, that will point to internal or external API URL. On Docker infrastructure:

  • CHE_API_INTERNAL variable will be provided from "che.infra.docker.master_api_endpoint" (or in case one is not set/set to null, then value from CHE_API env. var will be used).
  • Same value is provided for CHE_API.
  • CHE_API_EXTERNAL is provided from "che.api" property, defined in che.properties

In Openshift and Kubernetes,CHE_API, CHE_API_INTERNAL, CHE_API_EXTERNAL will be the same and based from "che.api" property.

What issues does this PR fix or reference?

#9323

Release Notes

Docs PR

import org.eclipse.che.api.workspace.server.spi.InfrastructureException;
import org.eclipse.che.commons.lang.Pair;

/** @author Sergii Leshchenko */
Copy link
Member

Choose a reason for hiding this comment

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

Please fix authorship here


@Inject
public DockerCheApiExternalEnvVarProvider() {
apiEnvVar = Pair.of(CHE_API_EXTERNAL_VARIABLE, System.getenv(CHE_API_EXTERNAL_VARIABLE));
Copy link
Member

Choose a reason for hiding this comment

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

Please explain why do you use System.getenv(CHE_API_EXTERNAL_VARIABLE) but not injected che.api constant

@Inject
public DockerCheApiInternalEnvVarProvider(
@Named("che.infra.docker.master_api_endpoint") String apiEndpoint) {
String apiEndpointEnvVar = System.getenv(CHE_API_INTERNAL_VARIABLE);
Copy link
Member

Choose a reason for hiding this comment

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

I would say that it should be removed. If a user wants to customize this value he is able to specify CHE_INFRA_DOCKER_MASTER__API__ENDPOINT environment variable.

@mkuznyetsov
Copy link
Contributor Author

ci-test

@codenvy-ci
Copy link

ci-test build report:
Build details
Test report
selenium tests report data
docker image: eclipseche/che-server:9475
https://github.com/orgs/eclipse/teams/eclipse-che-qa please check this report.

@mkuznyetsov
Copy link
Contributor Author

ci-test

@codenvy-ci
Copy link

ci-test build report:
Build details
Test report
selenium tests report data
docker image: eclipseche/che-server:9475
https://github.com/orgs/eclipse/teams/eclipse-che-qa please check this report.

@@ -51,7 +51,6 @@ CHE_LOGS_DIR=/logs
CHE_WORKSPACE_LOGS=/logs/machines
CHE_TEMPLATE_STORAGE=/data/templates


Copy link
Contributor

Choose a reason for hiding this comment

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

remove this change if not needed

@@ -160,7 +160,7 @@
#
# Browser --> Che Server
# 1. Default is 'http://localhost:${SERVER_PORT}/api'.
# 2. Else use the value of CHE_API
# 2. Else use the value of CHE_API_EXTERNAL
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess we need to remove this change too.

@@ -37,6 +37,7 @@ public void provision(RuntimeIdentity id, InternalEnvironment internalEnvironmen
throws InfrastructureException {
for (EnvVarProvider envVarProvider : envVarProviders) {
Pair<String, String> envVar = envVarProvider.get(id);

Copy link
Contributor

Choose a reason for hiding this comment

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

remove this change if not needed

@riuvshin
Copy link
Contributor

ci-test

@codenvy-ci
Copy link

ci-test build report:
Build details
Test report
selenium tests report data
docker image: eclipseche/che-server:9475
https://github.com/orgs/eclipse/teams/eclipse-che-qa please check this report.

@riuvshin
Copy link
Contributor

ci-test

@codenvy-ci
Copy link

ci-test build report:
Build details
Test report
selenium tests report data
docker image: eclipseche/che-server:9475
https://github.com/orgs/eclipse/teams/eclipse-che-qa please check this report.

@riuvshin
Copy link
Contributor

ci-test

@codenvy-ci
Copy link

ci-test build report:
Build details
Test report
selenium tests report data
docker image: eclipseche/che-server:9475
https://github.com/orgs/eclipse/teams/eclipse-che-qa please check this report.

@riuvshin riuvshin requested a review from a user April 18, 2018 16:29
@riuvshin riuvshin requested a review from l0rd as a code owner April 18, 2018 16:29
@riuvshin
Copy link
Contributor

ci-test

@ghost
Copy link

ghost commented Apr 18, 2018

ci-test

@codenvy-ci
Copy link

ci-test build report:
Build details
Test report
selenium tests report data
docker image: eclipseche/che-server:9475
https://github.com/orgs/eclipse/teams/eclipse-che-qa please check this report.

@benoitf benoitf added status/code-review This issue has a pull request posted for it and is awaiting code review completion by the community. kind/task Internal things, technical debt, and to-do tasks to be performed. labels Apr 19, 2018
String CHE_API_INTERNAL_VARIABLE = "CHE_API_INTERNAL";

/**
* Returns Che API environment variable which should be injected into machines.
Copy link
Member

Choose a reason for hiding this comment

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

Please document what is internal Che API URL

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -67,6 +71,8 @@ protected void configure() {
bind(RemoveProjectOnWorkspaceRemove.class).asEagerSingleton();

bind(CheApiEnvVarProvider.class).to(KubernetesCheApiEnvVarProvider.class);
Copy link
Member

Choose a reason for hiding this comment

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

Do we still need CHE_API env var?
Or it wasn't removed because of backward compatibility? If yes, then maybe it would be better to ensure it on Workspace API level instead of each infrastructure?
I mean creating CheApiEnvVarProvider class that will inject CheApiInternalEnvVarProvider and provide its value as CHE_API. WDYT?

@mkuznyetsov
Copy link
Contributor Author

ci-test

Copy link
Member

@sleshchenko sleshchenko left a comment

Choose a reason for hiding this comment

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

LGTM


/**
* Returns Che API environment variable which should be injected into machines.
* Internal API URL is meant to be used from the inside of other machine containers.
Copy link
Member

Choose a reason for hiding this comment

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

I wouldn't use containers word here. I think other machines would be fine

@codenvy-ci
Copy link

ci-test build report:
Build details
Test report
selenium tests report data
docker image: eclipseche/che-server:9475
https://github.com/orgs/eclipse/teams/eclipse-che-qa please check this report.

@mkuznyetsov mkuznyetsov merged commit b14ec23 into master Apr 27, 2018
@mkuznyetsov mkuznyetsov deleted the che-9323 branch April 27, 2018 07:51
@benoitf benoitf removed the status/code-review This issue has a pull request posted for it and is awaiting code review completion by the community. label Apr 27, 2018
@benoitf benoitf added this to the 6.5.0 milestone Apr 27, 2018
@skabashnyuk skabashnyuk mentioned this pull request Jan 13, 2020
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/task Internal things, technical debt, and to-do tasks to be performed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants