Skip to content

Commit

Permalink
refactor delayed scheduling
Browse files Browse the repository at this point in the history
  • Loading branch information
hellt committed Aug 24, 2021
1 parent ce1fe7e commit c2051c4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
14 changes: 8 additions & 6 deletions clab/clab.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ func (c *CLab) createNodes(ctx context.Context, maxWorkers int,
log.Errorf("failed deploy phase for node %q: %v", node.Config().ShortName, err)
continue
}

node.Config().DeploymentStatus = "created"
case <-ctx.Done():
return
}
Expand Down Expand Up @@ -290,18 +292,18 @@ func (c *CLab) CreateLinks(ctx context.Context, workers uint, postdeploy bool) {
}(i)
}

workingLinks := map[int]*types.Link{}
linksCopy := map[int]*types.Link{}
for k, v := range c.Links {
workingLinks[k] = v
linksCopy[k] = v
}
for {
if len(workingLinks) == 0 {
if len(linksCopy) == 0 {
break
}
for k, link := range workingLinks {
if link.A.Node.NSPath != "" && link.B.Node.NSPath != "" {
for k, link := range linksCopy {
if link.A.Node.DeploymentStatus == "created" && link.B.Node.DeploymentStatus == "created" {
linksChan <- link
delete(workingLinks, k)
delete(linksCopy, k)
}
}
}
Expand Down
1 change: 0 additions & 1 deletion types/node_definition.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ type NodeDefinition struct {
License string `yaml:"license,omitempty"`
Position string `yaml:"position,omitempty"`
Cmd string `yaml:"cmd,omitempty"`

// list of bind mount compatible strings
Binds []string `yaml:"binds,omitempty"`
// list of port bindings
Expand Down
3 changes: 2 additions & 1 deletion types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ type NodeConfig struct {
// Configured container runtime
Runtime string
// Resource requirements
CPU, RAM string
CPU, RAM string
DeploymentStatus string // status that is set by containerlab to indicate deployment stage
}

// GenerateConfig generates configuration for the nodes
Expand Down

0 comments on commit c2051c4

Please sign in to comment.