modify package from iSulad-lxcfs-toolkit to lxcfs-tools
Signed-off-by: zhangsong34 <zhangsong34@huawei.com>
This commit is contained in:
parent
864470a0f9
commit
57c27bce2e
6
Makefile
6
Makefile
@ -1,5 +1,5 @@
|
|||||||
# Copyright (c) Huawei Technologies Co., Ltd. 2019. All rights reserved.
|
# Copyright (c) Huawei Technologies Co., Ltd. 2019. All rights reserved.
|
||||||
# iSulad-lxcfs-toolkit is licensed under the Mulan PSL v1.
|
# lxcfs-tools is licensed under the Mulan PSL v1.
|
||||||
# You can use this software according to the terms and conditions of the Mulan PSL v1.
|
# You can use this software according to the terms and conditions of the Mulan PSL v1.
|
||||||
# You may obtain a copy of Mulan PSL v1 at:
|
# You may obtain a copy of Mulan PSL v1 at:
|
||||||
# http://license.coscl.org.cn/MulanPSL
|
# http://license.coscl.org.cn/MulanPSL
|
||||||
@ -29,8 +29,8 @@ all: toolkit lxcfs-hook
|
|||||||
local: toolkit lxcfs-hook
|
local: toolkit lxcfs-hook
|
||||||
|
|
||||||
toolkit: $(SOURCES) | $(DEPS_LINK)
|
toolkit: $(SOURCES) | $(DEPS_LINK)
|
||||||
@echo "Making isulad-lxcfs-tools..."
|
@echo "Making lxcfs-tools..."
|
||||||
${ENV} go build -mod=vendor -tags ${TAGS} -ldflags ${GO_LDFLAGS} -o build/isulad-lxcfs-toolkit .
|
${ENV} go build -mod=vendor -tags ${TAGS} -ldflags ${GO_LDFLAGS} -o build/lxcfs-tools .
|
||||||
@echo "Done!"
|
@echo "Done!"
|
||||||
|
|
||||||
lxcfs-hook: $(SOURCES) | $(DEPS_LINK)
|
lxcfs-hook: $(SOURCES) | $(DEPS_LINK)
|
||||||
|
|||||||
2
go.mod
2
go.mod
@ -1,4 +1,4 @@
|
|||||||
module isulad-lxcfs-toolkit
|
module lxcfs-tools
|
||||||
|
|
||||||
replace (
|
replace (
|
||||||
github.com/docker/docker => github.com/docker/engine v0.0.0-20181106193140-f5749085e9cb
|
github.com/docker/docker => github.com/docker/engine v0.0.0-20181106193140-f5749085e9cb
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
# Copyright (c) Huawei Technologies Co., Ltd. 2019. All rights reserved.
|
# Copyright (c) Huawei Technologies Co., Ltd. 2019. All rights reserved.
|
||||||
# iSulad-lxcfs-toolkit is licensed under the Mulan PSL v1.
|
# lxcfs-tools is licensed under the Mulan PSL v1.
|
||||||
# You can use this software according to the terms and conditions of the Mulan PSL v1.
|
# You can use this software according to the terms and conditions of the Mulan PSL v1.
|
||||||
# You may obtain a copy of Mulan PSL v1 at:
|
# You may obtain a copy of Mulan PSL v1 at:
|
||||||
# http://license.coscl.org.cn/MulanPSL
|
# http://license.coscl.org.cn/MulanPSL
|
||||||
@ -14,10 +14,10 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
|
||||||
ISULAD_LXCFS_TOOLKIT_DIR=/usr/local/bin
|
LXCFS_TOOLS_DIR=/usr/local/bin
|
||||||
|
|
||||||
echo "isulad_lxcfs_toolkit will be installed to $ISULAD_LXCFS_TOOLKIT_DIR"
|
echo "lxcfs-tools will be installed to $LXCFS_TOOLS_DIR"
|
||||||
|
|
||||||
install -m 0755 -p ../build/isulad_lxcfs_toolkit ${ISULAD_LXCFS_TOOLKIT_DIR}
|
install -m 0755 -p ../build/lxcfs-tools ${LXCFS_TOOLS_DIR}
|
||||||
|
|
||||||
echo "isulad_lxcfs_toolkit install done"
|
echo "lxcfs-tools install done"
|
||||||
|
|||||||
@ -2,12 +2,12 @@
|
|||||||
%define debug_package %{nil}
|
%define debug_package %{nil}
|
||||||
|
|
||||||
#Basic Information
|
#Basic Information
|
||||||
Name: isulad-lxcfs-toolkit
|
Name: lxcfs-tools
|
||||||
Version: 0.3
|
Version: 0.3
|
||||||
Release: 15
|
Release: 16
|
||||||
Summary: toolkit for lxcfs to remount a running isulad
|
Summary: toolkit for lxcfs to remount a running isulad
|
||||||
License: Mulan PSL v1
|
License: Mulan PSL v1
|
||||||
URL: https://gitee.com/src-openeuler/iSulad-lxcfs-toolkit
|
URL: https://gitee.com/src-openeuler/lxcfs-tools
|
||||||
Source0: %{name}.tar.gz
|
Source0: %{name}.tar.gz
|
||||||
BuildRoot: %{_tmppath}/%{name}-root
|
BuildRoot: %{_tmppath}/%{name}-root
|
||||||
|
|
||||||
@ -26,23 +26,23 @@ export RPM_BUILD_SOURCE=%_topdir/SOURCES
|
|||||||
|
|
||||||
cd $RPM_BUILD_DIR
|
cd $RPM_BUILD_DIR
|
||||||
|
|
||||||
mkdir -p $RPM_BUILD_DIR/src/isula.org/isulad-lxcfs-toolkit && cd $RPM_BUILD_DIR/src/isula.org/isulad-lxcfs-toolkit
|
mkdir -p $RPM_BUILD_DIR/src/isula.org/lxcfs-tools && cd $RPM_BUILD_DIR/src/isula.org/lxcfs-tools
|
||||||
gzip -dc $RPM_BUILD_SOURCE/%{name}.tar.gz | tar -xvvf -
|
gzip -dc $RPM_BUILD_SOURCE/%{name}.tar.gz | tar -xvvf -
|
||||||
|
|
||||||
%build
|
%build
|
||||||
cd $RPM_BUILD_DIR/src/isula.org/isulad-lxcfs-toolkit
|
cd $RPM_BUILD_DIR/src/isula.org/lxcfs-tools
|
||||||
make
|
make
|
||||||
|
|
||||||
%install
|
%install
|
||||||
HOOK_DIR=$RPM_BUILD_ROOT/var/lib/isulad/hooks
|
HOOK_DIR=$RPM_BUILD_ROOT/var/lib/isulad/hooks
|
||||||
ISULAD_LXCFS_TOOLKIT_DIR=$RPM_BUILD_ROOT/usr/local/bin
|
LXCFS_TOOLS_DIR=$RPM_BUILD_ROOT/usr/local/bin
|
||||||
|
|
||||||
cd $RPM_BUILD_DIR/src/isula.org/isulad-lxcfs-toolkit
|
cd $RPM_BUILD_DIR/src/isula.org/lxcfs-tools
|
||||||
mkdir -p -m 0700 ${HOOK_DIR}
|
mkdir -p -m 0700 ${HOOK_DIR}
|
||||||
mkdir -p -m 0700 ${ISULAD_LXCFS_TOOLKIT_DIR}
|
mkdir -p -m 0700 ${LXCFS_TOOLS_DIR}
|
||||||
|
|
||||||
install -m 0750 build/lxcfs-hook ${HOOK_DIR}
|
install -m 0750 build/lxcfs-hook ${HOOK_DIR}
|
||||||
install -m 0750 build/isulad-lxcfs-toolkit ${ISULAD_LXCFS_TOOLKIT_DIR}
|
install -m 0750 build/lxcfs-tools ${LXCFS_TOOLS_DIR}
|
||||||
|
|
||||||
#Install and uninstall scripts
|
#Install and uninstall scripts
|
||||||
%pre
|
%pre
|
||||||
@ -89,7 +89,7 @@ chmod 0640 ${HOOK_SPEC}/hookspec.json
|
|||||||
#Files list
|
#Files list
|
||||||
%files
|
%files
|
||||||
%defattr(0550,root,root,0550)
|
%defattr(0550,root,root,0550)
|
||||||
/usr/local/bin/isulad-lxcfs-toolkit
|
/usr/local/bin/lxcfs-tools
|
||||||
%attr(0550,root,root) /var/lib/isulad/hooks
|
%attr(0550,root,root) /var/lib/isulad/hooks
|
||||||
%attr(0550,root,root) /var/lib/isulad/hooks/lxcfs-hook
|
%attr(0550,root,root) /var/lib/isulad/hooks/lxcfs-hook
|
||||||
|
|
||||||
@ -99,5 +99,8 @@ rm -rfv %{buildroot}
|
|||||||
|
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue Jan 7 2020 Zhangsong <zhangsong34@huawei.com> - 0.3.16
|
||||||
|
- update package
|
||||||
|
|
||||||
* Thu Feb 1 2018 Tanzhe <tanzhe@huawei.com>
|
* Thu Feb 1 2018 Tanzhe <tanzhe@huawei.com>
|
||||||
- add require version
|
- add require version
|
||||||
@ -1,5 +1,5 @@
|
|||||||
// Copyright (c) Huawei Technologies Co., Ltd. 2019. All rights reserved.
|
// Copyright (c) Huawei Technologies Co., Ltd. 2019. All rights reserved.
|
||||||
// iSulad-lxcfs-toolkit is licensed under the Mulan PSL v1.
|
// lxcfs-tools is licensed under the Mulan PSL v1.
|
||||||
// You can use this software according to the terms and conditions of the Mulan PSL v1.
|
// You can use this software according to the terms and conditions of the Mulan PSL v1.
|
||||||
// You may obtain a copy of Mulan PSL v1 at:
|
// You may obtain a copy of Mulan PSL v1 at:
|
||||||
// http://license.coscl.org.cn/MulanPSL
|
// http://license.coscl.org.cn/MulanPSL
|
||||||
@ -17,17 +17,17 @@ package main
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"isulad-lxcfs-toolkit/libmount"
|
"lxcfs-tools/libmount"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
isulad_lxcfs_log "github.com/sirupsen/logrus"
|
lxcfs_log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
func prestartMountHook(pid int, rootfs string) error {
|
func prestartMountHook(pid int, rootfs string) error {
|
||||||
lxcfssubpath, err := ioutil.ReadDir("/var/lib/lxc/lxcfs/proc")
|
lxcfssubpath, err := ioutil.ReadDir("/var/lib/lxc/lxcfs/proc")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
isulad_lxcfs_log.Errorf("Prase lxcfs dir failed: %v", err)
|
lxcfs_log.Errorf("Prase lxcfs dir failed: %v", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ func prestartMountHook(pid int, rootfs string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := libmount.NsExecMount(strconv.Itoa(pid), rootfs, valueMountPaths, valuePaths); err != nil {
|
if err := libmount.NsExecMount(strconv.Itoa(pid), rootfs, valueMountPaths, valuePaths); err != nil {
|
||||||
isulad_lxcfs_log.Errorf("mount %v into container error: %v", valueMountPaths, err)
|
lxcfs_log.Errorf("mount %v into container error: %v", valueMountPaths, err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
// Copyright (c) Huawei Technologies Co., Ltd. 2019. All rights reserved.
|
// Copyright (c) Huawei Technologies Co., Ltd. 2019. All rights reserved.
|
||||||
// iSulad-lxcfs-toolkit is licensed under the Mulan PSL v1.
|
// lxcfs-tools is licensed under the Mulan PSL v1.
|
||||||
// You can use this software according to the terms and conditions of the Mulan PSL v1.
|
// You can use this software according to the terms and conditions of the Mulan PSL v1.
|
||||||
// You may obtain a copy of Mulan PSL v1 at:
|
// You may obtain a copy of Mulan PSL v1 at:
|
||||||
// http://license.coscl.org.cn/MulanPSL
|
// http://license.coscl.org.cn/MulanPSL
|
||||||
@ -17,7 +17,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"isulad-lxcfs-toolkit/hooks/lxcfs-hook/utils"
|
"lxcfs-tools/hooks/lxcfs-hook/utils"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/docker/docker/pkg/reexec"
|
"github.com/docker/docker/pkg/reexec"
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
// Copyright (c) Huawei Technologies Co., Ltd. 2019. All rights reserved.
|
// Copyright (c) Huawei Technologies Co., Ltd. 2019. All rights reserved.
|
||||||
// iSulad-lxcfs-toolkit is licensed under the Mulan PSL v1.
|
// lxcfs-tools is licensed under the Mulan PSL v1.
|
||||||
// You can use this software according to the terms and conditions of the Mulan PSL v1.
|
// You can use this software according to the terms and conditions of the Mulan PSL v1.
|
||||||
// You may obtain a copy of Mulan PSL v1 at:
|
// You may obtain a copy of Mulan PSL v1 at:
|
||||||
// http://license.coscl.org.cn/MulanPSL
|
// http://license.coscl.org.cn/MulanPSL
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
// Copyright (c) Huawei Technologies Co., Ltd. 2019. All rights reserved.
|
// Copyright (c) Huawei Technologies Co., Ltd. 2019. All rights reserved.
|
||||||
// iSulad-lxcfs-toolkit is licensed under the Mulan PSL v1.
|
// lxcfs-tools is licensed under the Mulan PSL v1.
|
||||||
// You can use this software according to the terms and conditions of the Mulan PSL v1.
|
// You can use this software according to the terms and conditions of the Mulan PSL v1.
|
||||||
// You may obtain a copy of Mulan PSL v1 at:
|
// You may obtain a copy of Mulan PSL v1 at:
|
||||||
// http://license.coscl.org.cn/MulanPSL
|
// http://license.coscl.org.cn/MulanPSL
|
||||||
@ -16,7 +16,7 @@ package libmount
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"isulad-lxcfs-toolkit/libmount/nsexec"
|
"lxcfs-tools/libmount/nsexec"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
// Copyright (c) Huawei Technologies Co., Ltd. 2019. All rights reserved.
|
// Copyright (c) Huawei Technologies Co., Ltd. 2019. All rights reserved.
|
||||||
// iSulad-lxcfs-toolkit is licensed under the Mulan PSL v1.
|
// lxcfs-tools is licensed under the Mulan PSL v1.
|
||||||
// You can use this software according to the terms and conditions of the Mulan PSL v1.
|
// You can use this software according to the terms and conditions of the Mulan PSL v1.
|
||||||
// You may obtain a copy of Mulan PSL v1 at:
|
// You may obtain a copy of Mulan PSL v1 at:
|
||||||
// http://license.coscl.org.cn/MulanPSL
|
// http://license.coscl.org.cn/MulanPSL
|
||||||
@ -14,7 +14,7 @@
|
|||||||
package libmount
|
package libmount
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"isulad-lxcfs-toolkit/libmount/nsexec"
|
"lxcfs-tools/libmount/nsexec"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NsExecMount exec mount in container namespace
|
// NsExecMount exec mount in container namespace
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
// Copyright (c) Huawei Technologies Co., Ltd. 2019. All rights reserved.
|
// Copyright (c) Huawei Technologies Co., Ltd. 2019. All rights reserved.
|
||||||
// iSulad-lxcfs-toolkit is licensed under the Mulan PSL v1.
|
// lxcfs-tools is licensed under the Mulan PSL v1.
|
||||||
// You can use this software according to the terms and conditions of the Mulan PSL v1.
|
// You can use this software according to the terms and conditions of the Mulan PSL v1.
|
||||||
// You may obtain a copy of Mulan PSL v1 at:
|
// You may obtain a copy of Mulan PSL v1 at:
|
||||||
// http://license.coscl.org.cn/MulanPSL
|
// http://license.coscl.org.cn/MulanPSL
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
// Copyright (c) Huawei Technologies Co., Ltd. 2019. All rights reserved.
|
// Copyright (c) Huawei Technologies Co., Ltd. 2019. All rights reserved.
|
||||||
// iSulad-lxcfs-toolkit is licensed under the Mulan PSL v1.
|
// lxcfs-tools is licensed under the Mulan PSL v1.
|
||||||
// You can use this software according to the terms and conditions of the Mulan PSL v1.
|
// You can use this software according to the terms and conditions of the Mulan PSL v1.
|
||||||
// You may obtain a copy of Mulan PSL v1 at:
|
// You may obtain a copy of Mulan PSL v1 at:
|
||||||
// http://license.coscl.org.cn/MulanPSL
|
// http://license.coscl.org.cn/MulanPSL
|
||||||
|
|||||||
10
main.go
10
main.go
@ -1,5 +1,5 @@
|
|||||||
// Copyright (c) Huawei Technologies Co., Ltd. 2019. All rights reserved.
|
// Copyright (c) Huawei Technologies Co., Ltd. 2019. All rights reserved.
|
||||||
// iSulad-lxcfs-toolkit is licensed under the Mulan PSL v1.
|
// lxcfs-tools is licensed under the Mulan PSL v1.
|
||||||
// You can use this software according to the terms and conditions of the Mulan PSL v1.
|
// You can use this software according to the terms and conditions of the Mulan PSL v1.
|
||||||
// You may obtain a copy of Mulan PSL v1 at:
|
// You may obtain a copy of Mulan PSL v1 at:
|
||||||
// http://license.coscl.org.cn/MulanPSL
|
// http://license.coscl.org.cn/MulanPSL
|
||||||
@ -21,19 +21,19 @@ import (
|
|||||||
|
|
||||||
"github.com/docker/docker/pkg/reexec"
|
"github.com/docker/docker/pkg/reexec"
|
||||||
_ "github.com/opencontainers/runc/libcontainer/nsenter"
|
_ "github.com/opencontainers/runc/libcontainer/nsenter"
|
||||||
isulad_lxcfs_log "github.com/sirupsen/logrus"
|
lxcfs_log "github.com/sirupsen/logrus"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
usage = `Toolkit for reconnet to a running isulad using lxcfs`
|
usage = `Toolkit for reconnet to a running isulad using lxcfs`
|
||||||
syslogTag = "isulad-lxcfs-tools"
|
syslogTag = "lxcfs-tools"
|
||||||
)
|
)
|
||||||
|
|
||||||
var version = "0.1"
|
var version = "0.1"
|
||||||
|
|
||||||
func onfail(err error) {
|
func onfail(err error) {
|
||||||
isulad_lxcfs_log.Error(err)
|
lxcfs_log.Error(err)
|
||||||
fmt.Fprint(os.Stderr, err)
|
fmt.Fprint(os.Stderr, err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
@ -44,7 +44,7 @@ func onfailf(t string, v ...interface{}) {
|
|||||||
|
|
||||||
func runToolkit() {
|
func runToolkit() {
|
||||||
app := cli.NewApp()
|
app := cli.NewApp()
|
||||||
app.Name = "isulad-lxcfs-toolkit"
|
app.Name = "lxcfs-tools"
|
||||||
app.Usage = usage
|
app.Usage = usage
|
||||||
|
|
||||||
v := []string{
|
v := []string{
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
// Copyright (c) Huawei Technologies Co., Ltd. 2019. All rights reserved.
|
// Copyright (c) Huawei Technologies Co., Ltd. 2019. All rights reserved.
|
||||||
// iSulad-lxcfs-toolkit is licensed under the Mulan PSL v1.
|
// lxcfs-tools is licensed under the Mulan PSL v1.
|
||||||
// You can use this software according to the terms and conditions of the Mulan PSL v1.
|
// You can use this software according to the terms and conditions of the Mulan PSL v1.
|
||||||
// You may obtain a copy of Mulan PSL v1 at:
|
// You may obtain a copy of Mulan PSL v1 at:
|
||||||
// http://license.coscl.org.cn/MulanPSL
|
// http://license.coscl.org.cn/MulanPSL
|
||||||
@ -19,7 +19,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"isulad-lxcfs-toolkit/libmount"
|
"lxcfs-tools/libmount"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
@ -27,7 +27,7 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
isulad_lxcfs_log "github.com/sirupsen/logrus"
|
lxcfs_log "github.com/sirupsen/logrus"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ var recmountContainer = cli.Command{
|
|||||||
onfail(fmt.Errorf("read init user namespace fail: %v", err))
|
onfail(fmt.Errorf("read init user namespace fail: %v", err))
|
||||||
}
|
}
|
||||||
if context.Bool("all") {
|
if context.Bool("all") {
|
||||||
isulad_lxcfs_log.Info("remount to all containers")
|
lxcfs_log.Info("remount to all containers")
|
||||||
if err := remountAll(initMountns, initUserns); err != nil {
|
if err := remountAll(initMountns, initUserns); err != nil {
|
||||||
onfail(err)
|
onfail(err)
|
||||||
}
|
}
|
||||||
@ -101,7 +101,7 @@ var checklxcfs = cli.Command{
|
|||||||
if err := waitForLxcfs(); err != nil {
|
if err := waitForLxcfs(); err != nil {
|
||||||
onfail(err)
|
onfail(err)
|
||||||
} else {
|
} else {
|
||||||
isulad_lxcfs_log.Info("lxcfs is running")
|
lxcfs_log.Info("lxcfs is running")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -119,20 +119,20 @@ var execprestart = cli.Command{
|
|||||||
if err := doprestart(); err != nil {
|
if err := doprestart(); err != nil {
|
||||||
onfail(err)
|
onfail(err)
|
||||||
} else {
|
} else {
|
||||||
isulad_lxcfs_log.Info("prestart done")
|
lxcfs_log.Info("prestart done")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func doprestart() error {
|
func doprestart() error {
|
||||||
isulad_lxcfs_log.Info("do prestart")
|
lxcfs_log.Info("do prestart")
|
||||||
|
|
||||||
if err := syscall.Unmount("/var/lib/lxc/lxcfs", syscall.MNT_DETACH); err == nil {
|
if err := syscall.Unmount("/var/lib/lxc/lxcfs", syscall.MNT_DETACH); err == nil {
|
||||||
isulad_lxcfs_log.Warning("releaseMountpoint: umount /var/lib/lxc/lxcfs")
|
lxcfs_log.Warning("releaseMountpoint: umount /var/lib/lxc/lxcfs")
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := syscall.Unmount("/var/lib/lxc", syscall.MNT_DETACH); err == nil {
|
if err := syscall.Unmount("/var/lib/lxc", syscall.MNT_DETACH); err == nil {
|
||||||
isulad_lxcfs_log.Warning("releaseMountpoint: umount /var/lib/lxc")
|
lxcfs_log.Warning("releaseMountpoint: umount /var/lib/lxc")
|
||||||
}
|
}
|
||||||
|
|
||||||
prestartparm1 := []string{
|
prestartparm1 := []string{
|
||||||
@ -170,7 +170,7 @@ func waitForLxcfs() error {
|
|||||||
|
|
||||||
if count == maxCount {
|
if count == maxCount {
|
||||||
err := fmt.Errorf("lxcfs is not ready")
|
err := fmt.Errorf("lxcfs is not ready")
|
||||||
isulad_lxcfs_log.Errorf("%v", err)
|
lxcfs_log.Errorf("%v", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,7 +178,7 @@ func waitForLxcfs() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func remountAll(initMountns, initUserns string) error {
|
func remountAll(initMountns, initUserns string) error {
|
||||||
isulad_lxcfs_log.Info("begin remount All runing container...")
|
lxcfs_log.Info("begin remount All runing container...")
|
||||||
out, err := execCommond("isula", []string{"ps", "--format", "{{.ID}} {{.Pid}}"})
|
out, err := execCommond("isula", []string{"ps", "--format", "{{.ID}} {{.Pid}}"})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -196,19 +196,19 @@ func remountAll(initMountns, initUserns string) error {
|
|||||||
res := make(chan struct{}, 1)
|
res := make(chan struct{}, 1)
|
||||||
go func() {
|
go func() {
|
||||||
if err := remountToContainer(initMountns, initUserns, containerslice[0], containerslice[1], true); err != nil {
|
if err := remountToContainer(initMountns, initUserns, containerslice[0], containerslice[1], true); err != nil {
|
||||||
isulad_lxcfs_log.Errorf("remount lxcfs dir to container(%s) failed: %v", containerslice[0], err)
|
lxcfs_log.Errorf("remount lxcfs dir to container(%s) failed: %v", containerslice[0], err)
|
||||||
}
|
}
|
||||||
res <- struct{}{}
|
res <- struct{}{}
|
||||||
}()
|
}()
|
||||||
select {
|
select {
|
||||||
case <-res:
|
case <-res:
|
||||||
case <-time.After(30 * time.Second): // 30s timeout
|
case <-time.After(30 * time.Second): // 30s timeout
|
||||||
isulad_lxcfs_log.Errorf("remount lxcfs dir to container(%s) timeout", containerslice[0])
|
lxcfs_log.Errorf("remount lxcfs dir to container(%s) timeout", containerslice[0])
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
isulad_lxcfs_log.Info(" remount All done...")
|
lxcfs_log.Info(" remount All done...")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -221,7 +221,7 @@ func remountToContainer(initMountns, initUserns, containerid string, pid string,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
isulad_lxcfs_log.Infof("begin remount container,container id: %s, pid: %s", containerid, pid)
|
lxcfs_log.Infof("begin remount container,container id: %s, pid: %s", containerid, pid)
|
||||||
|
|
||||||
lxcfssubpath, err := ioutil.ReadDir("/var/lib/lxc/lxcfs/proc")
|
lxcfssubpath, err := ioutil.ReadDir("/var/lib/lxc/lxcfs/proc")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -244,18 +244,18 @@ func remountToContainer(initMountns, initUserns, containerid string, pid string,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := libmount.NsExecUmount(pid, valuePaths); err != nil {
|
if err := libmount.NsExecUmount(pid, valuePaths); err != nil {
|
||||||
isulad_lxcfs_log.Errorf("unmount %v for container error: %v", valuePaths, err)
|
lxcfs_log.Errorf("unmount %v for container error: %v", valuePaths, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := libmount.NsExecMount(pid, "", valueMountPaths, valuePaths); err != nil {
|
if err := libmount.NsExecMount(pid, "", valueMountPaths, valuePaths); err != nil {
|
||||||
isulad_lxcfs_log.Errorf("mount %v into container %s error: %v", valueMountPaths, containerid, err)
|
lxcfs_log.Errorf("mount %v into container %s error: %v", valueMountPaths, containerid, err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func isContainerExsit(containerid string) (string, error) {
|
func isContainerExsit(containerid string) (string, error) {
|
||||||
isulad_lxcfs_log.Info("begin isContainerExsit...")
|
lxcfs_log.Info("begin isContainerExsit...")
|
||||||
if containerid == "" {
|
if containerid == "" {
|
||||||
return "", fmt.Errorf("Containerid mustn't be empty")
|
return "", fmt.Errorf("Containerid mustn't be empty")
|
||||||
}
|
}
|
||||||
@ -283,7 +283,7 @@ func execCommond(command string, params []string) ([]string, error) {
|
|||||||
res := []string{
|
res := []string{
|
||||||
" ",
|
" ",
|
||||||
}
|
}
|
||||||
isulad_lxcfs_log.Info("exec cmd :", cmd.Args)
|
lxcfs_log.Info("exec cmd :", cmd.Args)
|
||||||
|
|
||||||
stdout, err := cmd.StdoutPipe()
|
stdout, err := cmd.StdoutPipe()
|
||||||
|
|
||||||
|
|||||||
20
umountcmd.go
20
umountcmd.go
@ -1,5 +1,5 @@
|
|||||||
// Copyright (c) Huawei Technologies Co., Ltd. 2019. All rights reserved.
|
// Copyright (c) Huawei Technologies Co., Ltd. 2019. All rights reserved.
|
||||||
// iSulad-lxcfs-toolkit is licensed under the Mulan PSL v1.
|
// lxcfs-tools is licensed under the Mulan PSL v1.
|
||||||
// You can use this software according to the terms and conditions of the Mulan PSL v1.
|
// You can use this software according to the terms and conditions of the Mulan PSL v1.
|
||||||
// You may obtain a copy of Mulan PSL v1 at:
|
// You may obtain a copy of Mulan PSL v1 at:
|
||||||
// http://license.coscl.org.cn/MulanPSL
|
// http://license.coscl.org.cn/MulanPSL
|
||||||
@ -17,13 +17,13 @@ package main
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"isulad-lxcfs-toolkit/libmount"
|
"lxcfs-tools/libmount"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
isulad_lxcfs_log "github.com/sirupsen/logrus"
|
lxcfs_log "github.com/sirupsen/logrus"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ var umountContainer = cli.Command{
|
|||||||
onfail(fmt.Errorf("read init user namespace fail: %v", err))
|
onfail(fmt.Errorf("read init user namespace fail: %v", err))
|
||||||
}
|
}
|
||||||
if context.Bool("all") {
|
if context.Bool("all") {
|
||||||
isulad_lxcfs_log.Info("umount for all containers")
|
lxcfs_log.Info("umount for all containers")
|
||||||
if err := umountAll(initMountns, initUserns); err != nil {
|
if err := umountAll(initMountns, initUserns); err != nil {
|
||||||
onfail(err)
|
onfail(err)
|
||||||
}
|
}
|
||||||
@ -84,7 +84,7 @@ var umountContainer = cli.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
func umountAll(initMountns, initUserns string) error {
|
func umountAll(initMountns, initUserns string) error {
|
||||||
isulad_lxcfs_log.Info("begin umount All runing container...")
|
lxcfs_log.Info("begin umount All runing container...")
|
||||||
out, err := execCommond("isula", []string{"ps", "--format", "{{.ID}} {{.Pid}}"})
|
out, err := execCommond("isula", []string{"ps", "--format", "{{.ID}} {{.Pid}}"})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -102,20 +102,20 @@ func umountAll(initMountns, initUserns string) error {
|
|||||||
res := make(chan struct{}, 1)
|
res := make(chan struct{}, 1)
|
||||||
go func() {
|
go func() {
|
||||||
if err := umountForContainer(initMountns, initUserns, containerslice[0], containerslice[1], true); err != nil {
|
if err := umountForContainer(initMountns, initUserns, containerslice[0], containerslice[1], true); err != nil {
|
||||||
isulad_lxcfs_log.Errorf("umount lxcfs dir from container(%s) failed: %v", containerslice[0], err)
|
lxcfs_log.Errorf("umount lxcfs dir from container(%s) failed: %v", containerslice[0], err)
|
||||||
}
|
}
|
||||||
res <- struct{}{}
|
res <- struct{}{}
|
||||||
}()
|
}()
|
||||||
select {
|
select {
|
||||||
case <-res:
|
case <-res:
|
||||||
case <-time.After(30 * time.Second): // 30s timeout
|
case <-time.After(30 * time.Second): // 30s timeout
|
||||||
isulad_lxcfs_log.Errorf("umount lxcfs dir from container(%s) timeout", containerslice[0])
|
lxcfs_log.Errorf("umount lxcfs dir from container(%s) timeout", containerslice[0])
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
}
|
}
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
isulad_lxcfs_log.Info(" umount All done...")
|
lxcfs_log.Info(" umount All done...")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,7 +128,7 @@ func umountForContainer(initMountns, initUserns, containerid string, pid string,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
isulad_lxcfs_log.Infof("begin umount container,container id: %s, pid: %s", containerid, pid)
|
lxcfs_log.Infof("begin umount container,container id: %s, pid: %s", containerid, pid)
|
||||||
|
|
||||||
lxcfssubpath, err := ioutil.ReadDir("/var/lib/lxc/lxcfs/proc")
|
lxcfssubpath, err := ioutil.ReadDir("/var/lib/lxc/lxcfs/proc")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -149,7 +149,7 @@ func umountForContainer(initMountns, initUserns, containerid string, pid string,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := libmount.NsExecUmount(pid, valuePaths); err != nil {
|
if err := libmount.NsExecUmount(pid, valuePaths); err != nil {
|
||||||
isulad_lxcfs_log.Errorf("unmount %v for container %s error: %v", valuePaths, containerid, err)
|
lxcfs_log.Errorf("unmount %v for container %s error: %v", valuePaths, containerid, err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user