rest

package
v0.0.0-...-3641ea5 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2020 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bundle

type Bundle struct {
	ID      string    `json:"id,omitempty"`
	Type    Type      `json:"type"`
	Size    int64     `json:"size,omitempty"` // length in bytes for regular files; 0 when Canceled or Deleted
	Status  Status    `json:"status"`
	Started time.Time `json:"started_at,omitempty"`
	Stopped time.Time `json:"stopped_at,omitempty"`
	Errors  []string  `json:"errors,omitempty"`
}

func (*Bundle) Failed

func (b *Bundle) Failed(when time.Time, why error)

func (*Bundle) IsFinished

func (b *Bundle) IsFinished() bool

type BundleHandler

type BundleHandler struct {
	// contains filtered or unexported fields
}

BundleHandler is a struct that collects all functions responsible for diagnostics bundle lifecycle

func NewBundleHandler

func NewBundleHandler(workDir string, collectors []collector.Collector, timeout, collectorTimeout time.Duration) (*BundleHandler, error)

func (BundleHandler) Create

func (h BundleHandler) Create(w http.ResponseWriter, r *http.Request)

func (BundleHandler) Delete

func (h BundleHandler) Delete(w http.ResponseWriter, r *http.Request)

func (BundleHandler) Get

func (BundleHandler) GetFile

func (h BundleHandler) GetFile(w http.ResponseWriter, r *http.Request)

func (BundleHandler) List

type BundleStatus

type BundleStatus struct {
	// contains filtered or unexported fields
}

BundleStatus tracks the status of local bundle creation requests

type Client

type Client interface {
	// CreateBundle requests the given node to start a bundle creation process with that is identified by the given ID
	CreateBundle(ctx context.Context, node string, ID string) (*Bundle, error)
	// Status returns the status of the bundle with the given ID on the given node
	Status(ctx context.Context, node string, ID string) (*Bundle, error)
	// GetFile downloads the bundle file of the bundle with the given ID from the node
	// url and save it to local filesystem under given path.
	// Returns an error if there were a problem.
	GetFile(ctx context.Context, node string, ID string, path string) (err error)
	// List will get the list of available bundles on the given node
	List(ctx context.Context, node string) ([]*Bundle, error)
	// Delete will delete the bundle with the given id from the given node
	Delete(ctx context.Context, node string, ID string) error
}

Client is an interface that can talk with dcos-diagnostics REST API and manipulate remote bundles

type Clock

type Clock interface {
	Now() time.Time
}

type ClusterBundleHandler

type ClusterBundleHandler struct {
	// contains filtered or unexported fields
}

ClusterBundleHandler is a handler that will create and manage cluster-wide diagnostics bundles

func NewClusterBundleHandler

func NewClusterBundleHandler(c Coordinator, client Client, tools dcos.Tooler, workDir string, timeout time.Duration,
	urlBuilder dcos.NodeURLBuilder) (*ClusterBundleHandler, error)

func (*ClusterBundleHandler) Create

Create will send the initial creation request for the bundle to all nodes. The created bundle will exist on the called master node

func (*ClusterBundleHandler) Delete

Delete will delete a given bundle, proxying the call if the given bundle exists on a different master

func (*ClusterBundleHandler) Download

Download will download the given bundle, proxying the call to the appropriate master

func (*ClusterBundleHandler) List

List will get a list of all bundles available across all masters

func (*ClusterBundleHandler) Status

Status will return the status of a given bundle, proxying the call to the appropriate master

type Coordinator

type Coordinator interface {
	// CreateBundle starts the bundle creation process. Status updates be monitored
	// on the returned channel.
	CreateBundle(ctx context.Context, id string, nodes []node) <-chan BundleStatus
	// CollectBundle waits until all the nodes' bundles have finished, downloads,
	// and merges them. The resulting bundle zip file path is returned.
	CollectBundle(ctx context.Context, bundleID string, numBundles int, statuses <-chan BundleStatus) (string, error)
}

golangcli-lint marks this as dead code because nothing uses the interface yet. this will be removed with the bundle handler PR coordinator is an interface to coordinate the creation of diagnostics bundles across a cluster of nodes

type DiagnosticsBundleAlreadyExists

type DiagnosticsBundleAlreadyExists struct {
	// contains filtered or unexported fields
}

func (*DiagnosticsBundleAlreadyExists) Error

type DiagnosticsBundleNotFoundError

type DiagnosticsBundleNotFoundError struct {
	// contains filtered or unexported fields
}

func (*DiagnosticsBundleNotFoundError) Error

type DiagnosticsBundleUnreadableError

type DiagnosticsBundleUnreadableError struct {
	// contains filtered or unexported fields
}

func (*DiagnosticsBundleUnreadableError) Error

type DiagnosticsClient

type DiagnosticsClient struct {
	// contains filtered or unexported fields
}

func NewDiagnosticsClient

func NewDiagnosticsClient(client *http.Client) DiagnosticsClient

NewDiagnosticsClient constructs a diagnostics client

func (DiagnosticsClient) CreateBundle

func (d DiagnosticsClient) CreateBundle(ctx context.Context, node string, ID string) (*Bundle, error)

func (DiagnosticsClient) Delete

func (d DiagnosticsClient) Delete(ctx context.Context, node string, id string) error

func (DiagnosticsClient) GetFile

func (d DiagnosticsClient) GetFile(ctx context.Context, node string, ID string, path string) error

func (DiagnosticsClient) List

func (d DiagnosticsClient) List(ctx context.Context, node string) ([]*Bundle, error)

func (DiagnosticsClient) Status

func (d DiagnosticsClient) Status(ctx context.Context, node string, ID string) (*Bundle, error)

type ErrorResponse

type ErrorResponse struct {
	Code  int    `json:"code"`
	Error string `json:"error"`
}

type ParallelCoordinator

type ParallelCoordinator struct {
	// contains filtered or unexported fields
}

ParallelCoordinator implements Coordinator interface to coordinate bundle creation across a cluster, parallelized across multiple goroutines.

func NewParallelCoordinator

func NewParallelCoordinator(client Client, interval time.Duration, workDir string) *ParallelCoordinator

NewParallelCoordinator creates and returns a new ParallelCoordinator

func (ParallelCoordinator) CollectBundle

func (c ParallelCoordinator) CollectBundle(ctx context.Context, bundleID string, numBundles int, statuses <-chan BundleStatus) (string, error)

CollectBundle waits until all the nodes' bundles have finished, downloads, and merges them. The resulting bundle zip file path is returned.

func (ParallelCoordinator) CreateBundle

func (c ParallelCoordinator) CreateBundle(ctx context.Context, id string, nodes []node) <-chan BundleStatus

CreateBundle starts the bundle creation process. Status updates be monitored on the returned channel.

type Status

type Status int

Status represents an bundle status

const (
	Unknown    Status = iota // No information about this bundle
	Started                  // Diagnostics is preparing
	InProgress               // Diagnostics in progress
	Done                     // Diagnostics finished and the file is ready to be downloaded
	Canceled                 // Diagnostics has been cancelled
	Deleted                  // Diagnostics was finished but was deleted
	Failed                   // Diagnostics could not be downloaded
)

func (Status) MarshalJSON

func (s Status) MarshalJSON() ([]byte, error)

MarshalJSON marshals the enum as a quoted json string

func (Status) String

func (s Status) String() string

func (*Status) UnmarshalJSON

func (s *Status) UnmarshalJSON(b []byte) error

UnmarshalJSON unmashals a quoted json string to the enum value

type Type

type Type int

Type represents a bundle type

const (
	Local Type = iota
	Cluster
)

func (Type) MarshalJSON

func (s Type) MarshalJSON() ([]byte, error)

MarshalJSON marshals the enum as a quoted json string

func (Type) String

func (s Type) String() string

func (*Type) UnmarshalJSON

func (s *Type) UnmarshalJSON(b []byte) error

UnmarshalJSON unmashals a quoted json string to the enum value

Jump to

Keyboard shortcuts

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