-
Notifications
You must be signed in to change notification settings - Fork 550
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: validate the machine configuration in the installer container
Talos validates machine configuration at boot time, and refuses to boot if machine configuration is invalid. As machine configuration validation rules might change over time, we need to prevent a scenario when after an upgrade machine configuration becomes invalid, as there's no way to roll back properly. Machine configuration is submitted over stdin to the installer container, and installer container validates it using the new version of Talos (which is going to be installed). If the config is not sent over stdin, installer assumes old version of Talos and proceeds. This should be backported to 0.9 to allow config validation on upgrade to 0.10. Fixes #3419 Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com> (cherry picked from commit d5e2a45)
- Loading branch information
Showing
6 changed files
with
100 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
internal/app/machined/pkg/system/runner/containerd/stdin.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
package containerd | ||
|
||
import ( | ||
"context" | ||
"io" | ||
|
||
"github.com/containerd/containerd" | ||
) | ||
|
||
// StdinCloser wraps io.Reader providing a signal when reader is read till EOF. | ||
type StdinCloser struct { | ||
Stdin io.Reader | ||
Closer chan struct{} | ||
} | ||
|
||
func (s *StdinCloser) Read(p []byte) (int, error) { | ||
n, err := s.Stdin.Read(p) | ||
if err == io.EOF { | ||
close(s.Closer) | ||
} | ||
|
||
return n, err | ||
} | ||
|
||
// WaitAndClose closes containerd task stdin when StdinCloser is exhausted. | ||
func (s *StdinCloser) WaitAndClose(ctx context.Context, task containerd.Task) { | ||
select { | ||
case <-ctx.Done(): | ||
return | ||
case <-s.Closer: | ||
//nolint:errcheck | ||
task.CloseIO(ctx, containerd.WithStdinCloser) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters