debug

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

README

gNOI Debug Streaming RPC Design

Contributors: hines@google.com, robjs@google.com Last Updated: 2023-11-04

Background

For all legacy devices that provided a CLI on box, providers have leveraged this CLI through services to provide users with the ability to interact with device CLI's to both get information as well as set operational state on devices. This interaction is very vendor specific and requires significant overhead to maintain the vendor specific bindings throughout the operational life cycle of a device.

With the introduction of g* services, the goal has been to remove vendor specific data formats from the view operators. This lets operators have standard models for interacting with any number of vendor devices consistently. There however are gaps between those endpoints versioning and the ability to troubleshoot specific data on a device before API's can be updated. This proposal is to enable a lightweight interface via gRPC to still access shell level interactions on the device in a secure, maintainable way.

Architecture

The service will run on a specified port. This service upon recieving a command the server will validate the user has access to the service via Authz check. If user has access the server will then parse the request and check if the user has both the acccess to run the command and if provided act as the role user. If the user is allowed the device will then open "shell" in the mode requested and execute the command in that mode.

User Experience

User needs to get custom state from device

User Request -> Stream of data returned

Example requests are CLI ‘show’ commands. Ie:

show proc cpu | json

User needs to be able to shell to subcomponent (linecard / backup supervisor) to get data

shell <linecard>; show memory

User needs to tail a process to get output

tail -f /var/log/foo

User needs to capture a trace of process

strace <cmd>

Documentation

Index

Constants

View Source
const (
	Debug_Debug_FullMethodName = "/gnoi.debug.Debug/Debug"
)

Variables

View Source
var (
	DebugRequest_Mode_name = map[int32]string{
		0: "MODE_UNSPECIFIED",
		1: "MODE_SHELL",
		2: "MODE_CLI",
	}
	DebugRequest_Mode_value = map[string]int32{
		"MODE_UNSPECIFIED": 0,
		"MODE_SHELL":       1,
		"MODE_CLI":         2,
	}
)

Enum value maps for DebugRequest_Mode.

View Source
var Debug_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "gnoi.debug.Debug",
	HandlerType: (*DebugServer)(nil),
	Methods:     []grpc.MethodDesc{},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "Debug",
			Handler:       _Debug_Debug_Handler,
			ServerStreams: true,
		},
	},
	Metadata: "github.com/openconfig/gnoi/debug/debug.proto",
}

Debug_ServiceDesc is the grpc.ServiceDesc for Debug service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

View Source
var File_github_com_openconfig_gnoi_debug_debug_proto protoreflect.FileDescriptor

Functions

func RegisterDebugServer

func RegisterDebugServer(s grpc.ServiceRegistrar, srv DebugServer)

Types

type DebugClient

type DebugClient interface {
	Debug(ctx context.Context, in *DebugRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[DebugResponse], error)
}

DebugClient is the client API for Debug service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

func NewDebugClient

func NewDebugClient(cc grpc.ClientConnInterface) DebugClient

type DebugRequest

type DebugRequest struct {
	Mode        DebugRequest_Mode `protobuf:"varint,1,opt,name=mode,proto3,enum=gnoi.debug.DebugRequest_Mode" json:"mode,omitempty"`
	Command     []byte            `protobuf:"bytes,2,opt,name=command,proto3" json:"command,omitempty"`
	ByteLimit   int64             `protobuf:"varint,3,opt,name=byte_limit,json=byteLimit,proto3" json:"byte_limit,omitempty"`
	Timeout     int64             `protobuf:"varint,4,opt,name=timeout,proto3" json:"timeout,omitempty"`
	RoleAccount string            `protobuf:"bytes,5,opt,name=role_account,json=roleAccount,proto3" json:"role_account,omitempty"`
	// contains filtered or unexported fields
}

func (*DebugRequest) Descriptor deprecated

func (*DebugRequest) Descriptor() ([]byte, []int)

Deprecated: Use DebugRequest.ProtoReflect.Descriptor instead.

func (*DebugRequest) GetByteLimit

func (x *DebugRequest) GetByteLimit() int64

func (*DebugRequest) GetCommand

func (x *DebugRequest) GetCommand() []byte

func (*DebugRequest) GetMode

func (x *DebugRequest) GetMode() DebugRequest_Mode

func (*DebugRequest) GetRoleAccount

func (x *DebugRequest) GetRoleAccount() string

func (*DebugRequest) GetTimeout

func (x *DebugRequest) GetTimeout() int64

func (*DebugRequest) ProtoMessage

func (*DebugRequest) ProtoMessage()

func (*DebugRequest) ProtoReflect

func (x *DebugRequest) ProtoReflect() protoreflect.Message

func (*DebugRequest) Reset

func (x *DebugRequest) Reset()

func (*DebugRequest) String

func (x *DebugRequest) String() string

type DebugRequest_Mode

type DebugRequest_Mode int32
const (
	DebugRequest_MODE_UNSPECIFIED DebugRequest_Mode = 0
	DebugRequest_MODE_SHELL       DebugRequest_Mode = 1
	DebugRequest_MODE_CLI         DebugRequest_Mode = 2
)

func (DebugRequest_Mode) Descriptor

func (DebugRequest_Mode) Enum

func (DebugRequest_Mode) EnumDescriptor deprecated

func (DebugRequest_Mode) EnumDescriptor() ([]byte, []int)

Deprecated: Use DebugRequest_Mode.Descriptor instead.

func (DebugRequest_Mode) Number

func (DebugRequest_Mode) String

func (x DebugRequest_Mode) String() string

func (DebugRequest_Mode) Type

type DebugResponse

type DebugResponse struct {

	// Types that are valid to be assigned to Response:
	//
	//	*DebugResponse_Request
	//	*DebugResponse_Data
	//	*DebugResponse_Status
	Response isDebugResponse_Response `protobuf_oneof:"response"`
	// contains filtered or unexported fields
}

func (*DebugResponse) Descriptor deprecated

func (*DebugResponse) Descriptor() ([]byte, []int)

Deprecated: Use DebugResponse.ProtoReflect.Descriptor instead.

func (*DebugResponse) GetData

func (x *DebugResponse) GetData() []byte

func (*DebugResponse) GetRequest

func (x *DebugResponse) GetRequest() *DebugRequest

func (*DebugResponse) GetResponse

func (x *DebugResponse) GetResponse() isDebugResponse_Response

func (*DebugResponse) GetStatus

func (x *DebugResponse) GetStatus() *DebugStatus

func (*DebugResponse) ProtoMessage

func (*DebugResponse) ProtoMessage()

func (*DebugResponse) ProtoReflect

func (x *DebugResponse) ProtoReflect() protoreflect.Message

func (*DebugResponse) Reset

func (x *DebugResponse) Reset()

func (*DebugResponse) String

func (x *DebugResponse) String() string

type DebugResponse_Data

type DebugResponse_Data struct {
	Data []byte `protobuf:"bytes,101,opt,name=data,proto3,oneof"`
}

type DebugResponse_Request

type DebugResponse_Request struct {
	Request *DebugRequest `protobuf:"bytes,100,opt,name=request,proto3,oneof"`
}

type DebugResponse_Status

type DebugResponse_Status struct {
	Status *DebugStatus `protobuf:"bytes,102,opt,name=status,proto3,oneof"`
}

type DebugServer

type DebugServer interface {
	Debug(*DebugRequest, grpc.ServerStreamingServer[DebugResponse]) error
}

DebugServer is the server API for Debug service. All implementations should embed UnimplementedDebugServer for forward compatibility.

type DebugStatus

type DebugStatus struct {
	Code    int32        `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"`
	Message string       `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"`
	Details []*anypb.Any `protobuf:"bytes,3,rep,name=details,proto3" json:"details,omitempty"`
	// contains filtered or unexported fields
}

func (*DebugStatus) Descriptor deprecated

func (*DebugStatus) Descriptor() ([]byte, []int)

Deprecated: Use DebugStatus.ProtoReflect.Descriptor instead.

func (*DebugStatus) GetCode

func (x *DebugStatus) GetCode() int32

func (*DebugStatus) GetDetails

func (x *DebugStatus) GetDetails() []*anypb.Any

func (*DebugStatus) GetMessage

func (x *DebugStatus) GetMessage() string

func (*DebugStatus) ProtoMessage

func (*DebugStatus) ProtoMessage()

func (*DebugStatus) ProtoReflect

func (x *DebugStatus) ProtoReflect() protoreflect.Message

func (*DebugStatus) Reset

func (x *DebugStatus) Reset()

func (*DebugStatus) String

func (x *DebugStatus) String() string

type Debug_DebugClient

type Debug_DebugClient = grpc.ServerStreamingClient[DebugResponse]

This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.

type Debug_DebugServer

type Debug_DebugServer = grpc.ServerStreamingServer[DebugResponse]

This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.

type UnimplementedDebugServer

type UnimplementedDebugServer struct{}

UnimplementedDebugServer should be embedded to have forward compatible implementations.

NOTE: this should be embedded by value instead of pointer to avoid a nil pointer dereference when methods are called.

func (UnimplementedDebugServer) Debug

type UnsafeDebugServer added in v0.4.1

type UnsafeDebugServer interface {
	// contains filtered or unexported methods
}

UnsafeDebugServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to DebugServer will result in compilation errors.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL