Files
nomad/scheduler/structs/structs.go
Piotr Kazmierczak 199d12865f scheduler: isolate feasibility (#26031)
This change isolates all the code that deals with node selection in the
scheduler into its own package called feasible.
---------

Co-authored-by: Tim Gross <tgross@hashicorp.com>
2025-06-11 20:11:04 +02:00

54 lines
1.2 KiB
Go

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1
package structs
import "github.com/hashicorp/nomad/nomad/structs"
// PortCollisionEvent is an event that can happen during scheduling when
// an unexpected port collision is detected.
type PortCollisionEvent struct {
Reason string
Node *structs.Node
Allocations []*structs.Allocation
// TODO: this is a large struct, but may be required to debug unexpected
// port collisions. Re-evaluate its need in the future if the bug is fixed
// or not caused by this field.
NetIndex *structs.NetworkIndex
}
func (ev *PortCollisionEvent) Copy() *PortCollisionEvent {
if ev == nil {
return nil
}
c := new(PortCollisionEvent)
*c = *ev
c.Node = ev.Node.Copy()
if len(ev.Allocations) > 0 {
for i, a := range ev.Allocations {
c.Allocations[i] = a.Copy()
}
}
c.NetIndex = ev.NetIndex.Copy()
return c
}
func (ev *PortCollisionEvent) Sanitize() *PortCollisionEvent {
if ev == nil {
return nil
}
clean := ev.Copy()
clean.Node = ev.Node.Sanitize()
clean.Node.Meta = make(map[string]string)
for i, alloc := range ev.Allocations {
clean.Allocations[i] = alloc.CopySkipJob()
clean.Allocations[i].Job = nil
}
return clean
}