github.com/hernad/nomad@v1.6.112/nomad/structs/config/drain.go (about) 1 // Copyright (c) HashiCorp, Inc. 2 // SPDX-License-Identifier: MPL-2.0 3 4 package config 5 6 import "github.com/hernad/nomad/helper/pointer" 7 8 // DrainConfig describes a Node's drain behavior on graceful shutdown. 9 type DrainConfig struct { 10 // Deadline is the duration after the drain starts when client will stop 11 // waiting for allocations to stop. 12 Deadline *string `hcl:"deadline"` 13 14 // IgnoreSystemJobs allows systems jobs to remain on the node even though it 15 // has been marked for draining. 16 IgnoreSystemJobs *bool `hcl:"ignore_system_jobs"` 17 18 // Force causes the drain to stop all the allocations immediately, ignoring 19 // their jobs' migrate blocks. 20 Force *bool `hcl:"force"` 21 } 22 23 func (d *DrainConfig) Copy() *DrainConfig { 24 if d == nil { 25 return nil 26 } 27 28 nd := new(DrainConfig) 29 *nd = *d 30 return nd 31 } 32 33 func (d *DrainConfig) Merge(o *DrainConfig) *DrainConfig { 34 switch { 35 case d == nil: 36 return o.Copy() 37 case o == nil: 38 return d.Copy() 39 default: 40 nd := d.Copy() 41 if o.Deadline != nil { 42 nd.Deadline = pointer.Copy(o.Deadline) 43 } 44 if o.IgnoreSystemJobs != nil && *o.IgnoreSystemJobs { 45 nd.IgnoreSystemJobs = pointer.Of(true) 46 } 47 if o.Force != nil && *o.Force { 48 nd.Force = pointer.Of(true) 49 } 50 return nd 51 } 52 }