Browse code

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

Remove `SystemInfo()` error handling.

Akihiro Suda authored on 2020/03/13 01:59:13
Showing 7 changed files
... ...
@@ -13,7 +13,7 @@ import (
13 13
 // Backend is the methods that need to be implemented to provide
14 14
 // system specific functionality.
15 15
 type Backend interface {
16
-	SystemInfo() (*types.Info, error)
16
+	SystemInfo() *types.Info
17 17
 	SystemVersion() types.Version
18 18
 	SystemDiskUsage(ctx context.Context) (*types.DiskUsage, error)
19 19
 	SubscribeToEvents(since, until time.Time, ef filters.Args) ([]events.Message, chan interface{})
... ...
@@ -44,10 +44,8 @@ func (s *systemRouter) pingHandler(ctx context.Context, w http.ResponseWriter, r
44 44
 }
45 45
 
46 46
 func (s *systemRouter) getInfo(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
47
-	info, err := s.backend.SystemInfo()
48
-	if err != nil {
49
-		return err
50
-	}
47
+	info := s.backend.SystemInfo()
48
+
51 49
 	if s.cluster != nil {
52 50
 		info.Swarm = s.cluster.Info()
53 51
 		info.Warnings = append(info.Warnings, info.Swarm.Warnings...)
... ...
@@ -48,7 +48,7 @@ type Backend interface {
48 48
 	SetContainerDependencyStore(name string, store exec.DependencyGetter) error
49 49
 	SetContainerSecretReferences(name string, refs []*swarmtypes.SecretReference) error
50 50
 	SetContainerConfigReferences(name string, refs []*swarmtypes.ConfigReference) error
51
-	SystemInfo() (*types.Info, error)
51
+	SystemInfo() *types.Info
52 52
 	Containers(config *types.ContainerListOptions) ([]*types.Container, error)
53 53
 	SetNetworkBootstrapKeys([]*networktypes.EncryptionKey) error
54 54
 	DaemonJoinsCluster(provider cluster.Provider)
... ...
@@ -47,10 +47,7 @@ func NewExecutor(b executorpkg.Backend, p plugin.Backend, i executorpkg.ImageBac
47 47
 
48 48
 // Describe returns the underlying node description from the docker client.
49 49
 func (e *executor) Describe(ctx context.Context) (*api.NodeDescription, error) {
50
-	info, err := e.backend.SystemInfo()
51
-	if err != nil {
52
-		return nil, err
53
-	}
50
+	info := e.backend.SystemInfo()
54 51
 
55 52
 	plugins := map[api.PluginDescription]struct{}{}
56 53
 	addPlugins := func(typ string, names []string) {
... ...
@@ -1098,8 +1098,7 @@ func NewDaemon(ctx context.Context, config *config.Config, pluginStore *plugin.S
1098 1098
 	}
1099 1099
 	close(d.startupDone)
1100 1100
 
1101
-	// FIXME: this method never returns an error
1102
-	info, _ := d.SystemInfo()
1101
+	info := d.SystemInfo()
1103 1102
 
1104 1103
 	engineInfo.WithValues(
1105 1104
 		dockerversion.Version,
... ...
@@ -87,7 +87,7 @@ func (daemon *Daemon) LogNetworkEventWithAttributes(nw libnetwork.Network, actio
87 87
 // LogDaemonEventWithAttributes generates an event related to the daemon itself with specific given attributes.
88 88
 func (daemon *Daemon) LogDaemonEventWithAttributes(action string, attributes map[string]string) {
89 89
 	if daemon.EventsService != nil {
90
-		if info, err := daemon.SystemInfo(); err == nil && info.Name != "" {
90
+		if info := daemon.SystemInfo(); info.Name != "" {
91 91
 			attributes["name"] = info.Name
92 92
 		}
93 93
 		actor := events.Actor{
... ...
@@ -25,7 +25,7 @@ import (
25 25
 )
26 26
 
27 27
 // SystemInfo returns information about the host server the daemon is running on.
28
-func (daemon *Daemon) SystemInfo() (*types.Info, error) {
28
+func (daemon *Daemon) SystemInfo() *types.Info {
29 29
 	defer metrics.StartTimer(hostInfoFunctions.WithValues("system_info"))()
30 30
 
31 31
 	sysInfo := sysinfo.New(true)
... ...
@@ -79,7 +79,7 @@ func (daemon *Daemon) SystemInfo() (*types.Info, error) {
79 79
 	daemon.fillSecurityOptions(v, sysInfo)
80 80
 	daemon.fillLicense(v)
81 81
 
82
-	return v, nil
82
+	return v
83 83
 }
84 84
 
85 85
 // SystemVersion returns version information about the daemon.