Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changelog/28486.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
```release-note:deprecation
api: the Allocation struct's Resources and TaskResources fields are deprecated. Use the AllocatedResources field instead
```

```release-note:deprecation
client: state databases restored from backups older than Nomad 0.9 are no longer compatible and will fail client startup.
```
30 changes: 18 additions & 12 deletions api/allocations.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,17 +253,22 @@ func (a *Allocations) Services(allocID string, q *QueryOptions) ([]*ServiceRegis

// Allocation is used for serialization of allocations.
type Allocation struct {
ID string
Namespace string
EvalID string
Name string
NodeID string
NodeName string
JobID string
Job *Job
TaskGroup string
Resources *Resources
TaskResources map[string]*Resources
ID string
Namespace string
EvalID string
Name string
NodeID string
NodeName string
JobID string
Job *Job
TaskGroup string

// Deprecated: will be removed in a future version of the API. Use AllocatedResources.
Resources *Resources

// Deprecated: will be removed in a future version of the API. Use AllocatedResources.
TaskResources map[string]*Resources

AllocatedResources *AllocatedResources
Services map[string]string
Metrics *AllocationMetric
Expand Down Expand Up @@ -453,7 +458,8 @@ type PortMapping struct {
}

type AllocatedCpuResources struct {
CpuShares int64
CpuShares int64
ReservedCores []uint16
}

type AllocatedMemoryResources struct {
Expand Down
10 changes: 0 additions & 10 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3471,16 +3471,6 @@ func (c *Client) getAllocatedResources(selfNode *structs.Node) *structs.Comparab
}
}
}
} else if alloc.Resources != nil {
for _, allocatedNetwork := range alloc.Resources.Networks {
for cidr, dev := range cidrToDevice {
ip := net.ParseIP(allocatedNetwork.IP)
if cidr.Contains(ip) {
allocatedDeviceMbits[dev] += allocatedNetwork.MBits
break
}
}
}
}
}

Expand Down
1 change: 0 additions & 1 deletion client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,6 @@ func TestClient_AddAllocError(t *testing.T) {

// Set these two fields to nil to cause alloc runner creation to fail
alloc1.AllocatedResources = nil
alloc1.TaskResources = nil

state := s1.State()
err := state.UpsertJob(structs.MsgTypeTestSetup, 100, nil, job)
Expand Down
134 changes: 0 additions & 134 deletions client/state/08types.go

This file was deleted.

10 changes: 2 additions & 8 deletions client/state/db_bolt.go
Original file line number Diff line number Diff line change
Expand Up @@ -1215,11 +1215,11 @@ func (s *BoltStateDB) updateWithOptions(opts []WriteOption, updateFn func(tx *bo
// 0.9 schema. Creates a backup before upgrading.
func (s *BoltStateDB) Upgrade() error {
// Check to see if the underlying DB needs upgrading.
upgrade09, upgrade13, err := NeedsUpgrade(s.db.BoltDB())
upgrade13, err := NeedsUpgrade(s.db.BoltDB())
if err != nil {
return err
}
if !upgrade09 && !upgrade13 {
if !upgrade13 {
// No upgrade needed!
return nil
}
Expand All @@ -1232,12 +1232,6 @@ func (s *BoltStateDB) Upgrade() error {

// Perform the upgrade
if err := s.db.Update(func(tx *boltdd.Tx) error {

if upgrade09 {
if err := UpgradeAllocs(s.logger, tx); err != nil {
return err
}
}
if upgrade13 {
if err := UpgradeDynamicPluginRegistry(s.logger, tx); err != nil {
return err
Expand Down
Binary file removed client/state/testdata/state-0.7.1.db.gz
Binary file not shown.
Binary file removed client/state/testdata/state-0.8.6-empty.db.gz
Binary file not shown.
Binary file removed client/state/testdata/state-0.8.6-no-deploy.db.gz
Binary file not shown.
Loading
Loading