@@ -235,17 +235,15 @@ type resourceOptions struct {
235235 resCPU opts.NanoCPUs
236236 resMemBytes opts.MemBytes
237237 resGenericResources []string
238- swapBytes opts.MemBytes
239- memSwappiness int64
240238}
241239
242- func (r * resourceOptions ) ToResourceRequirements (flags * pflag. FlagSet ) (* swarm.ResourceRequirements , error ) {
240+ func (r * resourceOptions ) ToResourceRequirements () (* swarm.ResourceRequirements , error ) {
243241 generic , err := ParseGenericResources (r .resGenericResources )
244242 if err != nil {
245243 return nil , err
246244 }
247245
248- resreq := & swarm.ResourceRequirements {
246+ return & swarm.ResourceRequirements {
249247 Limits : & swarm.Limit {
250248 NanoCPUs : r .limitCPU .Value (),
251249 MemoryBytes : r .limitMemBytes .Value (),
@@ -256,20 +254,7 @@ func (r *resourceOptions) ToResourceRequirements(flags *pflag.FlagSet) (*swarm.R
256254 MemoryBytes : r .resMemBytes .Value (),
257255 GenericResources : generic ,
258256 },
259- }
260-
261- // SwapBytes and MemorySwappiness are *int64 (pointers), so we need to have
262- // a variable we can take a pointer to. Additionally, we need to ensure
263- // that these values are only set if they are set as options.
264- if flags .Changed (flagSwapBytes ) {
265- swapBytes := r .swapBytes .Value ()
266- resreq .SwapBytes = & swapBytes
267- }
268- if flags .Changed (flagMemSwappiness ) {
269- resreq .MemorySwappiness = & r .memSwappiness
270- }
271-
272- return resreq , nil
257+ }, nil
273258}
274259
275260type restartPolicyOptions struct {
@@ -749,7 +734,7 @@ func (options *serviceOptions) ToService(ctx context.Context, apiClient client.N
749734 return networks [i ].Target < networks [j ].Target
750735 })
751736
752- resources , err := options .resources .ToResourceRequirements (flags )
737+ resources , err := options .resources .ToResourceRequirements ()
753738 if err != nil {
754739 return service , err
755740 }
@@ -904,10 +889,6 @@ func addServiceFlags(flags *pflag.FlagSet, options *serviceOptions, defaultFlagV
904889 flags .Var (& options .resources .resMemBytes , flagReserveMemory , "Reserve Memory" )
905890 flags .Int64Var (& options .resources .limitPids , flagLimitPids , 0 , "Limit maximum number of processes (default 0 = unlimited)" )
906891 flags .SetAnnotation (flagLimitPids , "version" , []string {"1.41" })
907- flags .Var (& options .resources .swapBytes , flagSwapBytes , "Swap Bytes (-1 for unlimited)" )
908- flags .SetAnnotation (flagLimitPids , "version" , []string {"1.52" })
909- flags .Int64Var (& options .resources .memSwappiness , flagMemSwappiness , - 1 , "Tune memory swappiness (0-100), -1 to reset to default" )
910- flags .SetAnnotation (flagLimitPids , "version" , []string {"1.52" })
911892
912893 flags .Var (& options .stopGrace , flagStopGracePeriod , flagDesc (flagStopGracePeriod , "Time to wait before force killing a container (ns|us|ms|s|m|h)" ))
913894 flags .Var (& options .replicas , flagReplicas , "Number of tasks" )
@@ -1092,8 +1073,6 @@ const (
10921073 flagUlimitAdd = "ulimit-add"
10931074 flagUlimitRemove = "ulimit-rm"
10941075 flagOomScoreAdj = "oom-score-adj"
1095- flagSwapBytes = "memory-swap"
1096- flagMemSwappiness = "memory-swappiness"
10971076)
10981077
10991078func toNetipAddrSlice (ips []string ) []netip.Addr {
0 commit comments