Browse code

Had `HasExperimental()` to cluster backend

It's already defined on the daemon. This allows us to not call
`SystemInfo` which is failry heavy and potentially can even error.

Takes care of todo item from Derek's containerd integration PR.
https://github.com/moby/moby/blob/51c412f26e03ac564ace2de5a8a43c900ef80ef7/daemon/cluster/services.go#L148-L149

Signed-off-by: Brian Goff <cpuguy83@gmail.com>

Brian Goff authored on 2019/03/01 09:52:30
Showing 3 changed files
... ...
@@ -61,6 +61,7 @@ type Backend interface {
61 61
 	PluginManager() *plugin.Manager
62 62
 	PluginGetter() *plugin.Store
63 63
 	GetAttachmentStore() *networkSettings.AttachmentStore
64
+	HasExperimental() bool
64 65
 }
65 66
 
66 67
 // VolumeBackend is used by an executor to perform volume operations
... ...
@@ -229,8 +229,7 @@ func (e *executor) Controller(t *api.Task) (exec.Controller, error) {
229 229
 		}
230 230
 		switch runtimeKind {
231 231
 		case string(swarmtypes.RuntimePlugin):
232
-			info, _ := e.backend.SystemInfo()
233
-			if !info.ExperimentalBuild {
232
+			if !e.backend.HasExperimental() {
234 233
 				return ctlr, fmt.Errorf("runtime type %q only supported in experimental", swarmtypes.RuntimePlugin)
235 234
 			}
236 235
 			c, err := plugin.NewController(e.pluginBackend, t)
... ...
@@ -144,8 +144,7 @@ func (c *Cluster) CreateService(s types.ServiceSpec, encodedAuth string, queryRe
144 144
 		case *swarmapi.TaskSpec_Generic:
145 145
 			switch serviceSpec.Task.GetGeneric().Kind {
146 146
 			case string(types.RuntimePlugin):
147
-				info, _ := c.config.Backend.SystemInfo()
148
-				if !info.ExperimentalBuild {
147
+				if !c.config.Backend.HasExperimental() {
149 148
 					return fmt.Errorf("runtime type %q only supported in experimental", types.RuntimePlugin)
150 149
 				}
151 150
 				if s.TaskTemplate.PluginSpec == nil {