Skip to content

Commit

Permalink
Fix multiple requisites
Browse files Browse the repository at this point in the history
  • Loading branch information
kvaps committed Apr 27, 2023
1 parent 8c8ead5 commit c24ebd0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 21 deletions.
15 changes: 2 additions & 13 deletions pkg/linstor/highlevelclient/high_level_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"github.com/container-storage-interface/spec/lib/go/csi"

"github.com/piraeusdatastore/linstor-csi/pkg/linstor/util"
"github.com/piraeusdatastore/linstor-csi/pkg/slice"
"github.com/piraeusdatastore/linstor-csi/pkg/topology"
"github.com/piraeusdatastore/linstor-csi/pkg/volume"
)
Expand Down Expand Up @@ -104,18 +103,8 @@ func (c *HighLevelClient) GetAllTopologyNodes(ctx context.Context, remoteAccessP
accessibleSegments = []map[string]string{{}}
}

var allNodes []string

for _, segment := range accessibleSegments {
nodes, err := c.NodesForTopology(ctx, segment)
if err != nil {
return nil, err
}

allNodes = slice.AppendUnique(allNodes, nodes...)
}

return allNodes, nil
// schedulded node of the pod is the first entry in the accessible segment
return c.NodesForTopology(ctx, accessibleSegments[0])
}

// NodesForTopology finds all matching nodes for the given topology segment.
Expand Down
15 changes: 7 additions & 8 deletions pkg/topology/scheduler/autoplacetopology/autoplacetopology.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,13 @@ func (s *Scheduler) Create(ctx context.Context, volId string, params *volume.Par
// Step 2: Try to place a replica on any preferred segment
log.WithField("requirements", topologies).Trace("got topology requirement")

for _, preferred := range topologies.GetPreferred() {
err := s.PlaceOneAccessibleToSegment(ctx, volId, preferred.GetSegments(), params.AllowRemoteVolumeAccess, diskfulNodes)
if err != nil {
log.WithError(err).Debug("failed to place on preferred segment")
} else {
log.Debug("placed accessible to preferred segment")
break
}
// schedulded node of the pod is the first entry in the preferred segment
preferred := topologies.GetPreferred()[0]
err = s.PlaceOneAccessibleToSegment(ctx, volId, preferred.GetSegments(), params.AllowRemoteVolumeAccess, diskfulNodes)
if err != nil {
log.WithError(err).Debug("failed to place on preferred segment")
} else {
log.Debug("placed accessible to preferred segment")
}

// Step 2a: bail early if resource already matches replica count and requisite nodes
Expand Down

0 comments on commit c24ebd0

Please sign in to comment.