Merge pull request #2694 from chrisghill/issue/2693
Fix orphaned /tmp/drone directories in kubernetes
This commit is contained in:
commit
4ad252ee6a
1 changed files with 23 additions and 0 deletions
|
@ -10,6 +10,7 @@ import (
|
|||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
@ -104,6 +105,26 @@ func (s *kubeScheduler) Schedule(ctx context.Context, stage *core.Stage) error {
|
|||
rand := strings.ToLower(uniuri.NewLen(12))
|
||||
name := fmt.Sprintf("drone-job-%d-%s", stage.ID, rand)
|
||||
|
||||
var mounts []v1.VolumeMount
|
||||
mount := v1.VolumeMount{
|
||||
Name: name + "-local",
|
||||
MountPath: filepath.Join("/tmp", "drone"),
|
||||
}
|
||||
mounts = append(mounts, mount)
|
||||
|
||||
var volumes []v1.Volume
|
||||
source := v1.HostPathDirectoryOrCreate
|
||||
volume := v1.Volume{
|
||||
Name: name + "-local",
|
||||
VolumeSource: v1.VolumeSource{
|
||||
HostPath: &v1.HostPathVolumeSource{
|
||||
Path: filepath.Join("/tmp", "drone"),
|
||||
Type: &source,
|
||||
},
|
||||
},
|
||||
}
|
||||
volumes = append(volumes, volume)
|
||||
|
||||
job := &batchv1.Job{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
GenerateName: name,
|
||||
|
@ -131,7 +152,9 @@ func (s *kubeScheduler) Schedule(ctx context.Context, stage *core.Stage) error {
|
|||
Image: internal.DefaultImage(s.config.Image),
|
||||
ImagePullPolicy: pull,
|
||||
Env: env,
|
||||
VolumeMounts: mounts,
|
||||
}},
|
||||
Volumes: volumes,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue