Browse Source

Merge pull request #39816 from tao12345666333/rm-systeminfo-error-handler

Remove `SystemInfo()` error handling.
Akihiro Suda 5 years ago
parent
commit
f073ed4187

+ 1 - 1
api/server/router/system/backend.go

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

+ 2 - 4
api/server/router/system/system_routes.go

@@ -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 {
 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 {
 	if s.cluster != nil {
 		info.Swarm = s.cluster.Info()
 		info.Swarm = s.cluster.Info()
 		info.Warnings = append(info.Warnings, info.Swarm.Warnings...)
 		info.Warnings = append(info.Warnings, info.Swarm.Warnings...)

+ 1 - 1
daemon/cluster/executor/backend.go

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

+ 1 - 4
daemon/cluster/executor/container/executor.go

@@ -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.
 // Describe returns the underlying node description from the docker client.
 func (e *executor) Describe(ctx context.Context) (*api.NodeDescription, error) {
 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{}{}
 	plugins := map[api.PluginDescription]struct{}{}
 	addPlugins := func(typ string, names []string) {
 	addPlugins := func(typ string, names []string) {

+ 1 - 2
daemon/daemon.go

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

+ 1 - 1
daemon/events.go

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

+ 2 - 2
daemon/info.go

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