Skip to content

Commit

Permalink
fix secret-key for authfs (#757)
Browse files Browse the repository at this point in the history
Signed-off-by: zwwhdls <[email protected]>
  • Loading branch information
zwwhdls authored Sep 27, 2023
1 parent 61326e1 commit 290a68c
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 19 deletions.
1 change: 1 addition & 0 deletions .github/scripts/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
TOKEN = os.getenv("JUICEFS_TOKEN") or ""
JUICEFS_MODE = os.getenv("JUICEFS_MODE")
IS_CE = os.getenv("JUICEFS_MODE") == "ce"
Beta = os.getenv("JFSCHAN") == "beta"
MOUNT_MODE = "pod" if "pod" in os.getenv("TEST_MODE") else (
"process" if "process" in os.getenv("TEST_MODE") else "webhook")
RESOURCE_PREFIX = "{}-{}-".format(MOUNT_MODE, JUICEFS_MODE)
Expand Down
24 changes: 17 additions & 7 deletions .github/scripts/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,25 @@ def mount_on_host(mount_path):
LOG.info(f"Mount {mount_path}")
try:
if IS_CE:
subprocess.check_call(
subprocess.run(
["sudo", "/usr/local/bin/juicefs", "format", f"--storage={STORAGE}", f"--access-key={ACCESS_KEY}",
f"--secret-key={SECRET_KEY}", f"--bucket={BUCKET}", META_URL, SECRET_NAME])
subprocess.check_call(["sudo", "/usr/local/bin/juicefs", "mount", "-d", META_URL, mount_path])
f"--secret-key={SECRET_KEY}", f"--bucket={BUCKET}", META_URL, SECRET_NAME],
check=True
)
subprocess.run(
["sudo", "/usr/local/bin/juicefs", "mount", "-d", META_URL, mount_path],
check=True
)
else:
subprocess.check_call(
["sudo", "/usr/bin/juicefs", "auth", f"--token={TOKEN}", f"--accesskey={ACCESS_KEY}",
f"--secretkey={SECRET_KEY}", f"--bucket={BUCKET}", SECRET_NAME])
subprocess.check_call(["sudo", "/usr/bin/juicefs", "mount", "-d", SECRET_NAME, mount_path])
subprocess.run(
["sudo", "/usr/bin/juicefs", "auth", f"--token={TOKEN}", f"--access-key={ACCESS_KEY}",
f"--secret-key={SECRET_KEY}", f"--bucket={BUCKET}", SECRET_NAME],
check=True
)
subprocess.run(
["sudo", "/usr/bin/juicefs", "mount", "-d", SECRET_NAME, mount_path],
check=True
)
LOG.info("Mount success.")
except Exception as e:
LOG.info("Error in juicefs mount: {}".format(e))
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/release_check_ee.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ jobs:
make -C docker image-release-check
make -C docker image-release-check-push
- name: Deploy JuiceFS CSI
env:
JFSCHAN: beta
run: |
testmode=${{matrix.testmode}}
cd ${GITHUB_WORKSPACE}
Expand All @@ -57,6 +59,7 @@ jobs:
.github/scripts/deploy-csi-in-k8s.sh ${testmode}
- name: Run e2e test
env:
JFSCHAN: beta
JUICEFS_TOKEN: ${{ secrets.JUICEFS_CI_VOLUME_TOKEN }}
JUICEFS_STORAGE: s3
JUICEFS_BUCKET: "http://juicefs-bucket.minio.default.svc.cluster.local:9000"
Expand Down
3 changes: 2 additions & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ RUN apt update && apt install -y software-properties-common wget gnupg gnupg2 &&

RUN apt-get update && apt-get install -y librados2 librados-dev libcephfs-dev librbd-dev curl fuse procps iputils-ping strace iproute2 net-tools tcpdump lsof && \
rm -rf /var/cache/apt/* && \
curl -sSL https://juicefs.com/static/juicefs -o ${JUICEFS_CLI} && chmod +x ${JUICEFS_CLI} && \
bash -c "if [[ ${JFSCHAN} == beta ]]; then curl -sSL https://juicefs.com/static/juicefs.py.beta -o ${JUICEFS_CLI}; else curl -sSL https://juicefs.com/static/juicefs -o ${JUICEFS_CLI}; fi; " && \
chmod +x ${JUICEFS_CLI} && \
mkdir -p /root/.juicefs && \
ln -s /usr/local/bin/python /usr/bin/python && \
mkdir /root/.acl && cp /etc/passwd /root/.acl/passwd && cp /etc/group /root/.acl/group && \
Expand Down
3 changes: 2 additions & 1 deletion docker/ee.juicefs.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ RUN apt update && apt install -y software-properties-common wget gnupg gnupg2 &&

RUN apt-get update && apt-get install -y librados2 curl fuse procps iputils-ping strace iproute2 net-tools tcpdump lsof librados-dev libcephfs-dev librbd-dev && \
rm -rf /var/cache/apt/* && \
curl -sSL https://juicefs.com/static/juicefs -o ${JUICEFS_CLI} && chmod +x ${JUICEFS_CLI} && \
bash -c "if [[ ${JFSCHAN} == beta ]]; then curl -sSL https://juicefs.com/static/juicefs.py.beta -o ${JUICEFS_CLI}; else curl -sSL https://juicefs.com/static/juicefs -o ${JUICEFS_CLI}; fi; " && \
chmod +x ${JUICEFS_CLI} && \
mkdir -p /root/.juicefs && \
ln -s /usr/local/bin/python /usr/bin/python && \
mkdir /root/.acl && cp /etc/passwd /root/.acl/passwd && cp /etc/group /root/.acl/group && \
Expand Down
29 changes: 19 additions & 10 deletions pkg/juicefs/juicefs.go
Original file line number Diff line number Diff line change
Expand Up @@ -673,10 +673,10 @@ func (j *juicefs) AuthFs(ctx context.Context, secrets map[string]string, setting
cmdArgs := []string{config.CliPath, "auth", secrets["name"]}

keysCompatible := map[string]string{
"access-key": "accesskey",
"access-key2": "accesskey2",
"secret-key": "secretkey",
"secret-key2": "secretkey2",
"accesskey": "access-key",
"accesskey2": "access-key2",
"secretkey": "secret-key",
"secretkey2": "secret-key2",
}
// compatible
for compatibleKey, realKey := range keysCompatible {
Expand All @@ -688,17 +688,22 @@ func (j *juicefs) AuthFs(ctx context.Context, secrets map[string]string, setting
}

keys := []string{
"accesskey",
"accesskey2",
"access-key",
"access-key2",
"bucket",
"bucket2",
"subdir",
}
keysStripped := []string{
"token",
"secretkey",
"secretkey2",
"passphrase"}
"secret-key",
"secret-key2",
"passphrase",
}
strippedkey := map[string]string{
"secret-key": "secretkey",
"secret-key2": "secretkey2",
}
for _, k := range keys {
if secrets[k] != "" {
cmdArgs = append(cmdArgs, fmt.Sprintf("--%s=%s", k, secrets[k]))
Expand All @@ -707,7 +712,11 @@ func (j *juicefs) AuthFs(ctx context.Context, secrets map[string]string, setting
}
for _, k := range keysStripped {
if secrets[k] != "" {
cmdArgs = append(cmdArgs, fmt.Sprintf("--%s=${%s}", k, k))
argKey := k
if v, ok := strippedkey[k]; ok {
argKey = v
}
cmdArgs = append(cmdArgs, fmt.Sprintf("--%s=${%s}", k, argKey))
args = append(args, fmt.Sprintf("--%s=%s", k, secrets[k]))
}
}
Expand Down

0 comments on commit 290a68c

Please sign in to comment.