mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
Merge pull request #51469 from thaJeztah/daemon_rm_deadcode
remove some dead code
This commit is contained in:
@@ -86,13 +86,6 @@ func (daemon *Daemon) load(id string) (*container.Container, error) {
|
|||||||
return ctr, nil
|
return ctr, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register makes a container object usable by the daemon as <container.ID>
|
|
||||||
//
|
|
||||||
// Deprecated: this function is unused and will be removed in the next release.
|
|
||||||
func (daemon *Daemon) Register(c *container.Container) error {
|
|
||||||
return daemon.register(context.TODO(), c)
|
|
||||||
}
|
|
||||||
|
|
||||||
// register makes a container object usable by the daemon as [container.Container.ID].
|
// register makes a container object usable by the daemon as [container.Container.ID].
|
||||||
func (daemon *Daemon) register(ctx context.Context, c *container.Container) error {
|
func (daemon *Daemon) register(ctx context.Context, c *container.Container) error {
|
||||||
// Attach to stdout and stderr
|
// Attach to stdout and stderr
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ import (
|
|||||||
"github.com/docker/distribution"
|
"github.com/docker/distribution"
|
||||||
"github.com/moby/go-archive"
|
"github.com/moby/go-archive"
|
||||||
"github.com/opencontainers/go-digest"
|
"github.com/opencontainers/go-digest"
|
||||||
"github.com/opencontainers/image-spec/identity"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -180,13 +179,6 @@ type DescribableStore interface {
|
|||||||
RegisterWithDescriptor(io.Reader, ChainID, distribution.Descriptor) (Layer, error)
|
RegisterWithDescriptor(io.Reader, ChainID, distribution.Descriptor) (Layer, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateChainID returns ID for a layerDigest slice.
|
|
||||||
//
|
|
||||||
// Deprecated: use [identity.ChainID].
|
|
||||||
func CreateChainID(dgsts []DiffID) ChainID {
|
|
||||||
return identity.ChainID(dgsts)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ReleaseAndLog releases the provided layer from the given layer
|
// ReleaseAndLog releases the provided layer from the given layer
|
||||||
// store, logging any error and release metadata
|
// store, logging any error and release metadata
|
||||||
func ReleaseAndLog(ls Store, l Layer) {
|
func ReleaseAndLog(ls Store, l Layer) {
|
||||||
|
|||||||
@@ -29,16 +29,6 @@ type NodeDiscoveryData struct {
|
|||||||
Self bool
|
Self bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// DatastoreConfigData is the data for the datastore update event message
|
|
||||||
//
|
|
||||||
// Deprecated: no longer used.
|
|
||||||
type DatastoreConfigData struct {
|
|
||||||
Scope string
|
|
||||||
Provider string
|
|
||||||
Address string
|
|
||||||
Config any
|
|
||||||
}
|
|
||||||
|
|
||||||
// DriverEncryptionConfig contains the initial datapath encryption key(s)
|
// DriverEncryptionConfig contains the initial datapath encryption key(s)
|
||||||
// Key in first position is the primary key, the one to be used in tx.
|
// Key in first position is the primary key, the one to be used in tx.
|
||||||
// Original key and tag types are []byte and uint64
|
// Original key and tag types are []byte and uint64
|
||||||
|
|||||||
@@ -17,21 +17,6 @@ import (
|
|||||||
// early for "a" (all); https://github.com/torvalds/linux/blob/v5.10/security/device_cgroup.c#L614-L642
|
// early for "a" (all); https://github.com/torvalds/linux/blob/v5.10/security/device_cgroup.c#L614-L642
|
||||||
var deviceCgroupRuleRegex = lazyregexp.New("^([acb]) ([0-9]+|\\*):([0-9]+|\\*) ([rwm]{1,3})$")
|
var deviceCgroupRuleRegex = lazyregexp.New("^([acb]) ([0-9]+|\\*):([0-9]+|\\*) ([rwm]{1,3})$")
|
||||||
|
|
||||||
// SetCapabilities sets the provided capabilities on the spec.
|
|
||||||
//
|
|
||||||
// Deprecated: this function is no longer used and will be removed in the next release.
|
|
||||||
func SetCapabilities(s *specs.Spec, caplist []string) error {
|
|
||||||
if s.Process == nil {
|
|
||||||
s.Process = &specs.Process{}
|
|
||||||
}
|
|
||||||
s.Process.Capabilities = &specs.LinuxCapabilities{
|
|
||||||
Effective: caplist,
|
|
||||||
Bounding: caplist,
|
|
||||||
Permitted: caplist,
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// AppendDevicePermissionsFromCgroupRules takes rules for the devices cgroup to append to the default set
|
// AppendDevicePermissionsFromCgroupRules takes rules for the devices cgroup to append to the default set
|
||||||
func AppendDevicePermissionsFromCgroupRules(devPermissions []specs.LinuxDeviceCgroup, rules []string) ([]specs.LinuxDeviceCgroup, error) {
|
func AppendDevicePermissionsFromCgroupRules(devPermissions []specs.LinuxDeviceCgroup, rules []string) ([]specs.LinuxDeviceCgroup, error) {
|
||||||
for _, deviceCgroupRule := range rules {
|
for _, deviceCgroupRule := range rules {
|
||||||
|
|||||||
@@ -1,127 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"log"
|
|
||||||
"os"
|
|
||||||
"path/filepath"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/moby/buildkit/identity"
|
|
||||||
"github.com/moby/sys/mountinfo"
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
)
|
|
||||||
|
|
||||||
const volumePath = "/abc/a"
|
|
||||||
|
|
||||||
var rootfs string
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
if err := run(); err != nil {
|
|
||||||
log.Printf("error: %+v", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func run() error {
|
|
||||||
infos, err := mountinfo.GetMounts(nil)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
hasVolume := false
|
|
||||||
for _, info := range infos {
|
|
||||||
if info.Mountpoint == "/" {
|
|
||||||
v, err := getOverlayRootfs(info)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
rootfs = v
|
|
||||||
}
|
|
||||||
|
|
||||||
if info.Mountpoint == volumePath {
|
|
||||||
hasVolume = true
|
|
||||||
}
|
|
||||||
log.Printf("mount: %+v", info)
|
|
||||||
}
|
|
||||||
if !hasVolume {
|
|
||||||
return errors.Errorf("volume not found: %s", volumePath)
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Printf("rootfs: %s", rootfs)
|
|
||||||
|
|
||||||
base := filepath.Base(rootfs)
|
|
||||||
if err := os.Symlink("/", filepath.Join(volumePath, base)); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// create duplicate volume path with symlink target
|
|
||||||
p := "/"
|
|
||||||
var volumeRoot string
|
|
||||||
for _, c := range strings.Split(filepath.Dir(volumePath), string(filepath.Separator)) {
|
|
||||||
if c == "" {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if volumeRoot == "" {
|
|
||||||
volumeRoot = "/" + c
|
|
||||||
c += "_target"
|
|
||||||
}
|
|
||||||
p = filepath.Join(p, c)
|
|
||||||
if err := os.Mkdir(p, 0755); err != nil {
|
|
||||||
if os.IsExist(err) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
log.Printf("created: %s", p)
|
|
||||||
}
|
|
||||||
if err := os.Symlink(filepath.Dir(rootfs), filepath.Join(p, filepath.Base(volumePath))); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := os.Rename(volumeRoot, volumeRoot+"_old"); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
for {
|
|
||||||
if _, err := os.Stat(volumeRoot); err != nil {
|
|
||||||
if os.IsNotExist(err) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
// log.Printf("detected: %s", volumeRoot)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
for {
|
|
||||||
if err := os.Rename(volumeRoot+"_target", volumeRoot); err != nil {
|
|
||||||
if os.IsExist(err) {
|
|
||||||
if err := os.Rename(volumeRoot, volumeRoot+"_"+identity.NewID()); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
log.Printf("failed to rename: %s", err)
|
|
||||||
}
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func getOverlayRootfs(info *mountinfo.Info) (string, error) {
|
|
||||||
if info.FSType != "overlay" {
|
|
||||||
return "", errors.Errorf("not overlay: %s", info.FSType)
|
|
||||||
}
|
|
||||||
for _, opt := range strings.Split(info.VFSOptions, ",") {
|
|
||||||
parts := strings.SplitN(opt, "=", 2)
|
|
||||||
if parts[0] == "workdir" {
|
|
||||||
return filepath.Join(filepath.Dir(parts[1]), "merged"), nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return "", errors.Errorf("workdir not found: %s", info.VFSOptions)
|
|
||||||
}
|
|
||||||
|
|
||||||
// /var/lib/docker/overlay2/86fcb18db0e3774cfe3b9ed6fa526d4dffcb45ac3b26cbe99db6c2d08e6dfc0e/merged
|
|
||||||
|
|
||||||
// merged/<sym>/dir1/dir2/
|
|
||||||
|
|
||||||
// volume
|
|
||||||
Reference in New Issue
Block a user