mirror of
https://github.com/containers/podman.git
synced 2025-07-02 00:30:00 +08:00
libpod: set cid network alias in setupContainer()
Since we have sqlite there is no point in duplicating this acroos two db backends. Just set earlier when we validate the networks anyway. Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
@ -607,8 +607,6 @@ func (s *BoltState) addContainer(ctr *Container, pod *Pod) error {
|
|||||||
if opts.InterfaceName == "" {
|
if opts.InterfaceName == "" {
|
||||||
return fmt.Errorf("network interface name cannot be an empty string: %w", define.ErrInvalidArg)
|
return fmt.Errorf("network interface name cannot be an empty string: %w", define.ErrInvalidArg)
|
||||||
}
|
}
|
||||||
// always add the short id as alias for docker compat
|
|
||||||
opts.Aliases = append(opts.Aliases, ctr.config.ID[:12])
|
|
||||||
optBytes, err := json.Marshal(opts)
|
optBytes, err := json.Marshal(opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("marshalling network options JSON for container %s: %w", ctr.ID(), err)
|
return fmt.Errorf("marshalling network options JSON for container %s: %w", ctr.ID(), err)
|
||||||
|
@ -282,6 +282,8 @@ func (r *Runtime) setupContainer(ctx context.Context, ctr *Container) (_ *Contai
|
|||||||
return nil, errors.New("failed to find free network interface name")
|
return nil, errors.New("failed to find free network interface name")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// always add the short id as alias for docker compat
|
||||||
|
opts.Aliases = append(opts.Aliases, ctr.config.ID[:12])
|
||||||
|
|
||||||
normalizeNetworks[netName] = opts
|
normalizeNetworks[netName] = opts
|
||||||
}
|
}
|
||||||
|
@ -385,12 +385,6 @@ func (s *SQLiteState) rewriteContainerConfig(ctr *Container, newCfg *ContainerCo
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *SQLiteState) addContainer(ctr *Container) (defErr error) {
|
func (s *SQLiteState) addContainer(ctr *Container) (defErr error) {
|
||||||
for net := range ctr.config.Networks {
|
|
||||||
opts := ctr.config.Networks[net]
|
|
||||||
opts.Aliases = append(opts.Aliases, ctr.config.ID[:12])
|
|
||||||
ctr.config.Networks[net] = opts
|
|
||||||
}
|
|
||||||
|
|
||||||
configJSON, err := json.Marshal(ctr.config)
|
configJSON, err := json.Marshal(ctr.config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("marshalling container config json: %w", err)
|
return fmt.Errorf("marshalling container config json: %w", err)
|
||||||
|
Reference in New Issue
Block a user