Remove `SystemInfo()` error handling.

Signed-off-by: Jintao Zhang <zhangjintao9020@gmail.com>
This commit is contained in:
Jintao Zhang 2019-08-29 07:44:39 +08:00
parent 7ce0e26c16
commit 9134130b39
7 changed files with 9 additions and 15 deletions

View File

@ -13,7 +13,7 @@ import (
// Backend is the methods that need to be implemented to provide
// system specific functionality.
type Backend interface {
SystemInfo() (*types.Info, error)
SystemInfo() *types.Info
SystemVersion() types.Version
SystemDiskUsage(ctx context.Context) (*types.DiskUsage, error)
SubscribeToEvents(since, until time.Time, ef filters.Args) ([]events.Message, chan interface{})

View File

@ -44,10 +44,8 @@ func (s *systemRouter) pingHandler(ctx context.Context, w http.ResponseWriter, r
}
func (s *systemRouter) getInfo(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
info, err := s.backend.SystemInfo()
if err != nil {
return err
}
info := s.backend.SystemInfo()
if s.cluster != nil {
info.Swarm = s.cluster.Info()
info.Warnings = append(info.Warnings, info.Swarm.Warnings...)

View File

@ -48,7 +48,7 @@ type Backend interface {
SetContainerDependencyStore(name string, store exec.DependencyGetter) error
SetContainerSecretReferences(name string, refs []*swarmtypes.SecretReference) error
SetContainerConfigReferences(name string, refs []*swarmtypes.ConfigReference) error
SystemInfo() (*types.Info, error)
SystemInfo() *types.Info
Containers(config *types.ContainerListOptions) ([]*types.Container, error)
SetNetworkBootstrapKeys([]*networktypes.EncryptionKey) error
DaemonJoinsCluster(provider cluster.Provider)

View File

@ -47,10 +47,7 @@ func NewExecutor(b executorpkg.Backend, p plugin.Backend, i executorpkg.ImageBac
// Describe returns the underlying node description from the docker client.
func (e *executor) Describe(ctx context.Context) (*api.NodeDescription, error) {
info, err := e.backend.SystemInfo()
if err != nil {
return nil, err
}
info := e.backend.SystemInfo()
plugins := map[api.PluginDescription]struct{}{}
addPlugins := func(typ string, names []string) {

View File

@ -1065,8 +1065,7 @@ func NewDaemon(ctx context.Context, config *config.Config, pluginStore *plugin.S
}
close(d.startupDone)
// FIXME: this method never returns an error
info, _ := d.SystemInfo()
info := d.SystemInfo()
engineInfo.WithValues(
dockerversion.Version,

View File

@ -87,7 +87,7 @@ func (daemon *Daemon) LogNetworkEventWithAttributes(nw libnetwork.Network, actio
// LogDaemonEventWithAttributes generates an event related to the daemon itself with specific given attributes.
func (daemon *Daemon) LogDaemonEventWithAttributes(action string, attributes map[string]string) {
if daemon.EventsService != nil {
if info, err := daemon.SystemInfo(); err == nil && info.Name != "" {
if info := daemon.SystemInfo(); info.Name != "" {
attributes["name"] = info.Name
}
actor := events.Actor{

View File

@ -26,7 +26,7 @@ import (
)
// SystemInfo returns information about the host server the daemon is running on.
func (daemon *Daemon) SystemInfo() (*types.Info, error) {
func (daemon *Daemon) SystemInfo() *types.Info {
defer metrics.StartTimer(hostInfoFunctions.WithValues("system_info"))()
sysInfo := sysinfo.New(true)
@ -81,7 +81,7 @@ func (daemon *Daemon) SystemInfo() (*types.Info, error) {
daemon.fillSecurityOptions(v, sysInfo)
daemon.fillLicense(v)
return v, nil
return v
}
// SystemVersion returns version information about the daemon.