本文整理匯總了Golang中github.com/hyperhq/runv/lib/glog.Warningf函數的典型用法代碼示例。如果您正苦於以下問題:Golang Warningf函數的具體用法?Golang Warningf怎麽用?Golang Warningf使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Warningf函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Kill
func (vc *VBoxContext) Kill(ctx *hypervisor.VmContext) {
go func() {
// detach the bootable Disk
m := vc.Machine
if m == nil {
return
}
name := m.Name
m.Poweroff()
if err := vc.detachDisk(m.Name, 0); err != nil {
glog.Warningf("failed to detach the disk of VBox(%s), %s", name, err.Error())
}
if ctx.Keep < types.VM_KEEP_AFTER_SHUTDOWN {
if err := m.Delete(); err != nil {
glog.Warningf("failed to delete the VBox(%s), %s", name, err.Error())
}
delete(vc.Driver.Machines, name)
args := fmt.Sprintf("ps aux | grep %s | grep -v grep | awk '{print \"kill -9 \" $2}' | sh", name)
cmd := exec.Command("/bin/sh", "-c", args)
if err := cmd.Run(); err != nil {
ctx.Hub <- &hypervisor.VmKilledEvent{Success: false}
return
}
os.RemoveAll(path.Join(hypervisor.BaseDir, "vm", name))
}
ctx.Hub <- &hypervisor.VmKilledEvent{Success: true}
}()
}
示例2: CmdTty
func (daemon *Daemon) CmdTty(job *engine.Job) (err error) {
if len(job.Args) < 3 {
return nil
}
var (
podID = job.Args[0]
tag = job.Args[1]
h = job.Args[2]
w = job.Args[3]
container string
vmid string
)
if strings.Contains(podID, "pod-") {
container = ""
vmid, err = daemon.GetVmByPodId(podID)
if err != nil {
return err
}
} else if strings.Contains(podID, "vm-") {
vmid = podID
} else {
container = podID
podID, err = daemon.GetPodByContainer(container)
if err != nil {
return err
}
vmid, err = daemon.GetVmByPodId(podID)
if err != nil {
return err
}
}
vm, ok := daemon.VmList[vmid]
if !ok {
return fmt.Errorf("vm %s doesn't exist!")
}
row, err := strconv.Atoi(h)
if err != nil {
glog.Warningf("Window row %s incorrect!", h)
}
column, err := strconv.Atoi(w)
if err != nil {
glog.Warningf("Window column %s incorrect!", h)
}
err = vm.Tty(tag, row, column)
if err != nil {
return err
}
glog.V(1).Infof("Success to resize the tty!")
return nil
}
示例3: verifyContainerSettings
func (daemon *Daemon) verifyContainerSettings(hostConfig *runconfig.HostConfig) ([]string, error) {
var warnings []string
if hostConfig == nil {
return warnings, nil
}
if hostConfig.Memory != 0 && hostConfig.Memory < 4194304 {
return warnings, fmt.Errorf("Minimum memory limit allowed is 4MB")
}
if hostConfig.Memory > 0 && !daemon.SystemConfig().MemoryLimit {
warnings = append(warnings, "Your kernel does not support memory limit capabilities. Limitation discarded.")
glog.Warningf("Your kernel does not support memory limit capabilities. Limitation discarded.")
hostConfig.Memory = 0
}
if hostConfig.Memory > 0 && hostConfig.MemorySwap != -1 && !daemon.SystemConfig().SwapLimit {
warnings = append(warnings, "Your kernel does not support swap limit capabilities, memory limited without swap.")
glog.Warningf("Your kernel does not support swap limit capabilities, memory limited without swap.")
hostConfig.MemorySwap = -1
}
if hostConfig.Memory > 0 && hostConfig.MemorySwap > 0 && hostConfig.MemorySwap < hostConfig.Memory {
return warnings, fmt.Errorf("Minimum memoryswap limit should be larger than memory limit, see usage.")
}
if hostConfig.Memory == 0 && hostConfig.MemorySwap > 0 {
return warnings, fmt.Errorf("You should always set the Memory limit when using Memoryswap limit, see usage.")
}
if hostConfig.CpuPeriod > 0 && !daemon.SystemConfig().CpuCfsPeriod {
warnings = append(warnings, "Your kernel does not support CPU cfs period. Period discarded.")
glog.Warningf("Your kernel does not support CPU cfs period. Period discarded.")
hostConfig.CpuPeriod = 0
}
if hostConfig.CpuQuota > 0 && !daemon.SystemConfig().CpuCfsQuota {
warnings = append(warnings, "Your kernel does not support CPU cfs quota. Quota discarded.")
glog.Warningf("Your kernel does not support CPU cfs quota. Quota discarded.")
hostConfig.CpuQuota = 0
}
if hostConfig.BlkioWeight > 0 && (hostConfig.BlkioWeight < 10 || hostConfig.BlkioWeight > 1000) {
return warnings, fmt.Errorf("Range of blkio weight is from 10 to 1000.")
}
if hostConfig.OomKillDisable && !daemon.SystemConfig().OomKillDisable {
hostConfig.OomKillDisable = false
return warnings, fmt.Errorf("Your kernel does not support oom kill disable.")
}
if daemon.SystemConfig().IPv4ForwardingDisabled {
warnings = append(warnings, "IPv4 forwarding is disabled. Networking will not work.")
glog.Warningf("IPv4 forwarding is disabled. Networking will not work")
}
return warnings, nil
}
示例4: waitInitReady
func waitInitReady(ctx *VmContext) {
conn, err := UnixSocketConnect(ctx.HyperSockName)
if err != nil {
glog.Error("Cannot connect to hyper socket ", err.Error())
ctx.Hub <- &InitFailedEvent{
Reason: "Cannot connect to hyper socket " + err.Error(),
}
return
}
glog.Info("Wating for init messages...")
msg, err := readVmMessage(conn.(*net.UnixConn))
if err != nil {
glog.Error("read init message failed... ", err.Error())
ctx.Hub <- &InitFailedEvent{
Reason: "read init message failed... " + err.Error(),
}
conn.Close()
} else if msg.code == INIT_READY {
glog.Info("Get init ready message")
ctx.Hub <- &InitConnectedEvent{conn: conn.(*net.UnixConn)}
go waitCmdToInit(ctx, conn.(*net.UnixConn))
} else {
glog.Warningf("Get init message %d", msg.code)
ctx.Hub <- &InitFailedEvent{
Reason: fmt.Sprintf("Get init message %d", msg.code),
}
conn.Close()
}
}
示例5: makeHttpHandler
func makeHttpHandler(eng *engine.Engine, logging bool, localMethod string, localRoute string, handlerFunc HttpApiFunc, corsHeaders string, dockerVersion version.Version) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
// log the request
glog.V(0).Infof("Calling %s %s", localMethod, localRoute)
if logging {
glog.V(1).Infof("%s %s", r.Method, r.RequestURI)
}
if strings.Contains(r.Header.Get("User-Agent"), "Docker-Client/") {
userAgent := strings.Split(r.Header.Get("User-Agent"), "/")
if len(userAgent) == 2 && !dockerVersion.Equal(version.Version(userAgent[1])) {
glog.Warningf("client and server don't have the same version (client: %s, server: %s)", userAgent[1], dockerVersion)
}
}
version := version.Version(mux.Vars(r)["version"])
if version == "" {
version = utils.APIVERSION
}
if corsHeaders != "" {
writeCorsHeaders(w, r, corsHeaders)
}
if version.GreaterThan(utils.APIVERSION) {
http.Error(w, fmt.Errorf("client and server don't have same version (client API version: %s, server API version: %s)", version, utils.APIVERSION).Error(), http.StatusNotFound)
return
}
if err := handlerFunc(eng, version, w, r, mux.Vars(r)); err != nil {
glog.Errorf("Handler for %s %s returned error: %s", localMethod, localRoute, err)
httpError(w, err)
}
}
}
示例6: RemoveDir
func (vc *VBoxContext) RemoveDir(name string) error {
if err := vc.Machine.RemoveSharedFolder(vc.Machine.Name, name); err != nil {
glog.Warningf("The shared folder is failed to remove, since %s", err.Error())
return err
}
return nil
}
示例7: createDisk
func (d *Driver) createDisk(id, parent string) error {
// create a raw image
if _, err := os.Stat(fmt.Sprintf("%s/images/%s.vdi", d.RootPath(), id)); err == nil {
return nil
}
var (
parentDisk string = d.BaseImage()
idDisk string = fmt.Sprintf("%s/images/%s.vdi", d.RootPath(), id)
)
if parent != "" {
parentDisk = fmt.Sprintf("%s/images/%s.vdi", d.RootPath(), parent)
}
params := fmt.Sprintf("vboxmanage createhd --filename %s --diffparent %s --format VDI", idDisk, parentDisk)
cmd := exec.Command("/bin/sh", "-c", params)
if output, err := cmd.CombinedOutput(); err != nil {
glog.Warningf(string(output))
if strings.Contains(string(output), "not found in the media registry") {
if err := virtualbox.RegisterDisk(d.pullVm, d.pullVm, parentDisk, 4); err != nil {
return err
}
}
}
os.Chmod(idDisk, 0755)
params = fmt.Sprintf("vboxmanage closemedium %s", idDisk)
cmd = exec.Command("/bin/sh", "-c", params)
if output, err := cmd.CombinedOutput(); err != nil {
glog.Error(err.Error())
return fmt.Errorf("error to run vboxmanage closemedium, %s", output)
}
return nil
}
示例8: getUnderlyingAvailableSpace
func (devices *DeviceSet) getUnderlyingAvailableSpace(loopFile string) (uint64, error) {
buf := new(syscall.Statfs_t)
if err := syscall.Statfs(loopFile, buf); err != nil {
glog.Warningf("Couldn't stat loopfile filesystem %v: %v", loopFile, err)
return 0, err
}
return buf.Bfree * uint64(buf.Bsize), nil
}
示例9: Poweroff
// Poweroff forcefully stops the machine. State is lost and might corrupt the disk image.
func (m *Machine) Poweroff() error {
switch m.State {
case Poweroff, Aborted, Saved:
glog.Warningf("The machine status is Poweroff, Aborted, Saved")
return nil
}
return vbm("controlvm", m.Name, "poweroff")
}
示例10: Setup
func (d *Driver) Setup() (err error) {
var (
vm *hypervisor.Vm
ids []string
parentIds []string
)
if d.daemon == nil {
d.daemon, err = GetDaemon()
if err != nil {
return err
}
}
vm, err = d.daemon.StartVm(d.pullVm, 1, 64, false, types.VM_KEEP_AFTER_SHUTDOWN)
if err != nil {
glog.Errorf(err.Error())
return err
}
defer func() {
if err != nil {
d.daemon.KillVm(vm.Id)
}
}()
if err = d.daemon.WaitVmStart(vm); err != nil {
glog.Error(err)
return err
}
if err = virtualbox.RegisterDisk(d.pullVm, d.pullVm, d.BaseImage(), 4); err != nil {
glog.Errorf(err.Error())
return err
}
ids, err = loadIds(path.Join(d.RootPath(), "layers"))
if err != nil {
return err
}
for _, id := range ids {
if d.disks[id] == true {
continue
}
parentIds, err = getParentIds(d.RootPath(), id)
if err != nil {
glog.Warningf(err.Error())
continue
}
for _, cid := range parentIds {
if d.disks[cid] == true {
continue
}
d.Exists(cid)
d.disks[cid] = true
}
d.disks[id] = true
}
return nil
}
示例11: checkKernel
func checkKernel() error {
// Check for unsupported kernel versions
// FIXME: it would be cleaner to not test for specific versions, but rather
// test for specific functionalities.
// Unfortunately we can't test for the feature "does not cause a kernel panic"
// without actually causing a kernel panic, so we need this workaround until
// the circumstances of pre-3.10 crashes are clearer.
// For details see https://github.com/docker/docker/issues/407
if k, err := kernel.GetKernelVersion(); err != nil {
glog.Warningf("%s", err)
} else {
if kernel.CompareKernelVersion(k, &kernel.KernelVersionInfo{Kernel: 3, Major: 10, Minor: 0}) < 0 {
if os.Getenv("DOCKER_NOWARN_KERNEL_VERSION") == "" {
glog.Warningf("You are running linux kernel version %s, which might be unstable running docker. Please upgrade your kernel to 3.10.0.", k.String())
}
}
}
return nil
}
示例12: isRealFile
func (devices *DeviceSet) isRealFile(loopFile string) (bool, error) {
if loopFile != "" {
fi, err := os.Stat(loopFile)
if err != nil {
glog.Warningf("Couldn't stat loopfile %v: %v", loopFile, err)
return false, err
}
return fi.Mode().IsRegular(), nil
}
return false, nil
}
示例13: UmountVolume
func UmountVolume(shareDir, volPath string, name string, hub chan VmEvent) {
mount := path.Join(shareDir, volPath)
success := true
err := syscall.Unmount(mount, 0)
if err != nil {
glog.Warningf("Cannot umount volume %s: %s", mount, err.Error())
err = syscall.Unmount(mount, syscall.MNT_DETACH)
if err != nil {
glog.Warningf("Cannot lazy umount volume %s: %s", mount, err.Error())
success = false
} else {
success = true
}
}
if success == true {
os.Remove(mount)
}
// After umount that device, we need to delete it
hub <- &VolumeUnmounted{Name: name, Success: success}
}
示例14: Restore
func (daemon *Daemon) Restore() error {
if daemon.GetPodNum() == 0 {
return nil
}
podList := map[string]string{}
iter := daemon.db.NewIterator(util.BytesPrefix([]byte("pod-")), nil)
for iter.Next() {
key := iter.Key()
value := iter.Value()
if strings.Contains(string(key), "pod-container-") {
glog.V(1).Infof(string(value))
continue
}
glog.V(1).Infof("Get the pod item, pod is %s!", key)
err := daemon.db.Delete(key, nil)
if err != nil {
return err
}
podList[string(key)[4:]] = string(value)
}
iter.Release()
err := iter.Error()
if err != nil {
return err
}
daemon.PodList.Lock()
glog.V(2).Infof("lock PodList")
defer glog.V(2).Infof("unlock PodList")
defer daemon.PodList.Unlock()
for k, v := range podList {
err = daemon.CreatePod(k, v, false)
if err != nil {
glog.Warningf("Got a unexpected error, %s", err.Error())
continue
}
vmId, err := daemon.DbGetVmByPod(k)
if err != nil {
glog.V(1).Info(err.Error(), " for ", k)
continue
}
p, _ := daemon.PodList.Get(k)
if err := p.AssociateVm(daemon, string(vmId)); err != nil {
glog.V(1).Info("Some problem during associate vm %s to pod %s, %v", string(vmId), k, err)
// continue to next
}
}
return nil
}
示例15: CleanPod
func (daemon *Daemon) CleanPod(podId string) (int, string, error) {
var (
code = 0
cause = ""
err error
)
os.RemoveAll(path.Join(utils.HYPER_ROOT, "services", podId))
pod, ok := daemon.PodList.Get(podId)
if !ok {
return -1, "", fmt.Errorf("Can not find that Pod(%s)", podId)
}
if pod.status.Status != types.S_POD_RUNNING {
// If the pod type is kubernetes, we just remove the pod from the pod list.
// The persistent data has been removed since we got the E_VM_SHUTDOWN event.
if pod.status.Type == "kubernetes" {
daemon.RemovePod(podId)
code = types.E_OK
} else {
daemon.DeletePodFromDB(podId)
for _, c := range pod.status.Containers {
glog.V(1).Infof("Ready to rm container: %s", c.Id)
if _, _, err = daemon.DockerCli.SendCmdDelete(c.Id); err != nil {
glog.Warningf("Error to rm container: %s", err.Error())
}
}
daemon.RemovePod(podId)
daemon.DeletePodContainerFromDB(podId)
daemon.DeleteVolumeId(podId)
code = types.E_OK
}
} else {
code, cause, err = daemon.StopPod(podId, "yes")
if err != nil {
return -1, "", err
}
if code == types.E_VM_SHUTDOWN {
daemon.DeletePodFromDB(podId)
for _, c := range pod.status.Containers {
glog.V(1).Infof("Ready to rm container: %s", c.Id)
if _, _, err = daemon.DockerCli.SendCmdDelete(c.Id); err != nil {
glog.V(1).Infof("Error to rm container: %s", err.Error())
}
}
daemon.RemovePod(podId)
daemon.DeletePodContainerFromDB(podId)
daemon.DeleteVolumeId(podId)
}
code = types.E_OK
}
return code, cause, nil
}