feat(osd): node reset and reboot (#142)

This commit is contained in:
Andrew Rynhard 2018-08-23 18:11:21 -07:00 committed by GitHub
parent db0cb37ea1
commit 0514ff4c62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 395 additions and 50 deletions

View File

@ -122,10 +122,14 @@ func root() (err error) {
case constants.ContainerRuntimeCRIO: case constants.ContainerRuntimeCRIO:
services.Start(&service.CRIO{}) services.Start(&service.CRIO{})
default: default:
panic(fmt.Errorf("Unknown container runtime: %s", data.Services.Kubeadm.ContainerRuntime)) panic(fmt.Errorf("unknown container runtime: %s", data.Services.Kubeadm.ContainerRuntime))
} }
services.Start(&service.Kubelet{}) services.Start(&service.Kubelet{})
services.Start(&service.Kubeadm{})
if _, err := os.Stat("/etc/kubernetes/kubelet.conf"); os.IsNotExist(err) {
services.Start(&service.Kubeadm{})
}
return nil return nil
} }

View File

@ -56,6 +56,11 @@ func Hosts(s, hostname, ip string) (err error) {
if err := ioutil.WriteFile(path.Join(s, "/var/run/hosts"), writer.Bytes(), 0644); err != nil { if err := ioutil.WriteFile(path.Join(s, "/var/run/hosts"), writer.Bytes(), 0644); err != nil {
return fmt.Errorf("write /etc/hosts: %v", err) return fmt.Errorf("write /etc/hosts: %v", err)
} }
if _, err := os.Lstat(path.Join(s, "/etc/hosts")); err == nil {
if err = os.Remove(path.Join(s, "/etc/hosts")); err != nil {
return fmt.Errorf("remove symlink /etc/hosts: %v", err)
}
}
// The kubelet wants to manage /etc/hosts. Create a symlink there that // The kubelet wants to manage /etc/hosts. Create a symlink there that
// points to a writable file. // points to a writable file.
if err := os.Symlink("/var/run/hosts", path.Join(s, "/etc/hosts")); err != nil { if err := os.Symlink("/var/run/hosts", path.Join(s, "/etc/hosts")); err != nil {
@ -68,6 +73,11 @@ func Hosts(s, hostname, ip string) (err error) {
// ResolvConf symlinks /proc/net/pnp to /etc/resolv.conf. See // ResolvConf symlinks /proc/net/pnp to /etc/resolv.conf. See
// https://www.kernel.org/doc/Documentation/filesystems/nfs/nfsroot.txt. // https://www.kernel.org/doc/Documentation/filesystems/nfs/nfsroot.txt.
func ResolvConf(s string) (err error) { func ResolvConf(s string) (err error) {
if _, err = os.Lstat(path.Join(s, "/etc/resolv.conf")); err == nil {
if err = os.Remove(path.Join(s, "/etc/resolv.conf")); err != nil {
return fmt.Errorf("remove symlink /etc/hosts: %v", err)
}
}
if err = os.Symlink("/proc/net/pnp", path.Join(s, "/etc/resolv.conf")); err != nil { if err = os.Symlink("/proc/net/pnp", path.Join(s, "/etc/resolv.conf")); err != nil {
return return
} }

View File

@ -197,10 +197,12 @@ func (p *CRIO) Pre(data userdata.UserData) error {
} }
// Cmd implements the Service interface. // Cmd implements the Service interface.
func (p *CRIO) Cmd(data userdata.UserData, cmdArgs *CmdArgs) { func (p *CRIO) Cmd(data userdata.UserData, cmdArgs *CmdArgs) error {
cmdArgs.Name = "crio" cmdArgs.Name = "crio"
cmdArgs.Path = "/bin/crio" cmdArgs.Path = "/bin/crio"
cmdArgs.Args = []string{} cmdArgs.Args = []string{}
return nil
} }
// Condition implements the Service interface. // Condition implements the Service interface.

View File

@ -15,7 +15,7 @@ func (p *Docker) Pre(data userdata.UserData) error {
} }
// Cmd implements the Service interface. // Cmd implements the Service interface.
func (p *Docker) Cmd(data userdata.UserData, cmdArgs *CmdArgs) { func (p *Docker) Cmd(data userdata.UserData, cmdArgs *CmdArgs) error {
cmdArgs.Name = "docker" cmdArgs.Name = "docker"
cmdArgs.Path = "/bin/dockerd" cmdArgs.Path = "/bin/dockerd"
cmdArgs.Args = []string{ cmdArgs.Args = []string{
@ -28,6 +28,8 @@ func (p *Docker) Cmd(data userdata.UserData, cmdArgs *CmdArgs) {
"--log-opt=max-size=10m", "--log-opt=max-size=10m",
"--log-opt=max-file=3", "--log-opt=max-file=3",
} }
return nil
} }
// Condition implements the Service interface. // Condition implements the Service interface.

View File

@ -32,7 +32,7 @@ func (p *Kubeadm) Pre(data userdata.UserData) (err error) {
} }
// Cmd implements the Service interface. // Cmd implements the Service interface.
func (p *Kubeadm) Cmd(data userdata.UserData, cmdArgs *CmdArgs) { func (p *Kubeadm) Cmd(data userdata.UserData, cmdArgs *CmdArgs) error {
var cmd string var cmd string
if data.Services.Kubeadm.Init { if data.Services.Kubeadm.Init {
cmd = "init" cmd = "init"
@ -75,6 +75,8 @@ func (p *Kubeadm) Cmd(data userdata.UserData, cmdArgs *CmdArgs) {
if data.Services.Kubeadm.Init { if data.Services.Kubeadm.Init {
cmdArgs.Args = append(cmdArgs.Args, "--skip-token-print") cmdArgs.Args = append(cmdArgs.Args, "--skip-token-print")
} }
return nil
} }
// Condition implements the Service interface. // Condition implements the Service interface.

View File

@ -34,7 +34,7 @@ func (p *Kubelet) Pre(data userdata.UserData) error {
} }
// Cmd implements the Service interface. // Cmd implements the Service interface.
func (p *Kubelet) Cmd(data userdata.UserData, cmdArgs *CmdArgs) { func (p *Kubelet) Cmd(data userdata.UserData, cmdArgs *CmdArgs) error {
cmdArgs.Name = "kubelet" cmdArgs.Name = "kubelet"
cmdArgs.Path = "/bin/docker" cmdArgs.Path = "/bin/docker"
cmdArgs.Args = []string{ cmdArgs.Args = []string{
@ -71,7 +71,7 @@ func (p *Kubelet) Cmd(data userdata.UserData, cmdArgs *CmdArgs) {
fileBytes, err := ioutil.ReadFile("/var/lib/kubelet/kubeadm-flags.env") fileBytes, err := ioutil.ReadFile("/var/lib/kubelet/kubeadm-flags.env")
if err != nil { if err != nil {
panic(err) return err
} }
argsString := strings.TrimPrefix(string(fileBytes), "KUBELET_KUBEADM_ARGS=") argsString := strings.TrimPrefix(string(fileBytes), "KUBELET_KUBEADM_ARGS=")
argsString = strings.TrimSuffix(argsString, "\n") argsString = strings.TrimSuffix(argsString, "\n")
@ -84,6 +84,8 @@ func (p *Kubelet) Cmd(data userdata.UserData, cmdArgs *CmdArgs) {
cmdArgs.Args = append(cmdArgs.Args, "--container-runtime=remote", "--container-runtime-endpoint=unix:///var/run/crio/crio.sock") cmdArgs.Args = append(cmdArgs.Args, "--container-runtime=remote", "--container-runtime-endpoint=unix:///var/run/crio/crio.sock")
default: default:
} }
return nil
} }
// Condition implements the Service interface. // Condition implements the Service interface.

View File

@ -17,7 +17,7 @@ func (p *OSD) Pre(data userdata.UserData) error {
} }
// Cmd implements the Service interface. // Cmd implements the Service interface.
func (p *OSD) Cmd(data userdata.UserData, cmdArgs *CmdArgs) { func (p *OSD) Cmd(data userdata.UserData, cmdArgs *CmdArgs) error {
cmdArgs.Name = "osd" cmdArgs.Name = "osd"
cmdArgs.Path = "/bin/osd" cmdArgs.Path = "/bin/osd"
cmdArgs.Args = []string{ cmdArgs.Args = []string{
@ -28,6 +28,8 @@ func (p *OSD) Cmd(data userdata.UserData, cmdArgs *CmdArgs) {
if !data.Services.Kubeadm.Init { if !data.Services.Kubeadm.Init {
cmdArgs.Args = append(cmdArgs.Args, "--generate=true") cmdArgs.Args = append(cmdArgs.Args, "--generate=true")
} }
return nil
} }
// Condition implements the Service interface. // Condition implements the Service interface.

View File

@ -16,10 +16,12 @@ func (p *ProxyD) Pre(data userdata.UserData) error {
} }
// Cmd implements the Service interface. // Cmd implements the Service interface.
func (p *ProxyD) Cmd(data userdata.UserData, cmdArgs *CmdArgs) { func (p *ProxyD) Cmd(data userdata.UserData, cmdArgs *CmdArgs) error {
cmdArgs.Name = "proxyd" cmdArgs.Name = "proxyd"
cmdArgs.Path = "/bin/proxyd" cmdArgs.Path = "/bin/proxyd"
cmdArgs.Args = []string{} cmdArgs.Args = []string{}
return nil
} }
// Condition implements the Service interface. // Condition implements the Service interface.

View File

@ -17,13 +17,15 @@ func (p *ROTD) Pre(data userdata.UserData) error {
} }
// Cmd implements the Service interface. // Cmd implements the Service interface.
func (p *ROTD) Cmd(data userdata.UserData, cmdArgs *CmdArgs) { func (p *ROTD) Cmd(data userdata.UserData, cmdArgs *CmdArgs) error {
cmdArgs.Name = "rotd" cmdArgs.Name = "rotd"
cmdArgs.Path = "/bin/rotd" cmdArgs.Path = "/bin/rotd"
cmdArgs.Args = []string{ cmdArgs.Args = []string{
"--port=50001", "--port=50001",
"--userdata=" + constants.UserDataPath, "--userdata=" + constants.UserDataPath,
} }
return nil
} }
// Condition implements the Service interface. // Condition implements the Service interface.

View File

@ -31,7 +31,7 @@ type Service interface {
Pre(userdata.UserData) error Pre(userdata.UserData) error
// Cmd describes the path to the binary, and the set of arguments to be // Cmd describes the path to the binary, and the set of arguments to be
// passed into it upon execution. // passed into it upon execution.
Cmd(userdata.UserData, *CmdArgs) Cmd(userdata.UserData, *CmdArgs) error
// Condition is invoked just before starting the process. // Condition is invoked just before starting the process.
Condition(userdata.UserData) func() (bool, error) Condition(userdata.UserData) func() (bool, error)
// Env describes the service's environment variables. Elements should be in // Env describes the service's environment variables. Elements should be in
@ -58,7 +58,10 @@ type CmdArgs struct {
func (m *Manager) build(proc Service) (cmd *exec.Cmd, err error) { func (m *Manager) build(proc Service) (cmd *exec.Cmd, err error) {
cmdArgs := &CmdArgs{} cmdArgs := &CmdArgs{}
// Build the exec.Cmd // Build the exec.Cmd
proc.Cmd(m.UserData, cmdArgs) if err = proc.Cmd(m.UserData, cmdArgs); err != nil {
err = fmt.Errorf("new command: %v", err)
return
}
cmd = exec.Command(cmdArgs.Path, cmdArgs.Args...) cmd = exec.Command(cmdArgs.Path, cmdArgs.Args...)
// Set the environment for the service. // Set the environment for the service.
@ -117,14 +120,20 @@ func (m *Manager) Start(proc Service) {
func (m *Manager) waitAndRestart(proc Service) (err error) { func (m *Manager) waitAndRestart(proc Service) (err error) {
cmd, err := m.build(proc) cmd, err := m.build(proc)
if err != nil { if err != nil {
return log.Printf("%v", err)
time.Sleep(5 * time.Second)
return m.waitAndRestart(proc)
} }
if err = cmd.Start(); err != nil { if err = cmd.Start(); err != nil {
return log.Printf("%v", err)
time.Sleep(5 * time.Second)
return m.waitAndRestart(proc)
} }
state, err := cmd.Process.Wait() state, err := cmd.Process.Wait()
if err != nil { if err != nil {
return log.Printf("%v", err)
time.Sleep(5 * time.Second)
return m.waitAndRestart(proc)
} }
if state.Exited() { if state.Exited() {
time.Sleep(5 * time.Second) time.Sleep(5 * time.Second)

View File

@ -0,0 +1,36 @@
package cmd
import (
"fmt"
"os"
"github.com/autonomy/dianemo/src/initramfs/cmd/osctl/pkg/client"
"github.com/spf13/cobra"
)
// rebootCmd represents the reboot command
var rebootCmd = &cobra.Command{
Use: "reboot",
Short: "Reboot a node",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
creds, err := client.NewDefaultClientCredentials()
if err != nil {
fmt.Println(err)
os.Exit(1)
}
c, err := client.NewClient(port, creds)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
if err := c.Reboot(); err != nil {
fmt.Println(err)
os.Exit(1)
}
},
}
func init() {
rootCmd.AddCommand(rebootCmd)
}

View File

@ -0,0 +1,36 @@
package cmd
import (
"fmt"
"os"
"github.com/autonomy/dianemo/src/initramfs/cmd/osctl/pkg/client"
"github.com/spf13/cobra"
)
// resetCmd represents the reset command
var resetCmd = &cobra.Command{
Use: "reset",
Short: "Reset a node",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
creds, err := client.NewDefaultClientCredentials()
if err != nil {
fmt.Println(err)
os.Exit(1)
}
c, err := client.NewClient(port, creds)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
if err := c.Reset(); err != nil {
fmt.Println(err)
os.Exit(1)
}
},
}
func init() {
rootCmd.AddCommand(resetCmd)
}

View File

@ -2,7 +2,6 @@ package cmd
import ( import (
"fmt" "fmt"
"log"
"os" "os"
"github.com/autonomy/dianemo/src/initramfs/cmd/osctl/pkg/client" "github.com/autonomy/dianemo/src/initramfs/cmd/osctl/pkg/client"
@ -14,7 +13,7 @@ var (
timeout int32 timeout int32
) )
// restartCmd represents the processes command // restartCmd represents the restart command
var restartCmd = &cobra.Command{ var restartCmd = &cobra.Command{
Use: "restart", Use: "restart",
Short: "Restart a process", Short: "Restart a process",
@ -33,13 +32,15 @@ var restartCmd = &cobra.Command{
} }
c, err := client.NewClient(port, creds) c, err := client.NewClient(port, creds)
if err != nil { if err != nil {
log.Fatal(err) fmt.Println(err)
os.Exit(1)
} }
r := &proto.RestartRequest{ r := &proto.RestartRequest{
Id: args[0], Id: args[0],
Timeout: timeout, Timeout: timeout,
} }
if err := c.Restart(r); err != nil { if err := c.Restart(r); err != nil {
fmt.Println(err)
os.Exit(1) os.Exit(1)
} }
}, },

View File

@ -140,6 +140,28 @@ func (c *Client) Restart(r *proto.RestartRequest) (err error) {
return nil return nil
} }
// Reset implements the proto.OSDClient interface.
func (c *Client) Reset() (err error) {
ctx := context.Background()
_, err = c.client.Reset(ctx, &empty.Empty{})
if err != nil {
return
}
return nil
}
// Reboot implements the proto.OSDClient interface.
func (c *Client) Reboot() (err error) {
ctx := context.Background()
_, err = c.client.Reboot(ctx, &empty.Empty{})
if err != nil {
return
}
return nil
}
// Dmesg implements the proto.OSDClient interface. // Dmesg implements the proto.OSDClient interface.
// nolint: dupl // nolint: dupl
func (c *Client) Dmesg() (err error) { func (c *Client) Dmesg() (err error) {

View File

@ -7,6 +7,7 @@ import (
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"os" "os"
"os/exec"
"strings" "strings"
"time" "time"
@ -97,6 +98,78 @@ func (r *Registrator) Restart(ctx context.Context, in *proto.RestartRequest) (re
return return
} }
// Reset implements the proto.OSDServer interface.
func (r *Registrator) Reset(ctx context.Context, in *empty.Empty) (reply *proto.ResetReply, err error) {
{
cmd := exec.Command("/bin/docker", "stop", "kubelet")
// Set the environment for the service.
cmd.Env = []string{fmt.Sprintf("PATH=%s", constants.PATH)}
if err = cmd.Start(); err != nil {
return
}
_, err = cmd.Process.Wait()
if err != nil {
return
}
}
args := []string{
"run",
"--rm",
"--net=host",
"--pid=host",
"--privileged",
"--volume=/sys:/sys:rw",
"--volume=/sys/fs/cgroup:/sys/fs/cgroup:rw",
"--volume=/var/run:/var/run:rw",
"--volume=/run:/run:rw",
"--volume=/var/lib/docker:/var/lib/docker:rw",
"--volume=/var/lib/kubelet:/var/lib/kubelet:slave",
"--volume=/var/log:/var/log",
"--volume=/etc/kubernetes:/etc/kubernetes:shared",
"--volume=/etc/os-release:/etc/os-release:ro",
"--volume=/lib/modules:/lib/modules:ro",
"--volume=/bin/docker:/bin/docker:ro",
"--volume=/bin/crictl:/bin/crictl:ro",
"--volume=/bin/kubeadm:/bin/kubeadm:ro",
"--name=kubeadm",
"gcr.io/google_containers/hyperkube:v1.11.2",
"/bin/kubeadm",
"reset",
"--force",
}
// Build the exec.Cmd
cmd := exec.Command("/bin/docker", args...)
// Set the environment for the service.
cmd.Env = []string{fmt.Sprintf("PATH=%s", constants.PATH)}
if err = cmd.Start(); err != nil {
return
}
_, err = cmd.Process.Wait()
if err != nil {
return
}
reply = &proto.ResetReply{}
return
}
// Reboot implements the proto.OSDServer interface.
func (r *Registrator) Reboot(ctx context.Context, in *empty.Empty) (reply *proto.RebootReply, err error) {
unix.Reboot(int(unix.LINUX_REBOOT_CMD_RESTART))
reply = &proto.RebootReply{}
return
}
// Dmesg implements the proto.OSDServer interface. The klogctl syscall is used // Dmesg implements the proto.OSDServer interface. The klogctl syscall is used
// to read from the ring buffer at /proc/kmsg by taking the // to read from the ring buffer at /proc/kmsg by taking the
// SYSLOG_ACTION_READ_ALL action. This action reads all messages remaining in // SYSLOG_ACTION_READ_ALL action. This action reads all messages remaining in

View File

@ -36,7 +36,7 @@ func (m *ProcessesReply) Reset() { *m = ProcessesReply{} }
func (m *ProcessesReply) String() string { return proto.CompactTextString(m) } func (m *ProcessesReply) String() string { return proto.CompactTextString(m) }
func (*ProcessesReply) ProtoMessage() {} func (*ProcessesReply) ProtoMessage() {}
func (*ProcessesReply) Descriptor() ([]byte, []int) { func (*ProcessesReply) Descriptor() ([]byte, []int) {
return fileDescriptor_api_682c95cee7fe52e8, []int{0} return fileDescriptor_api_b55c1a69b0d04a74, []int{0}
} }
func (m *ProcessesReply) XXX_Unmarshal(b []byte) error { func (m *ProcessesReply) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_ProcessesReply.Unmarshal(m, b) return xxx_messageInfo_ProcessesReply.Unmarshal(m, b)
@ -78,7 +78,7 @@ func (m *Process) Reset() { *m = Process{} }
func (m *Process) String() string { return proto.CompactTextString(m) } func (m *Process) String() string { return proto.CompactTextString(m) }
func (*Process) ProtoMessage() {} func (*Process) ProtoMessage() {}
func (*Process) Descriptor() ([]byte, []int) { func (*Process) Descriptor() ([]byte, []int) {
return fileDescriptor_api_682c95cee7fe52e8, []int{1} return fileDescriptor_api_b55c1a69b0d04a74, []int{1}
} }
func (m *Process) XXX_Unmarshal(b []byte) error { func (m *Process) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Process.Unmarshal(m, b) return xxx_messageInfo_Process.Unmarshal(m, b)
@ -139,7 +139,7 @@ func (m *RestartRequest) Reset() { *m = RestartRequest{} }
func (m *RestartRequest) String() string { return proto.CompactTextString(m) } func (m *RestartRequest) String() string { return proto.CompactTextString(m) }
func (*RestartRequest) ProtoMessage() {} func (*RestartRequest) ProtoMessage() {}
func (*RestartRequest) Descriptor() ([]byte, []int) { func (*RestartRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_api_682c95cee7fe52e8, []int{2} return fileDescriptor_api_b55c1a69b0d04a74, []int{2}
} }
func (m *RestartRequest) XXX_Unmarshal(b []byte) error { func (m *RestartRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_RestartRequest.Unmarshal(m, b) return xxx_messageInfo_RestartRequest.Unmarshal(m, b)
@ -184,7 +184,7 @@ func (m *RestartReply) Reset() { *m = RestartReply{} }
func (m *RestartReply) String() string { return proto.CompactTextString(m) } func (m *RestartReply) String() string { return proto.CompactTextString(m) }
func (*RestartReply) ProtoMessage() {} func (*RestartReply) ProtoMessage() {}
func (*RestartReply) Descriptor() ([]byte, []int) { func (*RestartReply) Descriptor() ([]byte, []int) {
return fileDescriptor_api_682c95cee7fe52e8, []int{3} return fileDescriptor_api_b55c1a69b0d04a74, []int{3}
} }
func (m *RestartReply) XXX_Unmarshal(b []byte) error { func (m *RestartReply) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_RestartReply.Unmarshal(m, b) return xxx_messageInfo_RestartReply.Unmarshal(m, b)
@ -204,6 +204,68 @@ func (m *RestartReply) XXX_DiscardUnknown() {
var xxx_messageInfo_RestartReply proto.InternalMessageInfo var xxx_messageInfo_RestartReply proto.InternalMessageInfo
// The response message containing the restart status.
type ResetReply struct {
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *ResetReply) Reset() { *m = ResetReply{} }
func (m *ResetReply) String() string { return proto.CompactTextString(m) }
func (*ResetReply) ProtoMessage() {}
func (*ResetReply) Descriptor() ([]byte, []int) {
return fileDescriptor_api_b55c1a69b0d04a74, []int{4}
}
func (m *ResetReply) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_ResetReply.Unmarshal(m, b)
}
func (m *ResetReply) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_ResetReply.Marshal(b, m, deterministic)
}
func (dst *ResetReply) XXX_Merge(src proto.Message) {
xxx_messageInfo_ResetReply.Merge(dst, src)
}
func (m *ResetReply) XXX_Size() int {
return xxx_messageInfo_ResetReply.Size(m)
}
func (m *ResetReply) XXX_DiscardUnknown() {
xxx_messageInfo_ResetReply.DiscardUnknown(m)
}
var xxx_messageInfo_ResetReply proto.InternalMessageInfo
// The response message containing the restart status.
type RebootReply struct {
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *RebootReply) Reset() { *m = RebootReply{} }
func (m *RebootReply) String() string { return proto.CompactTextString(m) }
func (*RebootReply) ProtoMessage() {}
func (*RebootReply) Descriptor() ([]byte, []int) {
return fileDescriptor_api_b55c1a69b0d04a74, []int{5}
}
func (m *RebootReply) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_RebootReply.Unmarshal(m, b)
}
func (m *RebootReply) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_RebootReply.Marshal(b, m, deterministic)
}
func (dst *RebootReply) XXX_Merge(src proto.Message) {
xxx_messageInfo_RebootReply.Merge(dst, src)
}
func (m *RebootReply) XXX_Size() int {
return xxx_messageInfo_RebootReply.Size(m)
}
func (m *RebootReply) XXX_DiscardUnknown() {
xxx_messageInfo_RebootReply.DiscardUnknown(m)
}
var xxx_messageInfo_RebootReply proto.InternalMessageInfo
// The request message containing the process name. // The request message containing the process name.
type LogsRequest struct { type LogsRequest struct {
Process string `protobuf:"bytes,1,opt,name=process,proto3" json:"process,omitempty"` Process string `protobuf:"bytes,1,opt,name=process,proto3" json:"process,omitempty"`
@ -217,7 +279,7 @@ func (m *LogsRequest) Reset() { *m = LogsRequest{} }
func (m *LogsRequest) String() string { return proto.CompactTextString(m) } func (m *LogsRequest) String() string { return proto.CompactTextString(m) }
func (*LogsRequest) ProtoMessage() {} func (*LogsRequest) ProtoMessage() {}
func (*LogsRequest) Descriptor() ([]byte, []int) { func (*LogsRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_api_682c95cee7fe52e8, []int{4} return fileDescriptor_api_b55c1a69b0d04a74, []int{6}
} }
func (m *LogsRequest) XXX_Unmarshal(b []byte) error { func (m *LogsRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_LogsRequest.Unmarshal(m, b) return xxx_messageInfo_LogsRequest.Unmarshal(m, b)
@ -263,7 +325,7 @@ func (m *Data) Reset() { *m = Data{} }
func (m *Data) String() string { return proto.CompactTextString(m) } func (m *Data) String() string { return proto.CompactTextString(m) }
func (*Data) ProtoMessage() {} func (*Data) ProtoMessage() {}
func (*Data) Descriptor() ([]byte, []int) { func (*Data) Descriptor() ([]byte, []int) {
return fileDescriptor_api_682c95cee7fe52e8, []int{5} return fileDescriptor_api_b55c1a69b0d04a74, []int{7}
} }
func (m *Data) XXX_Unmarshal(b []byte) error { func (m *Data) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Data.Unmarshal(m, b) return xxx_messageInfo_Data.Unmarshal(m, b)
@ -295,6 +357,8 @@ func init() {
proto.RegisterType((*Process)(nil), "proto.Process") proto.RegisterType((*Process)(nil), "proto.Process")
proto.RegisterType((*RestartRequest)(nil), "proto.RestartRequest") proto.RegisterType((*RestartRequest)(nil), "proto.RestartRequest")
proto.RegisterType((*RestartReply)(nil), "proto.RestartReply") proto.RegisterType((*RestartReply)(nil), "proto.RestartReply")
proto.RegisterType((*ResetReply)(nil), "proto.ResetReply")
proto.RegisterType((*RebootReply)(nil), "proto.RebootReply")
proto.RegisterType((*LogsRequest)(nil), "proto.LogsRequest") proto.RegisterType((*LogsRequest)(nil), "proto.LogsRequest")
proto.RegisterType((*Data)(nil), "proto.Data") proto.RegisterType((*Data)(nil), "proto.Data")
} }
@ -314,6 +378,8 @@ type OSDClient interface {
Kubeconfig(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*Data, error) Kubeconfig(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*Data, error)
Processes(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*ProcessesReply, error) Processes(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*ProcessesReply, error)
Restart(ctx context.Context, in *RestartRequest, opts ...grpc.CallOption) (*RestartReply, error) Restart(ctx context.Context, in *RestartRequest, opts ...grpc.CallOption) (*RestartReply, error)
Reset(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*ResetReply, error)
Reboot(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*RebootReply, error)
Logs(ctx context.Context, in *LogsRequest, opts ...grpc.CallOption) (OSD_LogsClient, error) Logs(ctx context.Context, in *LogsRequest, opts ...grpc.CallOption) (OSD_LogsClient, error)
Dmesg(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*Data, error) Dmesg(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*Data, error)
Version(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*Data, error) Version(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*Data, error)
@ -354,6 +420,24 @@ func (c *oSDClient) Restart(ctx context.Context, in *RestartRequest, opts ...grp
return out, nil return out, nil
} }
func (c *oSDClient) Reset(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*ResetReply, error) {
out := new(ResetReply)
err := c.cc.Invoke(ctx, "/proto.OSD/Reset", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *oSDClient) Reboot(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*RebootReply, error) {
out := new(RebootReply)
err := c.cc.Invoke(ctx, "/proto.OSD/Reboot", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *oSDClient) Logs(ctx context.Context, in *LogsRequest, opts ...grpc.CallOption) (OSD_LogsClient, error) { func (c *oSDClient) Logs(ctx context.Context, in *LogsRequest, opts ...grpc.CallOption) (OSD_LogsClient, error) {
stream, err := c.cc.NewStream(ctx, &_OSD_serviceDesc.Streams[0], "/proto.OSD/Logs", opts...) stream, err := c.cc.NewStream(ctx, &_OSD_serviceDesc.Streams[0], "/proto.OSD/Logs", opts...)
if err != nil { if err != nil {
@ -409,6 +493,8 @@ type OSDServer interface {
Kubeconfig(context.Context, *empty.Empty) (*Data, error) Kubeconfig(context.Context, *empty.Empty) (*Data, error)
Processes(context.Context, *empty.Empty) (*ProcessesReply, error) Processes(context.Context, *empty.Empty) (*ProcessesReply, error)
Restart(context.Context, *RestartRequest) (*RestartReply, error) Restart(context.Context, *RestartRequest) (*RestartReply, error)
Reset(context.Context, *empty.Empty) (*ResetReply, error)
Reboot(context.Context, *empty.Empty) (*RebootReply, error)
Logs(*LogsRequest, OSD_LogsServer) error Logs(*LogsRequest, OSD_LogsServer) error
Dmesg(context.Context, *empty.Empty) (*Data, error) Dmesg(context.Context, *empty.Empty) (*Data, error)
Version(context.Context, *empty.Empty) (*Data, error) Version(context.Context, *empty.Empty) (*Data, error)
@ -472,6 +558,42 @@ func _OSD_Restart_Handler(srv interface{}, ctx context.Context, dec func(interfa
return interceptor(ctx, in, info, handler) return interceptor(ctx, in, info, handler)
} }
func _OSD_Reset_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(empty.Empty)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(OSDServer).Reset(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/proto.OSD/Reset",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(OSDServer).Reset(ctx, req.(*empty.Empty))
}
return interceptor(ctx, in, info, handler)
}
func _OSD_Reboot_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(empty.Empty)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(OSDServer).Reboot(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/proto.OSD/Reboot",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(OSDServer).Reboot(ctx, req.(*empty.Empty))
}
return interceptor(ctx, in, info, handler)
}
func _OSD_Logs_Handler(srv interface{}, stream grpc.ServerStream) error { func _OSD_Logs_Handler(srv interface{}, stream grpc.ServerStream) error {
m := new(LogsRequest) m := new(LogsRequest)
if err := stream.RecvMsg(m); err != nil { if err := stream.RecvMsg(m); err != nil {
@ -545,6 +667,14 @@ var _OSD_serviceDesc = grpc.ServiceDesc{
MethodName: "Restart", MethodName: "Restart",
Handler: _OSD_Restart_Handler, Handler: _OSD_Restart_Handler,
}, },
{
MethodName: "Reset",
Handler: _OSD_Reset_Handler,
},
{
MethodName: "Reboot",
Handler: _OSD_Reboot_Handler,
},
{ {
MethodName: "Dmesg", MethodName: "Dmesg",
Handler: _OSD_Dmesg_Handler, Handler: _OSD_Dmesg_Handler,
@ -564,31 +694,33 @@ var _OSD_serviceDesc = grpc.ServiceDesc{
Metadata: "api.proto", Metadata: "api.proto",
} }
func init() { proto.RegisterFile("api.proto", fileDescriptor_api_682c95cee7fe52e8) } func init() { proto.RegisterFile("api.proto", fileDescriptor_api_b55c1a69b0d04a74) }
var fileDescriptor_api_682c95cee7fe52e8 = []byte{ var fileDescriptor_api_b55c1a69b0d04a74 = []byte{
// 364 bytes of a gzipped FileDescriptorProto // 400 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x51, 0x41, 0xcf, 0x9a, 0x40, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x51, 0x41, 0x6b, 0xd4, 0x40,
0x14, 0x14, 0x04, 0x29, 0x4f, 0xc3, 0xe1, 0xb5, 0x35, 0xc4, 0x7a, 0x30, 0x7b, 0x32, 0x69, 0x83, 0x18, 0xdd, 0x6c, 0x92, 0x8d, 0xf9, 0xb2, 0x06, 0xfc, 0xd4, 0x12, 0xd6, 0x1e, 0xca, 0x9c, 0x0a,
0x46, 0x0f, 0x4d, 0x9a, 0xa6, 0x27, 0x3d, 0xb5, 0x49, 0x9b, 0x6d, 0xd2, 0x4b, 0x4f, 0xa0, 0x4f, 0x4a, 0x5a, 0x5a, 0x51, 0x10, 0xf1, 0xb4, 0x3d, 0x29, 0x28, 0x23, 0x78, 0xf1, 0x94, 0x6c, 0xbf,
0x42, 0x22, 0x2c, 0x65, 0x97, 0x03, 0xff, 0xae, 0x3f, 0xed, 0x0b, 0xcb, 0xa2, 0x9f, 0x7e, 0xf9, 0x86, 0xc0, 0x26, 0x13, 0x33, 0x93, 0x43, 0xfe, 0x94, 0xbf, 0x51, 0x32, 0x33, 0x49, 0xec, 0x96,
0x12, 0x4f, 0xec, 0x0c, 0x33, 0x6f, 0xf7, 0xcd, 0x80, 0x1f, 0x97, 0x59, 0x54, 0x56, 0x42, 0x09, 0x85,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0xd4, 0x86, 0x93, 0x6d, 0x1e, 0x61, 0x81,
0x00, 0x00, 0xff, 0xff, 0x41, 0xa8, 0x42, 0xcb, 0xc8, 0x02, 0x00, 0x00, 0x6f, 0xc1, 0x1b, 0x66, 0xc0, 0xf1, 0xef, 0x7f, 0x9b, 0x1c, 0xf4, 0x71, 0xed, 0x60, 0x0a, 0xfe,
0xb6, 0x22, 0x79, 0x72, 0x83, 0xd7, 0x10, 0xfc, 0xa2, 0x56, 0x96, 0xa2, 0x3e, 0xd1, 0x91, 0xaf,
0x34, 0xba, 0xfd, 0x17, 0x00, 0x00, 0xff, 0xff, 0xb4, 0x9c, 0x7e, 0x60, 0x53, 0x03, 0x00, 0x00,
} }

View File

@ -10,6 +10,8 @@ service OSD {
rpc Kubeconfig(google.protobuf.Empty) returns (Data) {} rpc Kubeconfig(google.protobuf.Empty) returns (Data) {}
rpc Processes(google.protobuf.Empty) returns (ProcessesReply) {} rpc Processes(google.protobuf.Empty) returns (ProcessesReply) {}
rpc Restart(RestartRequest) returns (RestartReply) {} rpc Restart(RestartRequest) returns (RestartReply) {}
rpc Reset(google.protobuf.Empty) returns (ResetReply) {}
rpc Reboot(google.protobuf.Empty) returns (RebootReply) {}
rpc Logs(LogsRequest) returns (stream Data) {} rpc Logs(LogsRequest) returns (stream Data) {}
rpc Dmesg(google.protobuf.Empty) returns (Data) {} rpc Dmesg(google.protobuf.Empty) returns (Data) {}
rpc Version(google.protobuf.Empty) returns (Data) {} rpc Version(google.protobuf.Empty) returns (Data) {}
@ -37,6 +39,12 @@ message RestartRequest {
// The response message containing the restart status. // The response message containing the restart status.
message RestartReply {} message RestartReply {}
// The response message containing the restart status.
message ResetReply {}
// The response message containing the restart status.
message RebootReply {}
// The request message containing the process name. // The request message containing the process name.
message LogsRequest { message LogsRequest {
string process = 1; string process = 1;