Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stages/files: filter out non-existent paths before relabeling #1789

Merged
merged 2 commits into from
Jan 16, 2024
Merged
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
9 changes: 7 additions & 2 deletions docs/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,22 @@ nav_order: 9

### Breaking changes

- The dracut module is not automatically included in initramfs images anymore,
see distributor notes for details.
- Only include dracut module in initramfs if requested (see distributor notes
for details)

### Features



### Changes

- Require Go 1.20+

### Bug fixes

- Fix failure when config only disables units already disabled


## Ignition 2.17.0 (2023-11-20)

Starting with this release, ignition-validate binaries are signed with the
Expand Down
14 changes: 13 additions & 1 deletion internal/exec/stages/files/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package files
import (
"errors"
"fmt"
"os"
"path/filepath"

"github.com/coreos/ignition/v2/config/v3_5_experimental/types"
Expand Down Expand Up @@ -170,7 +171,18 @@ func (s *stage) relabelFiles() error {

keys := make([]string, 0, len(s.toRelabel))
for key := range s.toRelabel {
keys = append(keys, key)
// Filter out non-existent entries; some of the code that mark files for
// relabeling may not actually end up creating those files in the end.
if _, err := os.Stat(key); err == nil {
keys = append(keys, key)
} else if !errors.Is(err, os.ErrNotExist) {
return err
}
}

if len(keys) == 0 {
return nil
}

return s.RelabelFiles(keys)
}
Loading