Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixing #456 #458

Merged
merged 3 commits into from
Jun 17, 2021
Merged

fixing #456 #458

merged 3 commits into from
Jun 17, 2021

Conversation

steiler
Copy link
Collaborator

@steiler steiler commented Jun 17, 2021

The filter caused the default bridge to be excluded from the network listing.
Hence the container IP wasn't found.
I'm not sure why the filter was introduced in #433 for issue #432. Topology mentioned in #456 works fine. #433 has no topo attached to test.

@steiler steiler requested a review from karimra June 17, 2021 10:57
@hellt
Copy link
Member

hellt commented Jun 17, 2021

I believe the idea was to get the list of networks that containerlab created. hence the filter that has containerlab
but since bridge network is not the one that is created by containerlab, it was missing

@@ -360,14 +360,10 @@ func (c *DockerRuntime) ListContainers(ctx context.Context, gfilters []*types.Ge
}
var nr []dockerTypes.NetworkResource
if c.Mgmt.Network == "" {
netFilter := filters.NewArgs()
netFilter.Add("label", "containerlab")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we can create a filter that will capture both networks that have a containerlab label OR network which have bridge name

That way we will avoid getting the networks that could be created by users/other_systems and which are not needed for our purposes.

It is potentially an optimization, which is not necessary, but seems like nice to have.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be an AND operation if you add name=bridge
To do an OR, 2 queries need to be performed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, here is what I did

	if c.Mgmt.Network == "" {
		nctx, cancel := context.WithTimeout(ctx, c.timeout)
		defer cancel()
		// fetch containerlab created networks
		f := filters.NewArgs()
		f.Add("label", "containerlab")
		nr, err = c.Client.NetworkList(nctx, dockerTypes.NetworkListOptions{
			Filters: f,
		})

		if err != nil {
			return nil, err
		}

		// fetch default bridge network
		f = filters.NewArgs()
		f.Add("name", "bridge")
		bridgenet, err := c.Client.NetworkList(nctx, dockerTypes.NetworkListOptions{
			Filters: f,
		})

		if err != nil {
			return nil, err
		}

		nr = append(nr, bridgenet...)

not sure which is better though =)

@karimra
Copy link
Member

karimra commented Jun 17, 2021

This wouldn't work if no mgmt network was specified in the topo file, i.e use network clab

I'd say either do 2 queries for the networks (label=containerlab and name=bridge),

or make the var bridgeName default to bridge if it's still empty after going through the networks list, here: https://github.com/srl-labs/containerlab/blob/master/runtime/docker/docker.go#L421

@hellt
Copy link
Member

hellt commented Jun 17, 2021

This wouldn't work if no mgmt network was specified in the topo file, i.e use network clab

what wouldn't work? current version of this branch c8142b6 where filters are empty seems to work fine with the default network (i.e. omitted mgmt container in clab file)

@karimra
Copy link
Member

karimra commented Jun 17, 2021

it works because the containers are connected to a single bridge, so it defaults to that one.

The idea in #433 was to make sure the IPs printed come from a bridge that was created by clab, which turns out to be too restrictive in case --all is used.
The condition should be, a bridge created by clab or a bridge called bridge

@hellt
Copy link
Member

hellt commented Jun 17, 2021

in 38b11a3 the two-filters approach has been added

@hellt hellt merged commit f92fadd into master Jun 17, 2021
@hellt hellt deleted the issue456 branch October 22, 2021 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants