Skip to content

Commit

Permalink
use python3 to execute upgrade scripts (#408)
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-sun-star authored May 28, 2024
1 parent 4b48ffc commit 833226e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions build/Dockerfile.observer
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ ARG TARGETPLATFORM
WORKDIR /home/admin/oceanbase
RUN mkdir -p /home/admin/oceanbase/bin
COPY --from=builder /workspace/oceanbase-helper /home/admin/oceanbase/bin
RUN yum -y install python27
RUN pip2 install mysql-connector -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
RUN yum -y install python3
RUN ln -sf /usr/bin/python3 /usr/bin/python
RUN pip3 install mysql-connector-python==8.0.28 -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
# support docker platform linux/amd64 and linux/arm64, mapping platform to x86_64 or aarch64
RUN if [[ ${TARGETPLATFORM} == 'linux/amd64' ]] ; then yum install -y http://mirrors.aliyun.com/oceanbase/community/stable/el/8/x86_64/oceanbase-ce-libs-${VERSION}.el8.x86_64.rpm ; else yum install -y http://mirrors.aliyun.com/oceanbase/community/stable/el/8/aarch64/oceanbase-ce-libs-${VERSION}.el8.aarch64.rpm ; fi
RUN if [[ ${TARGETPLATFORM} == 'linux/amd64' ]] ; then yum install -y http://mirrors.aliyun.com/oceanbase/community/stable/el/8/x86_64/oceanbase-ce-${VERSION}.el8.x86_64.rpm ; else yum install -y http://mirrors.aliyun.com/oceanbase/community/stable/el/8/aarch64/oceanbase-ce-${VERSION}.el8.aarch64.rpm ; fi
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
ENV LD_LIBRARY_PATH /home/admin/oceanbase/lib
ENV LD_LIBRARY_PATH /home/admin/oceanbase/lib
4 changes: 2 additions & 2 deletions build/Dockerfile.operator
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM golang:1.20.4 as builder
FROM golang:1.22 as builder

ARG GOPROXY
ARG GOSUMDB
Expand All @@ -8,7 +8,7 @@ ARG RACE
WORKDIR /workspace
# copy everything
COPY . .
RUN GO11MODULE=ON CGO_ENABLED=1 GOOS=linux go build ${RACE} -o manager cmd/operator/main.go
RUN GO11MODULE=ON CGO_ENABLED=0 GOOS=linux go build ${RACE} -o manager cmd/operator/main.go

# start build docker image
FROM openanolis/anolisos:8.8
Expand Down
2 changes: 1 addition & 1 deletion internal/resource/utils/jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func ExecuteUpgradeScript(ctx context.Context, c client.Client, logger *logr.Log
container := corev1.Container{
Name: "script-runner",
Image: obcluster.Spec.OBServerTemplate.Image,
Command: []string{"bash", "-c", fmt.Sprintf("python2 %s -h%s -P%d -uroot -p'%s' %s", filepath, rootserver.Ip, rootserver.SqlPort, password, extraOpt)},
Command: []string{"bash", "-c", fmt.Sprintf("if [[ `command -v python2` ]]; then ln -sf /usr/bin/python2 /usr/bin/python; fi && python %s -h%s -P%d -uroot -p'%s' %s", filepath, rootserver.Ip, rootserver.SqlPort, password, extraOpt)},
}
job := batchv1.Job{
ObjectMeta: metav1.ObjectMeta{
Expand Down

0 comments on commit 833226e

Please sign in to comment.