Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions pkg/jobs/launcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ type LauncherWorker struct {
ResourceSpec *api.ContainerResources
AttributeSpec *api.ContainerSpec

// If we ask for sole tenancy, we assign 1 pod / hostname
SoleTenancy bool

// Scripts
WorkerScript string
LauncherScript string
Expand Down Expand Up @@ -170,12 +173,12 @@ func (m *LauncherWorker) ReplicatedJobs(spec *api.MetricSet) ([]jobset.Replicate
m.ensureDefaultNames()

// Generate a replicated job for the launcher (LauncherWorker) and workers
launcher, err := metrics.GetReplicatedJob(spec, false, 1, 1, m.LauncherLetter, false)
launcher, err := metrics.GetReplicatedJob(spec, false, 1, 1, m.LauncherLetter, m.SoleTenancy)
if err != nil {
return js, err
}

workers, err := metrics.GetReplicatedJob(spec, false, spec.Spec.Pods-1, spec.Spec.Pods-1, m.WorkerLetter, false)
workers, err := metrics.GetReplicatedJob(spec, false, spec.Spec.Pods-1, spec.Spec.Pods-1, m.WorkerLetter, m.SoleTenancy)
if err != nil {
return js, err
}
Expand Down
30 changes: 6 additions & 24 deletions pkg/metrics/jobset.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,16 @@ func GetReplicatedJob(
},
}

// Do we want to assign 1 node: 1 pod? We can use Pod Anti-affinity for that
// Add sole tenancy if desired (note this is not enabled for anything yet)
// as there is some bug with the selector, and I want to clarify how this works
if soleTenancy {
jobspec.Template.Spec.Affinity = getSoleTenancyAffinity()
jobspec.Template.Spec.Affinity = &corev1.Affinity{}
jobspec.Template.Spec.Affinity.PodAntiAffinity = getSoleTenancyAffinity()
jobspec.Selector = &metav1.LabelSelector{
MatchExpressions: []metav1.LabelSelectorRequirement{},
}
jobspec.Selector.MatchLabels = map[string]string{tenancyLabel: soleTenancyValue}
// jobspec.Template.Spec.TopologySpreadConstraints = getSoleTenancyConstraint()
}

// Do we have a pull secret for the application image?
Expand All @@ -209,22 +210,8 @@ func GetReplicatedJob(
return &job, nil
}

// getSoleTenancyConstraint determines spread based on hostname (not currently used)
func getSoleTenancyConstraint() []corev1.TopologySpreadConstraint {
return []corev1.TopologySpreadConstraint{
{
MaxSkew: 1,
TopologyKey: "kubernetes.io/hostname",
WhenUnsatisfiable: corev1.DoNotSchedule,
LabelSelector: &metav1.LabelSelector{
MatchLabels: map[string]string{tenancyLabel: soleTenancyValue},
},
},
}
}

// getSoleTenancyAffinity ensures one pod per node based on hostname
func getSoleTenancyAffinity() *corev1.Affinity {
func getSoleTenancyAffinity() *corev1.PodAntiAffinity {
terms := []corev1.PodAffinityTerm{
{
TopologyKey: "kubernetes.io/hostname",
Expand All @@ -233,12 +220,7 @@ func getSoleTenancyAffinity() *corev1.Affinity {
},
},
}
return &corev1.Affinity{
PodAntiAffinity: &corev1.PodAntiAffinity{
RequiredDuringSchedulingIgnoredDuringExecution: terms,
},
PodAffinity: &corev1.PodAffinity{
RequiredDuringSchedulingIgnoredDuringExecution: terms,
},
return &corev1.PodAntiAffinity{
RequiredDuringSchedulingIgnoredDuringExecution: terms,
}
}
3 changes: 3 additions & 0 deletions pkg/metrics/network/netmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ func (m *Netmark) SetOptions(metric *api.Metric) {
m.AttributeSpec = &metric.Attributes
m.LauncherLetter = "n"

// One pod per hostname
m.SoleTenancy = true

// Set user defined values or fall back to defaults
// If we have tasks defined, use it! Otherwise fall back to 2 (likely demo)
m.tasks = 0
Expand Down
3 changes: 3 additions & 0 deletions pkg/metrics/network/osu-benchmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ func (m *OSUBenchmark) SetOptions(metric *api.Metric) {
m.ResourceSpec = &metric.Resources
m.AttributeSpec = &metric.Attributes

// One pod per hostname
m.SoleTenancy = true

// We are allowed to specify just one command
opts, ok := metric.ListOptions["commands"]
if ok {
Expand Down