Skip to content

Commit

Permalink
improvement taskrun uuid
Browse files Browse the repository at this point in the history
  • Loading branch information
shaowenchen committed Nov 25, 2024
1 parent 5bc34b6 commit 6c8eda4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
3 changes: 3 additions & 0 deletions controllers/taskrun_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"time"

"github.com/google/go-cmp/cmp"
"github.com/google/uuid"
cron "github.com/robfig/cron/v3"
opsv1 "github.com/shaowenchen/ops/api/v1"
opsconstants "github.com/shaowenchen/ops/pkg/constants"
Expand Down Expand Up @@ -248,6 +249,7 @@ func (r *TaskRunReconciler) runTaskOnHost(logger *opslog.Logger, ctx context.Con
vars["HOSTNAME"] = h.GetHostname()
vars["OPSSERVER_ENDPOINT"] = r.getEventBusNodePortAddress(t.Namespace)
vars["EVENT_CLUSTER"] = opsconstants.GetEnvEventCluster()
vars["UUID"] = uuid.New().String()

// insert host labels
for k, v := range h.ObjectMeta.Labels {
Expand Down Expand Up @@ -318,6 +320,7 @@ func (r *TaskRunReconciler) runTaskOnKube(logger *opslog.Logger, ctx context.Con
vars["OPSSERVER_ENDPOINT"] = r.getEventBusNodePortAddress(t.Namespace)
vars["TASK"] = t.Name
vars["TASKRUN"] = tr.Name
vars["UUID"] = uuid.New().String()
opstask.RunTaskOnKube(logger, t, tr, kc, &node,
opsoption.TaskOption{
Variables: vars,
Expand Down
14 changes: 7 additions & 7 deletions tasks/collect-gpu-log.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ spec:
steps:
- name: run col_gpu_log.sh
content: |
rm -rf /tmp/col-gpu-log-${random} || true
mkdir -p /tmp/col-gpu-log-${random} && cd /tmp/col-gpu-log-${random}
rm -rf /tmp/col-gpu-log-${UUID} || true
mkdir -p /tmp/col-gpu-log-${UUID} && cd /tmp/col-gpu-log-${UUID}
curl -sfL https://ghp.ci/https://raw.githubusercontent.com/shaowenchen/hubimage/main/ai/col_gpu_log.sh | bash
mv *.tar.gz ${HOSTNAME}-col-gpu-log-${random}.tar.gz
mv *.tar.gz ${HOSTNAME}-col-gpu-log-${UUID}.tar.gz
- name: upload to s3
remotefile: s3://collect-gpu-log/${HOSTNAME}-col-gpu-log-${random}.tar.gz
localfile: /tmp/col-gpu-log-${random}/${HOSTNAME}-col-gpu-log-${random}.tar.gz
remotefile: s3://collect-gpu-log/${HOSTNAME}-col-gpu-log-${UUID}.tar.gz
localfile: /tmp/col-gpu-log-${UUID}/${HOSTNAME}-col-gpu-log-${UUID}.tar.gz
direction: upload
- name: get 2h shared link
content: |
curl -sfL https://ks3util-version-update.ks3-cn-beijing.ksyuncs.com/2.6.0/ks3util-linux-amd64 -o /usr/local/bin/ks3util >/dev/null
chmod +x /usr/local/bin/ks3util
/usr/local/bin/ks3util sign ks3://${bucket}/collect-gpu-log/${HOSTNAME}-col-gpu-log-${random}.tar.gz --endpoint ${endpoint} --timeout 7200 -i ${ak} -k ${sk}
/usr/local/bin/ks3util sign ks3://${bucket}/collect-gpu-log/${HOSTNAME}-col-gpu-log-${UUID}.tar.gz --endpoint ${endpoint} --timeout 7200 -i ${ak} -k ${sk}
- name: clean
content: |
rm -rf /tmp/col-gpu-log-${random} || true
rm -rf /tmp/col-gpu-log-${UUID} || true

0 comments on commit 6c8eda4

Please sign in to comment.