Skip to content
This repository was archived by the owner on Dec 30, 2020. It is now read-only.

Commit 6ad0fef

Browse files
author
Sasha Yakovtseva
authored
Merge pull request #117 from sylabs/staging
Set up staging environment
2 parents 9dfef1a + 4412559 commit 6ad0fef

File tree

4 files changed

+27
-18
lines changed

4 files changed

+27
-18
lines changed

.circleci/config.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,17 @@ jobs:
106106
- run:
107107
name: Publish images
108108
command: |
109+
TAG=latest
110+
if [ "${CIRCLE_BRANCH}" != "master" ]
111+
then
112+
TAG=${CIRCLE_BRANCH}
113+
fi
114+
109115
cd $GOPATH/src/github.com/sylabs/slurm-operator
110116
cat > push.sh <<EOF
111117
#!/usr/bin/expect -f
112118
set timeout -1
113-
spawn make push
119+
spawn make push TAG=${TAG}
114120
expect "Enter key passphrase : "
115121
send -- "\r"
116122
expect "Enter key passphrase : "
@@ -141,6 +147,7 @@ workflows:
141147
branches:
142148
only:
143149
- master
150+
- staging
144151
requires:
145152
- build
146153
- test

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,13 @@ lint:
3434
--deadline=3m ./...
3535

3636
.PHONY: push
37+
push: TAG=latest
3738
push:
3839
$(V)for f in `ls sif` ; do \
39-
echo " PUSH" $${f} ; \
40+
echo " PUSH" $${f}:${TAG} ; \
4041
sudo singularity build sif/$${f}.sif sif/$${f} ;\
4142
singularity sign sif/$${f}.sif;\
42-
singularity push sif/$${f}.sif library://library/slurm/$${f}:latest;\
43+
singularity push sif/$${f}.sif library://library/slurm/$${f}:${TAG};\
4344
done
4445

4546
.PHONY: dep

cmd/operator/main.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ var (
3939
metricsPort int32 = 8383
4040
)
4141

42+
const defaultJobCompanionImage = "cloud.sylabs.io/library/slurm/job-companion:latest"
43+
4244
func printVersion() {
4345
glog.Infof("Go Version: %s", runtime.Version())
4446
glog.Infof("Go OS/Arch: %s/%s", runtime.GOOS, runtime.GOARCH)
@@ -50,6 +52,7 @@ func main() {
5052
_ = flag.Set("logtostderr", "true")
5153
jcUID := flag.Int64("jc-uid", 1000, "uid to be used for running job-companion containers")
5254
jcGID := flag.Int64("jc-gid", 1000, "gid to be used for running job-companion containers")
55+
jcImage := flag.String("jc-image", defaultJobCompanionImage, "custom job companion image to use")
5356
flag.Parse()
5457
defer glog.Flush()
5558

@@ -90,8 +93,7 @@ func main() {
9093
glog.Fatalf("Failed to add manager to apis scheme: %v", err)
9194
}
9295

93-
// Setup SlurmJob controller
94-
sj := slurmjob.NewReconciler(mgr, *jcUID, *jcGID)
96+
sj := slurmjob.NewReconciler(mgr, *jcImage, *jcUID, *jcGID)
9597
if err := sj.AddToManager(mgr); err != nil {
9698
glog.Fatalf("Failed to add controller to manager: %v", err)
9799
}

pkg/operator/controller/slurmjob/slurmjob_controller.go

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,29 +35,28 @@ import (
3535
"sigs.k8s.io/controller-runtime/pkg/source"
3636
)
3737

38-
const (
39-
jobCompanionImage = "cloud.sylabs.io/library/slurm/job-companion:latest"
40-
)
41-
4238
// Reconciler reconciles a SlurmJob object
4339
type Reconciler struct {
4440
// This client, initialized using mgr.Client() above, is a split client
4541
// that reads objects from the cache and writes to the apiserver
46-
client client.Client
47-
scheme *runtime.Scheme
42+
client client.Client
43+
scheme *runtime.Scheme
44+
jcImage string
4845

4946
jcUID int64
5047
jcGID int64
5148
}
5249

5350
// NewReconciler returns a new SlurmJob controller.
54-
func NewReconciler(mgr manager.Manager, jcUID, jcGID int64) *Reconciler {
55-
return &Reconciler{
56-
client: mgr.GetClient(),
57-
scheme: mgr.GetScheme(),
58-
jcUID: jcUID,
59-
jcGID: jcGID,
51+
func NewReconciler(mgr manager.Manager, jcImage string, jcUID, jcGID int64) *Reconciler {
52+
r := &Reconciler{
53+
client: mgr.GetClient(),
54+
scheme: mgr.GetScheme(),
55+
jcUID: jcUID,
56+
jcGID: jcGID,
57+
jcImage: jcImage,
6058
}
59+
return r
6160
}
6261

6362
// AddToManager adds SlurmJob Reconciler to the given Manager.
@@ -197,7 +196,7 @@ func (r *Reconciler) newPodForSJ(sj *slurmv1alpha1.SlurmJob) *corev1.Pod {
197196
Containers: []corev1.Container{
198197
{
199198
Name: "jt1",
200-
Image: jobCompanionImage,
199+
Image: r.jcImage,
201200
ImagePullPolicy: corev1.PullIfNotPresent,
202201
Args: args,
203202
Resources: corev1.ResourceRequirements{

0 commit comments

Comments
 (0)