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

java-sample build failed due to network io timeout, can we do offline build? #73

Open
zylan29 opened this issue May 7, 2022 · 3 comments

Comments

@zylan29
Copy link

zylan29 commented May 7, 2022

I am following the java-sample steps.

~ kubectl apply -f java-function-sample.yml

~ cat java-function-sample.yml
apiVersion: core.openfunction.io/v1beta1
kind: Function
metadata:
  name: java-sample
spec:
  version: "v1.0.0"
  image: "harbor.local/sample-java-func:latest"
  imageCredentials:
    name: harbor-secret
  port: 80 # default to 8080
  build:
    builder: "openfunction/gcp-builder:v1"
    env:
      GOOGLE_FUNCTION_TARGET: "com.openfunction.HelloWorld"
      GOOGLE_FUNCTION_SIGNATURE_TYPE: "http"
    srcRepo:
      url: "https://github.com/OpenFunction/samples.git"
      sourceSubPath: "functions/knative/hello-world-java"
      revision: "main"
  serving:
    runtime: knative # default to knative
    template:
      containers:
        - name: function
          imagePullPolicy: Always

The builder failed when step-create, the error log is following:

 ===> DETECTING
 4 of 5 buildpacks participating
 google.java.runtime             0.9.1
 google.java.maven               0.9.0
 google.java.functions-framework 1.0.1
 google.utils.label              0.0.1
 ===> ANALYZING
 Previous image with name "harbor.local/sample-java-func:latest" not found
 ===> RESTORING
 ===> BUILDING
 === Java - Runtime ([email protected]) ===
 Using latest Java 11 runtime version. You can specify a different version with GOOGLE_RUNTIME_VERSION: https://github.com/GoogleCloudPlatform/buildpacks#configuration
 Failure: (ID: 2ff5e9d8) getting status code for https://api.adoptopenjdk.net/v3/assets/feature_releases/11/ga?architecture=x64&heap_size=normal&image_type=jdk&jvm_impl=hotspot&os=linux&page=0&page_size=1&project=jdk&sort_order=DESC&vendor=adoptopenjdk: Head "https://api.adoptopenjdk.net/v3/assets/feature_releases/11/ga?architecture=x64&heap_size=normal&image_type=jdk&jvm_impl=hotspot&os=linux&page=0&page_size=1&project=jdk&sort_order=DESC&vendor=adoptopenjdk": dial tcp 104.17.158.60:443: i/o timeout
 --------------------------------------------------------------------------------
 Sorry your project couldn't be built.
 Our documentation explains ways to configure Buildpacks to better recognise your project:
  -> https://github.com/GoogleCloudPlatform/buildpacks/blob/main/README.md
 If you think you've found an issue, please report it:
  -> https://github.com/GoogleCloudPlatform/buildpacks/issues/new
 --------------------------------------------------------------------------------
 ERROR: failed to build: exit status 1

Since many production environments cannot access internet, can we build Function from source code without internet?

@zylan29 zylan29 changed the title java-sample build failed due network io timeout, can we do offline build? java-sample build failed due to network io timeout, can we do offline build? May 7, 2022
@tpiperatgod
Copy link
Member

It looks like your cluster can't access this address: dial tcp 104.17.158.60:443: i/o timeout

The openfunction/gcp-builder:v1 is a builder provided by Google, and it may require your network to be unrestricted. So we are working on builders that can adapt to multiple network environments, including the Java builder (in progress)

The workaround is to configure a proxy for your cluster so that the builder can access api.adoptopenjdk.net

@lizzzcai
Copy link
Member

lizzzcai commented May 8, 2022

Alternatively if your local network is good, you can build it in your local and push the image to your harbor.

  1. Install Docker and the pack tool.

  2. Build a container from your function using the Functions buildpacks:

pack build \
	--builder openfunction/gcp-builder:v1 \
	--env GOOGLE_FUNCTION_TARGET=com.openfunction.HelloWorld \
	--env GOOGLE_FUNCTION_SIGNATURE_TYPE=http \
	my-java-sample

Deploy the serving-only function like this example.

@benjaminhuo
Copy link
Member

Alternatively if your local network is good, you can build it in your local and push the image to your harbor.

  1. Install Docker and the pack tool.
  2. Build a container from your function using the Functions buildpacks:
pack build \
	--builder openfunction/gcp-builder:v1 \
	--env GOOGLE_FUNCTION_TARGET=com.openfunction.HelloWorld \
	--env GOOGLE_FUNCTION_SIGNATURE_TYPE=http \
	my-java-sample

Deploy the serving-only function like this example.

Thanks @lizzzcai , I'm going to add the pack build method to the official doc

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

No branches or pull requests

4 participants