-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
pass networks to container clone #14059
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not the problem. The json marshal/unmarshal will handle it just fine.
Podman stores the network information inside an extra db bucket and not the container config. I guess container clone must read from the there and not the settings in the container config.
ah I see @Luap99 I will correct my comment but this fixes the issue, right?
|
Try with network connect/disconnect. Networks must always be read from the db, see |
yes it works with connect/disconnect.
|
Also if you connect a second network? |
You have to connect before you clone |
@Luap99 I will add some tests for these cases |
I just tried on main branch and it looks like it already works without this change. I assume something else merged in the meantime which fixed this problem |
@Luap99 I dont see how that could be possible, |
nvm I tested the wrong container, but it does not work with this patch either. |
I will keep working on this and add some more tests. This breaks running a cloned ctr in a pod too which makes me think this solution works and we were just never passing the network options. I will look at the original |
Ok I see the problem I thought I unset the networks but the logic does this to late after the config is written: podman/libpod/boltdb_state_internal.go Lines 584 to 586 in 73836e0
So you end up with networks in the config, however no caller should ever use this, always use Your patch is correct because Networks from the config has a different json tag ( So the only thing missing is do get the updated network list from the db. I guess it would make sense to attach this in c.Config() since outside caller should not worry about this detail IMO. |
@Luap99 can I just get the whole config again from the db in |
I was thinking something like this: diff --git a/libpod/container.go b/libpod/container.go
index 3e7ab7b0a..7afa78dc8 100644
--- a/libpod/container.go
+++ b/libpod/container.go
@@ -288,6 +288,12 @@ func (c *Container) Config() *ContainerConfig {
return nil
}
+ networks, err := c.networks()
+ if err != nil {
+ return nil
+ }
+ returnConfig.Networks = networks
+
return returnConfig
}
|
01b0f83
to
a36a4ac
Compare
LGTM |
@Luap99 PTAL |
since the network config is a string map, json.unmarshal does not recognize the config and spec as the same entity, need to map this option manually resolves containers#13713 Signed-off-by: cdoern <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, one nit but not worth to repush
_, ok := inspect.InspectContainerToJSON()[0].NetworkSettings.Networks["testing123"] | ||
Expect(ok).To(BeTrue()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit please use HaveKeyValue() for such tests.
If this check fails you currently would get a very unhelpful expected false to be true
message.
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: cdoern, Luap99 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
since the network config is a string map, json.unmarshal does not recognize
the config and spec as the same entity, need to map this option manually
resolves #13713
Signed-off-by: cdoern [email protected]