Skip to content

Commit 9d28e04

Browse files
authored
Merge pull request #2234 from chewi/partx-race
Fix disk partitioning race condition and using partition number 0
2 parents 4360370 + 2132963 commit 9d28e04

14 files changed

Lines changed: 358 additions & 177 deletions

File tree

config/shared/errors/errors.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ var (
8585
ErrUnrecognizedRaidLevel = errors.New("unrecognized raid level")
8686
ErrRaidDevicesRequired = errors.New("raid devices required")
8787
ErrShouldNotExistWithOthers = errors.New("shouldExist specified false with other options also specified")
88-
ErrZeroesWithShouldNotExist = errors.New("shouldExist is false for a partition and other partition(s) has start or size 0")
8988
ErrNeedLabelOrNumber = errors.New("a partition number >= 1 or a label must be specified")
9089
ErrDuplicateLabels = errors.New("cannot use the same partition label twice")
9190
ErrInvalidProxy = errors.New("proxies must be http(s)")

config/v3_0/types/disk.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ package types
1616

1717
import (
1818
"github.com/coreos/ignition/v2/config/shared/errors"
19-
"github.com/coreos/ignition/v2/config/util"
2019

2120
"github.com/coreos/vcontext/path"
2221
"github.com/coreos/vcontext/report"
@@ -39,9 +38,6 @@ func (n Disk) Validate(c path.ContextPath) (r report.Report) {
3938
if overlaps, p := n.partitionsOverlap(); overlaps {
4039
r.AddOnError(c.Append("partitions", p), errors.ErrPartitionsOverlap)
4140
}
42-
if n.partitionsMixZeroesAndNonexistence() {
43-
r.AddOnError(c.Append("partitions"), errors.ErrZeroesWithShouldNotExist)
44-
}
4541
if collides, p := n.partitionLabelsCollide(); collides {
4642
r.AddOnError(c.Append("partitions", p), errors.ErrDuplicateLabels)
4743
}
@@ -123,13 +119,3 @@ func (n Disk) partitionsOverlap() (bool, int) {
123119
}
124120
return false, 0
125121
}
126-
127-
func (n Disk) partitionsMixZeroesAndNonexistence() bool {
128-
hasZero := false
129-
hasShouldNotExist := false
130-
for _, p := range n.Partitions {
131-
hasShouldNotExist = hasShouldNotExist || util.IsFalse(p.ShouldExist)
132-
hasZero = hasZero || (p.Number == 0)
133-
}
134-
return hasZero && hasShouldNotExist
135-
}

config/v3_1/types/disk.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ package types
1616

1717
import (
1818
"github.com/coreos/ignition/v2/config/shared/errors"
19-
"github.com/coreos/ignition/v2/config/util"
2019

2120
"github.com/coreos/vcontext/path"
2221
"github.com/coreos/vcontext/report"
@@ -39,9 +38,6 @@ func (n Disk) Validate(c path.ContextPath) (r report.Report) {
3938
if overlaps, p := n.partitionsOverlap(); overlaps {
4039
r.AddOnError(c.Append("partitions", p), errors.ErrPartitionsOverlap)
4140
}
42-
if n.partitionsMixZeroesAndNonexistence() {
43-
r.AddOnError(c.Append("partitions"), errors.ErrZeroesWithShouldNotExist)
44-
}
4541
if collides, p := n.partitionLabelsCollide(); collides {
4642
r.AddOnError(c.Append("partitions", p), errors.ErrDuplicateLabels)
4743
}
@@ -123,13 +119,3 @@ func (n Disk) partitionsOverlap() (bool, int) {
123119
}
124120
return false, 0
125121
}
126-
127-
func (n Disk) partitionsMixZeroesAndNonexistence() bool {
128-
hasZero := false
129-
hasShouldNotExist := false
130-
for _, p := range n.Partitions {
131-
hasShouldNotExist = hasShouldNotExist || util.IsFalse(p.ShouldExist)
132-
hasZero = hasZero || (p.Number == 0)
133-
}
134-
return hasZero && hasShouldNotExist
135-
}

config/v3_2/types/disk.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ package types
1616

1717
import (
1818
"github.com/coreos/ignition/v2/config/shared/errors"
19-
"github.com/coreos/ignition/v2/config/util"
2019

2120
"github.com/coreos/vcontext/path"
2221
"github.com/coreos/vcontext/report"
@@ -39,9 +38,6 @@ func (n Disk) Validate(c path.ContextPath) (r report.Report) {
3938
if overlaps, p := n.partitionsOverlap(); overlaps {
4039
r.AddOnError(c.Append("partitions", p), errors.ErrPartitionsOverlap)
4140
}
42-
if n.partitionsMixZeroesAndNonexistence() {
43-
r.AddOnError(c.Append("partitions"), errors.ErrZeroesWithShouldNotExist)
44-
}
4541
if collides, p := n.partitionLabelsCollide(); collides {
4642
r.AddOnError(c.Append("partitions", p), errors.ErrDuplicateLabels)
4743
}
@@ -123,13 +119,3 @@ func (n Disk) partitionsOverlap() (bool, int) {
123119
}
124120
return false, 0
125121
}
126-
127-
func (n Disk) partitionsMixZeroesAndNonexistence() bool {
128-
hasZero := false
129-
hasShouldNotExist := false
130-
for _, p := range n.Partitions {
131-
hasShouldNotExist = hasShouldNotExist || util.IsFalse(p.ShouldExist)
132-
hasZero = hasZero || (p.Number == 0)
133-
}
134-
return hasZero && hasShouldNotExist
135-
}

config/v3_3/types/disk.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ package types
1616

1717
import (
1818
"github.com/coreos/ignition/v2/config/shared/errors"
19-
"github.com/coreos/ignition/v2/config/util"
2019

2120
"github.com/coreos/vcontext/path"
2221
"github.com/coreos/vcontext/report"
@@ -39,9 +38,6 @@ func (n Disk) Validate(c path.ContextPath) (r report.Report) {
3938
if overlaps, p := n.partitionsOverlap(); overlaps {
4039
r.AddOnError(c.Append("partitions", p), errors.ErrPartitionsOverlap)
4140
}
42-
if n.partitionsMixZeroesAndNonexistence() {
43-
r.AddOnError(c.Append("partitions"), errors.ErrZeroesWithShouldNotExist)
44-
}
4541
if collides, p := n.partitionLabelsCollide(); collides {
4642
r.AddOnError(c.Append("partitions", p), errors.ErrDuplicateLabels)
4743
}
@@ -123,13 +119,3 @@ func (n Disk) partitionsOverlap() (bool, int) {
123119
}
124120
return false, 0
125121
}
126-
127-
func (n Disk) partitionsMixZeroesAndNonexistence() bool {
128-
hasZero := false
129-
hasShouldNotExist := false
130-
for _, p := range n.Partitions {
131-
hasShouldNotExist = hasShouldNotExist || util.IsFalse(p.ShouldExist)
132-
hasZero = hasZero || (p.Number == 0)
133-
}
134-
return hasZero && hasShouldNotExist
135-
}

config/v3_4/types/disk.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ package types
1616

1717
import (
1818
"github.com/coreos/ignition/v2/config/shared/errors"
19-
"github.com/coreos/ignition/v2/config/util"
2019

2120
"github.com/coreos/vcontext/path"
2221
"github.com/coreos/vcontext/report"
@@ -39,9 +38,6 @@ func (n Disk) Validate(c path.ContextPath) (r report.Report) {
3938
if overlaps, p := n.partitionsOverlap(); overlaps {
4039
r.AddOnError(c.Append("partitions", p), errors.ErrPartitionsOverlap)
4140
}
42-
if n.partitionsMixZeroesAndNonexistence() {
43-
r.AddOnError(c.Append("partitions"), errors.ErrZeroesWithShouldNotExist)
44-
}
4541
if collides, p := n.partitionLabelsCollide(); collides {
4642
r.AddOnError(c.Append("partitions", p), errors.ErrDuplicateLabels)
4743
}
@@ -123,13 +119,3 @@ func (n Disk) partitionsOverlap() (bool, int) {
123119
}
124120
return false, 0
125121
}
126-
127-
func (n Disk) partitionsMixZeroesAndNonexistence() bool {
128-
hasZero := false
129-
hasShouldNotExist := false
130-
for _, p := range n.Partitions {
131-
hasShouldNotExist = hasShouldNotExist || util.IsFalse(p.ShouldExist)
132-
hasZero = hasZero || (p.Number == 0)
133-
}
134-
return hasZero && hasShouldNotExist
135-
}

config/v3_5/types/disk.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ package types
1616

1717
import (
1818
"github.com/coreos/ignition/v2/config/shared/errors"
19-
"github.com/coreos/ignition/v2/config/util"
2019

2120
"github.com/coreos/vcontext/path"
2221
"github.com/coreos/vcontext/report"
@@ -39,9 +38,6 @@ func (n Disk) Validate(c path.ContextPath) (r report.Report) {
3938
if overlaps, p := n.partitionsOverlap(); overlaps {
4039
r.AddOnError(c.Append("partitions", p), errors.ErrPartitionsOverlap)
4140
}
42-
if n.partitionsMixZeroesAndNonexistence() {
43-
r.AddOnError(c.Append("partitions"), errors.ErrZeroesWithShouldNotExist)
44-
}
4541
if collides, p := n.partitionLabelsCollide(); collides {
4642
r.AddOnError(c.Append("partitions", p), errors.ErrDuplicateLabels)
4743
}
@@ -123,13 +119,3 @@ func (n Disk) partitionsOverlap() (bool, int) {
123119
}
124120
return false, 0
125121
}
126-
127-
func (n Disk) partitionsMixZeroesAndNonexistence() bool {
128-
hasZero := false
129-
hasShouldNotExist := false
130-
for _, p := range n.Partitions {
131-
hasShouldNotExist = hasShouldNotExist || util.IsFalse(p.ShouldExist)
132-
hasZero = hasZero || (p.Number == 0)
133-
}
134-
return hasZero && hasShouldNotExist
135-
}

config/v3_6/types/disk.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ package types
1616

1717
import (
1818
"github.com/coreos/ignition/v2/config/shared/errors"
19-
"github.com/coreos/ignition/v2/config/util"
2019

2120
"github.com/coreos/vcontext/path"
2221
"github.com/coreos/vcontext/report"
@@ -39,9 +38,6 @@ func (n Disk) Validate(c path.ContextPath) (r report.Report) {
3938
if overlaps, p := n.partitionsOverlap(); overlaps {
4039
r.AddOnError(c.Append("partitions", p), errors.ErrPartitionsOverlap)
4140
}
42-
if n.partitionsMixZeroesAndNonexistence() {
43-
r.AddOnError(c.Append("partitions"), errors.ErrZeroesWithShouldNotExist)
44-
}
4541
if collides, p := n.partitionLabelsCollide(); collides {
4642
r.AddOnError(c.Append("partitions", p), errors.ErrDuplicateLabels)
4743
}
@@ -123,13 +119,3 @@ func (n Disk) partitionsOverlap() (bool, int) {
123119
}
124120
return false, 0
125121
}
126-
127-
func (n Disk) partitionsMixZeroesAndNonexistence() bool {
128-
hasZero := false
129-
hasShouldNotExist := false
130-
for _, p := range n.Partitions {
131-
hasShouldNotExist = hasShouldNotExist || util.IsFalse(p.ShouldExist)
132-
hasZero = hasZero || (p.Number == 0)
133-
}
134-
return hasZero && hasShouldNotExist
135-
}

config/v3_7_experimental/types/disk.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ package types
1616

1717
import (
1818
"github.com/coreos/ignition/v2/config/shared/errors"
19-
"github.com/coreos/ignition/v2/config/util"
2019

2120
"github.com/coreos/vcontext/path"
2221
"github.com/coreos/vcontext/report"
@@ -39,9 +38,6 @@ func (n Disk) Validate(c path.ContextPath) (r report.Report) {
3938
if overlaps, p := n.partitionsOverlap(); overlaps {
4039
r.AddOnError(c.Append("partitions", p), errors.ErrPartitionsOverlap)
4140
}
42-
if n.partitionsMixZeroesAndNonexistence() {
43-
r.AddOnError(c.Append("partitions"), errors.ErrZeroesWithShouldNotExist)
44-
}
4541
if collides, p := n.partitionLabelsCollide(); collides {
4642
r.AddOnError(c.Append("partitions", p), errors.ErrDuplicateLabels)
4743
}
@@ -123,13 +119,3 @@ func (n Disk) partitionsOverlap() (bool, int) {
123119
}
124120
return false, 0
125121
}
126-
127-
func (n Disk) partitionsMixZeroesAndNonexistence() bool {
128-
hasZero := false
129-
hasShouldNotExist := false
130-
for _, p := range n.Partitions {
131-
hasShouldNotExist = hasShouldNotExist || util.IsFalse(p.ShouldExist)
132-
hasZero = hasZero || (p.Number == 0)
133-
}
134-
return hasZero && hasShouldNotExist
135-
}

docs/release-notes.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Starting with this release, ignition-validate binaries are signed with the
1515

1616
- Support reading configs from `/run/ignition` and `/etc/ignition/` in addition to `/usr/lib/ignition/`, searched in descending priority order ([#2221](https://github.com/coreos/ignition/pull/2221))
1717
- Add support for `virtiofs`
18+
- Allow deleting a disk partition while creating another partition with number 0. ([#2234](https://github.com/coreos/ignition/pull/2234))
1819

1920
### Changes
2021

@@ -24,6 +25,9 @@ Starting with this release, ignition-validate binaries are signed with the
2425

2526
### Bug fixes
2627

28+
- Fix giving disk partition number 0 to get the next available slot. This caused the disks stage to fail since version 2.20.0. ([#2234](https://github.com/coreos/ignition/pull/2234))
29+
- Fix disk partitioning race condition where the kernel is already aware of the changes before running `partx`, causing a fatal error. ([#2234](https://github.com/coreos/ignition/pull/2234))
30+
2731

2832
## Ignition 2.26.0 (2026-02-17)
2933

0 commit comments

Comments
 (0)