Skip to content
This repository has been archived by the owner on Aug 16, 2024. It is now read-only.

Build an offline version of the Devfile registry image #112

Merged
merged 3 commits into from
Oct 11, 2019

Conversation

amisevsk
Copy link
Contributor

@amisevsk amisevsk commented Oct 7, 2019

Important Note: this PR is set to target the override-images branch until #110 is merged, as it also requires modification of the container entrypoint. Once PR #110 is merged, I will update target branch to master.

What does this PR do?

Enables building an offline version of the devfile registry.

As in the similar feature for the plugin registry, this is done by specifying --target offline-registry during the docker build (with the current online registry being built by --target registry).

The offline registry downloads all project zip files for projects hosted on github and stores them in the /resources dir. Devfiles are updated to contain a placeholder, which is filled from an env var (CHE_DEVFILE_HTTPS_ENDPOINT) that must be set at runtime.

What issues does this PR fix or reference?

eclipse-che/che#14733

Additional Info

Tested on OpenShift 3.11, manually setting the required environment variable. It works generally as desired, except I encountered issue eclipse-che/che#14800.

Caveat

For this solution to be viable, all the sample projects to be bundled need to have their license/copyright info correctly configured.

See https://issues.jboss.org/browse/CRW-317?focusedCommentId=13798222&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13798222 for a list of the problems with the sample projects' licenses/copyright info.

@amisevsk
Copy link
Contributor Author

amisevsk commented Oct 7, 2019

Update: the last commit adds an attempt to determine the registry's service IP and port from k8s env vars when the required environment variable is not set. This should work in many cases but is rather fragile. I haven't tested it for workspaces in another namespace, etc.

@amisevsk amisevsk changed the base branch from override-images to master October 10, 2019 22:12
@amisevsk
Copy link
Contributor Author

Squashed and rebased onto master now that #110 is merged; PR is ready for review

cc: @l0rd @nickboldt

# In addition, this script will perform the necessary set up for the offline
# devfile registry, replacing placeholders in all devfiles based off environment
# variable
# CHE_DEVFILE_HTTPS_ENDPOINT

Choose a reason for hiding this comment

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

So I assume that in airgap mode, from the operator, we would also have to add this variable in the new devfile registry config map, based on the external URL of the devfile registry ?

@l0rd do you confirm ?

cc @tomgeorge

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, that's accurate; we need the environment variable to be able to rewrite devfiles to point at exposed endpoints. Without the environment variable we do try to use k8s-provisioned env vars to determine service IP and route, but I haven't tested this much and it may be unreliable.

Copy link
Contributor

Choose a reason for hiding this comment

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

@davidfestal yes that's the weakness of this solution. There is no reliable way to figure the value automatically.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In particular, without the env var set, we try to go off of

URL="http://${CHE_DEVFILE_REGISTRY_SERVICE_HOST}:${CHE_DEVFILE_REGISTRY_SERVICE_PORT}"

which depends on the devfile registry server being called che-devfile-registry, and may not work in some scenarios (I don't know the internals of networking on OpenShift).

@davidfestal
Copy link

@l0rd @nickboldt So I assume that if we would like to use the devfile registry with embedded samples inside for the airgap mode, we should first have built that with the offine-registry mode.
So we should have 2 different registry images and switch from one to the other in the operator if we use airgap ?
Not sure I understand how this will be used in the case of the operator airgap mode.

@nickboldt
Copy link
Contributor

I suspect for CRW 2 we will only build & publish the offline/airgap option. Yes, it's a bigger image to download than the online flavour, but it's also more guaranteed to work as all the plugins/projects will be self-contained in the devfile and plugin reg containers.

@l0rd
Copy link
Contributor

l0rd commented Oct 11, 2019

I agree with @nickboldt. It will be the default downstream (and we should consider to make it the default upstream as well c.f. this comment)

@l0rd
Copy link
Contributor

l0rd commented Oct 11, 2019

@amisevsk I think we should update the container build section in the README file as well and the "Customizing the devfile and plugin-in registries" section in the doc. But considered that this PR may block other PRs we can merge it and address the doc in a separate one.

@davidfestal
Copy link

we should consider to make it the default upstream as well

+1

@amisevsk
Copy link
Contributor Author

@l0rd I added some docs to the README.md and opened issue eclipse-che/che#14866 to track the larger documentation task

Copy link
Contributor

@nickboldt nickboldt left a comment

Choose a reason for hiding this comment

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

I like this solution.

However...

For this solution to be viable, all the sample projects to be bundled need to have their license/copyright info correctly configured.

See https://issues.jboss.org/browse/CRW-317?focusedCommentId=13798222&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13798222 for a list of the problems with the sample projects' licenses/copyright info.

@amisevsk
Copy link
Contributor Author

Rebased on master to fix merge conflict.

@amisevsk
Copy link
Contributor Author

For this solution to be viable, all the sample projects to be bundled need to have their license/copyright info correctly configured.

Che issue for this: eclipse-che/che#14790

Enable users to build an offline version of the devfile registry, which
contains .zip files for all projects. The offline registry should be
launched with environment variable CHE_DEVFILE_HTTPS_ENDPOINT set to the
public URL of the devfile registry for it to properly serve project zip
files. If the environment variable is not set at startup, the registry
will try to resolve its cluster IP and port from Kubernetes-provisioned
environment variables.

The regular (non-offline) build of the registry now requires docker
builds to target 'registry', e.g.

    docker build [...] --target registry

offline builds can instead target 'offline-registry'

Signed-off-by: Angel Misevski <amisevsk@redhat.com>
Signed-off-by: Angel Misevski <amisevsk@redhat.com>
Signed-off-by: Angel Misevski <amisevsk@redhat.com>
@amisevsk amisevsk merged commit d3ecb92 into eclipse-che:master Oct 11, 2019
@nickboldt nickboldt mentioned this pull request Oct 11, 2019
monaka referenced this pull request in PizzaFactory/che-devfile-registry Nov 25, 2019
* Enable building offline version of registry

Enable users to build an offline version of the devfile registry, which
contains .zip files for all projects. The offline registry should be
launched with environment variable CHE_DEVFILE_HTTPS_ENDPOINT set to the
public URL of the devfile registry for it to properly serve project zip
files. If the environment variable is not set at startup, the registry
will try to resolve its cluster IP and port from Kubernetes-provisioned
environment variables.

The regular (non-offline) build of the registry now requires docker
builds to target 'registry', e.g.

    docker build [...] --target registry

offline builds can instead target 'offline-registry'

Signed-off-by: Angel Misevski <amisevsk@redhat.com>
monaka referenced this pull request in PizzaFactory/che-devfile-registry Nov 25, 2019
* Enable building offline version of registry

Enable users to build an offline version of the devfile registry, which
contains .zip files for all projects. The offline registry should be
launched with environment variable CHE_DEVFILE_HTTPS_ENDPOINT set to the
public URL of the devfile registry for it to properly serve project zip
files. If the environment variable is not set at startup, the registry
will try to resolve its cluster IP and port from Kubernetes-provisioned
environment variables.

The regular (non-offline) build of the registry now requires docker
builds to target 'registry', e.g.

    docker build [...] --target registry

offline builds can instead target 'offline-registry'

Signed-off-by: Angel Misevski <amisevsk@redhat.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants