Skip to content

Commit d97ad29

Browse files
committed
chore(builder): minio/minio#13799
1 parent afbc69e commit d97ad29

6 files changed

Lines changed: 20 additions & 10 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ The builder is primarily a git server that responds to `git push`es by executing
2121
1. Calls `git archive` to produce a tarball (i.e. a `.tar.gz` file) on the local file system
2222
2. Saves the tarball to centralized object storage according to the following rules:
2323
- If the `BUILDER_STORAGE` environment variable is other than `minio`, attempts to create the appropriate storage driver and saves using this driver.
24-
- Otherwise, if `BUILDER_STORAGE` is `minio` and the `DRYCC_MINIO_ENDPOINT` environment variables exist (these are standard [Kubernetes service discovery environment variables](http://kubernetes.io/docs/user-guide/services/#environment-variables)), saves to the [S3 API][s3-api-ref] compatible server at `http://$DRYCC_MINIO_ENDPOINT`
24+
- Otherwise, if `BUILDER_STORAGE` is `minio` and the `DRYCC_MINIO_ENDPOINT` environment variables exist (these are standard [Kubernetes service discovery environment variables](http://kubernetes.io/docs/user-guide/services/#environment-variables)), saves to the [S3 API][s3-api-ref] compatible server at `$DRYCC_MINIO_ENDPOINT`
2525
3. Starts a new [Kubernetes Pod](http://kubernetes.io/docs/user-guide/pods/) to build the code, according to the following rules:
2626
- If there is a `Dockerfile`, build the container with imagebuilder
2727
- Otherwise, use imagebuilder to build CNCF native buildpack

charts/builder/templates/_helpers.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ env:
3939
value: {{.Values.builder_pod_node_selector}}
4040
{{- if eq .Values.global.minioLocation "on-cluster" }}
4141
- name: "DRYCC_MINIO_ENDPOINT"
42-
value: ${DRYCC_MINIO_SERVICE_HOST}:${DRYCC_MINIO_SERVICE_PORT}
42+
value: http://${DRYCC_MINIO_SERVICE_HOST}:${DRYCC_MINIO_SERVICE_PORT}
4343
{{- else }}
4444
- name: "DRYCC_MINIO_ENDPOINT"
4545
value: "{{ .Values.minio.endpoint }}"

charts/builder/templates/builder-deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ spec:
3030
args:
3131
- netcat
3232
- -v
33-
- -a
33+
- -u
3434
- $(DRYCC_MINIO_ENDPOINT)
3535
{{- include "builder.envs" . | indent 8 }}
3636
containers:

pkg/conf/config.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ package conf
33
import (
44
"fmt"
55
"io/ioutil"
6+
"net"
7+
"net/url"
8+
"os"
69
"strings"
710

811
"github.com/drycc/builder/pkg/sys"
@@ -50,9 +53,15 @@ func GetStorageParams(env sys.Env) (Parameters, error) {
5053
params[file.Name()] = string(data)
5154
}
5255
params["bucket"] = params["builder-bucket"]
53-
mEndpointVar := env.Get(minioEndpointVar)
54-
params["region"] = "us-east-1"
55-
params["regionendpoint"] = fmt.Sprintf("http://%s", mEndpointVar)
56-
params["secure"] = false
56+
mEndpoint := env.Get(minioEndpointVar)
57+
params["regionendpoint"] = mEndpoint
58+
region := "us-east-1" //region is required in distribution
59+
if endpointURL, err := url.Parse(mEndpoint); err == nil {
60+
if endpointURL.Hostname() != "" && net.ParseIP(endpointURL.Hostname()) == nil {
61+
region = strings.Split(endpointURL.Hostname(), ".")[0]
62+
}
63+
}
64+
os.Setenv("REGISTRY_STORAGE_S3_REGION", region)
65+
5766
return params, nil
5867
}

pkg/conf/config_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func TestGetStorageParams(t *testing.T) {
6969
env := sys.NewFakeEnv()
7070
env.Envs = map[string]string{
7171
"BUILDER_STORAGE": "minio",
72-
"DRYCC_MINIO_ENDPOINT": "localhost:8088",
72+
"DRYCC_MINIO_ENDPOINT": "http://localhost:8088",
7373
}
7474
params, err = GetStorageParams(env)
7575
if err != nil {

rootfs/bin/normalize_storage

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ if [ -f $SECRET_KEY_FILE ]; then
1616
export MINIO_SECRET_KEY
1717
fi
1818

19-
export MINIO_ENDPOINT=http://"${DRYCC_MINIO_ENDPOINT}"
19+
export MINIO_ENDPOINT="${DRYCC_MINIO_ENDPOINT}"
2020

21-
mc config host add minio "${MINIO_ENDPOINT}" "${MINIO_ACCESS_KEY}" "${MINIO_SECRET_KEY}"
21+
# force aws signv4 to avoid probe
22+
mc config host add minio "${MINIO_ENDPOINT}" "${MINIO_ACCESS_KEY}" "${MINIO_SECRET_KEY}" --api s3v4

0 commit comments

Comments
 (0)