Skip to content

Commit

Permalink
satellite/nodeselection: introduce Name for Placements
Browse files Browse the repository at this point in the history
This human readable name can be used in UI instead of the int identifier.

Same as the legacy 'Location' annotation, but we don't need annotations any more.

Change-Id: I0060a1a836e08e99b57c700fe165829650c2c044
  • Loading branch information
elek authored and Storj Robot committed Jan 10, 2024
1 parent b41cf66 commit 17a1628
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions satellite/nodeselection/placement.go
Expand Up @@ -21,6 +21,8 @@ import (
type Placement struct {
// the unique ID of the placement
ID storj.PlacementConstraint
// meaningful identifier/label for Humans. Will be used on UI.
Name string
// binding condition for filtering out nodes
NodeFilter NodeFilter
// selector is the method how the nodes are selected from the full node space (eg. pick a subnet first, and pick a node from the subnet)
Expand All @@ -35,7 +37,11 @@ func (p Placement) Match(node *SelectedNode) bool {
}

// GetAnnotation implements NodeFilterWithAnnotation.
// Deprecated: use Name instead.
func (p Placement) GetAnnotation(name string) string {
if name == Location && p.Name != "" {
return p.Name
}
switch filter := p.NodeFilter.(type) {
case NodeFilterWithAnnotation:
return filter.GetAnnotation(name)
Expand Down Expand Up @@ -301,6 +307,8 @@ func (d PlacementDefinitions) AddPlacementFromString(definitions string) error {
placement.Selector = RandomSelector()
}

placement.Name = GetAnnotation(placement.NodeFilter, Location)

d[storj.PlacementConstraint(id)] = placement
}
return nil
Expand Down

0 comments on commit 17a1628

Please sign in to comment.