Add DNS and security fields to DB

Also moves port mappings out of the SQL DB and into a file on
disk. These could get very sizable (hundred to thousands of
ports) so moving them out to a file will keep the DB small and
fast.

Finally, add a foreign key reference from container ID to
container state ID. This ensures we never get into an
inconsistent state where we have data in one table but not the
other.

Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #225
Approved by: baude
This commit is contained in:
Matthew Heon
2018-01-15 11:21:30 -05:00
committed by Atomic Bot
parent 2bfb31ddf4
commit 2e48c60bc5
4 changed files with 190 additions and 35 deletions

View File

@ -3,6 +3,7 @@ package libpod
import (
"encoding/json"
"io/ioutil"
"net"
"os"
"path/filepath"
"reflect"
@ -10,6 +11,7 @@ import (
"time"
"github.com/containers/storage"
"github.com/cri-o/ocicni/pkg/ocicni"
"github.com/opencontainers/runtime-tools/generate"
"github.com/stretchr/testify/assert"
)
@ -29,6 +31,24 @@ func getTestContainer(id, name, locksDir string) (*Container, error) {
StopSignal: 0,
StopTimeout: 0,
CreatedTime: time.Now(),
Privileged: true,
Mounts: []string{"/does/not/exist"},
DNSServer: []net.IP{net.ParseIP("192.168.1.1"), net.ParseIP("192.168.2.2")},
DNSSearch: []string{"example.com", "example.example.com"},
PortMappings: []ocicni.PortMapping{
{
HostPort: 80,
ContainerPort: 90,
Protocol: "tcp",
HostIP: "192.168.3.3",
},
{
HostPort: 100,
ContainerPort: 110,
Protocol: "udp",
HostIP: "192.168.4.4",
},
},
},
state: &containerRuntimeInfo{
State: ContainerStateRunning,