Skip to content

Commit

Permalink
new directory structure for slurm sidecar
Browse files Browse the repository at this point in the history
  • Loading branch information
ttedeschi committed Oct 31, 2023
1 parent 90d949d commit 6083a48
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions pkg/sidecars/slurm/aux.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,17 @@ func prepare_mounts(container v1.Container, data []commonIL.RetrievedPodData) ([

func produce_slurm_script(podUID string, metadata metav1.ObjectMeta, commands []SingularityCommand) (string, error) {
log.G(Ctx).Info("-- Creating file for the Slurm script")
path := commonIL.InterLinkConfigInst.DataRootFolder + podUID + ".sh"
err := os.MkdirAll(commonIL.InterLinkConfigInst.DataRootFolder+podUID, os.ModePerm)
if err != nil {
log.G(Ctx).Error(err)
return "", err
} else {
log.G(Ctx).Info("-- Created directory " + commonIL.InterLinkConfigInst.DataRootFolder + podUID)
}
path := commonIL.InterLinkConfigInst.DataRootFolder + podUID + "/job.sh"
postfix := ""

err := os.RemoveAll(path)
err = os.RemoveAll(path)
if err != nil {
log.G(Ctx).Error(err)
return "", err
Expand Down Expand Up @@ -280,7 +287,7 @@ func slurm_batch_submit(path string) (string, error) {
func handle_jid(podUID string, output string, pod v1.Pod) error {
r := regexp.MustCompile(`Submitted batch job (?P<jid>\d+)`)
jid := r.FindStringSubmatch(output)
f, err := os.Create(commonIL.InterLinkConfigInst.DataRootFolder + podUID + ".jid")
f, err := os.Create(commonIL.InterLinkConfigInst.DataRootFolder + podUID + "/JobID.jid")
if err != nil {
log.G(Ctx).Error("Can't create jid_file")
return err
Expand Down Expand Up @@ -324,9 +331,7 @@ func delete_container(podUID string) error {
} else {
log.G(Ctx).Info("- Deleted Job ", jid.JID)
}
os.RemoveAll(commonIL.InterLinkConfigInst.DataRootFolder + podUID + ".out")
os.RemoveAll(commonIL.InterLinkConfigInst.DataRootFolder + podUID + ".err")
os.RemoveAll(commonIL.InterLinkConfigInst.DataRootFolder + podUID + ".status")
os.RemoveAll(commonIL.InterLinkConfigInst.DataRootFolder + podUID)
removeJID(jid.JID)
return nil
}
Expand Down

0 comments on commit 6083a48

Please sign in to comment.