Skip to content

Commit

Permalink
feat: rename apply-config --no-reboot to --on-reboot
Browse files Browse the repository at this point in the history
This explains the intetion better: config is applied on reboot, and
allows to easily distinguish it from `apply-config --immediate` which
applies config immediately without a reboot (that is coming in a
different PR).

Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
  • Loading branch information
smira authored and talos-bot committed Feb 17, 2021
1 parent 254e0e9 commit cc83b83
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 18 deletions.
2 changes: 1 addition & 1 deletion api/machine/machine.proto
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ service MachineService {
// node.
message ApplyConfigurationRequest {
bytes data = 1;
bool no_reboot = 2;
bool on_reboot = 2;
}

// ApplyConfigurationResponse describes the response to a configuration request.
Expand Down
10 changes: 7 additions & 3 deletions cmd/talosctl/cmd/talos/apply-config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var applyConfigCmdFlags struct {
filename string
insecure bool
interactive bool
noReboot bool
onReboot bool
}

// applyConfigCmd represents the applyConfiguration command.
Expand Down Expand Up @@ -135,7 +135,7 @@ var applyConfigCmd = &cobra.Command{

if _, err := c.ApplyConfiguration(ctx, &machineapi.ApplyConfigurationRequest{
Data: cfgBytes,
NoReboot: applyConfigCmdFlags.noReboot,
OnReboot: applyConfigCmdFlags.onReboot,
}); err != nil {
return fmt.Errorf("error applying new configuration: %s", err)
}
Expand All @@ -150,7 +150,11 @@ func init() {
applyConfigCmd.Flags().BoolVarP(&applyConfigCmdFlags.insecure, "insecure", "i", false, "apply the config using the insecure (encrypted with no auth) maintenance service")
applyConfigCmd.Flags().StringSliceVar(&applyConfigCmdFlags.certFingerprints, "cert-fingerprint", nil, "list of server certificate fingeprints to accept (defaults to no check)")
applyConfigCmd.Flags().BoolVar(&applyConfigCmdFlags.interactive, "interactive", false, "apply the config using text based interactive mode")
applyConfigCmd.Flags().BoolVar(&applyConfigCmdFlags.noReboot, "no-reboot", false, "apply the config only after the reboot")
applyConfigCmd.Flags().BoolVar(&applyConfigCmdFlags.onReboot, "on-reboot", false, "apply the config on reboot")

// deprecated, to be removed in 0.10
applyConfigCmd.Flags().BoolVar(&applyConfigCmdFlags.onReboot, "no-reboot", false, "apply the config only after the reboot")
applyConfigCmd.Flags().MarkHidden("no-reboot") //nolint: errcheck

addCommand(applyConfigCmd)
}
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (s *Server) Register(obj *grpc.Server) {

// ApplyConfiguration implements machine.MachineService.
func (s *Server) ApplyConfiguration(ctx context.Context, in *machine.ApplyConfigurationRequest) (reply *machine.ApplyConfigurationResponse, err error) {
if !in.NoReboot {
if !in.OnReboot {
if err = s.Controller.Runtime().SetConfig(in.GetData()); err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions internal/app/maintenance/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ func (s *Server) Register(obj *grpc.Server) {

// ApplyConfiguration implements machine.MachineService.
func (s *Server) ApplyConfiguration(ctx context.Context, in *machine.ApplyConfigurationRequest) (reply *machine.ApplyConfigurationResponse, err error) {
if in.NoReboot {
return nil, fmt.Errorf("apply configuration without reboot is not supported in maintenance mode")
if in.OnReboot {
return nil, fmt.Errorf("apply configuration on reboot is not supported in maintenance mode")
}

cfgProvider, err := configloader.NewFromBytes(in.GetData())
Expand Down
8 changes: 4 additions & 4 deletions internal/integration/api/apply-config.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ func (suite *ApplyConfigSuite) TestApply() {
)
}

// TestApplyNoReboot verifies the apply config API without reboot.
func (suite *ApplyConfigSuite) TestApplyNoReboot() {
// TestApplyOnReboot verifies the apply config API without reboot.
func (suite *ApplyConfigSuite) TestApplyOnReboot() {
suite.WaitForBootDone(suite.ctx)

node := suite.RandomDiscoveredNode()
Expand All @@ -149,7 +149,7 @@ func (suite *ApplyConfigSuite) TestApplyNoReboot() {
suite.Require().NoError(err, "failed to marshal updated machine config data (node %q)", node)

_, err = suite.Client.ApplyConfiguration(nodeCtx, &machineapi.ApplyConfigurationRequest{
NoReboot: true,
OnReboot: true,
Data: cfgDataOut,
})
suite.Require().NoError(err, "failed to apply deferred configuration (node %q): %w", node)
Expand All @@ -173,7 +173,7 @@ func (suite *ApplyConfigSuite) TestApplyNoReboot() {
suite.Require().NoError(err, "failed to marshal updated machine config data (node %q)", node)

_, err = suite.Client.ApplyConfiguration(nodeCtx, &machineapi.ApplyConfigurationRequest{
NoReboot: true,
OnReboot: true,
Data: cfgDataOut,
})
suite.Require().NoError(err, "failed to apply deferred configuration (node %q): %w", node)
Expand Down
10 changes: 5 additions & 5 deletions pkg/machinery/api/machine/machine.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion website/content/docs/v0.9/Reference/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ node.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| data | [bytes](#bytes) | | |
| no_reboot | [bool](#bool) | | |
| on_reboot | [bool](#bool) | | |



Expand Down
2 changes: 1 addition & 1 deletion website/content/docs/v0.9/Reference/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ talosctl apply-config [flags]
-h, --help help for apply-config
-i, --insecure apply the config using the insecure (encrypted with no auth) maintenance service
--interactive apply the config using text based interactive mode
--no-reboot apply the config only after the reboot
--on-reboot apply the config on reboot
```

### Options inherited from parent commands
Expand Down

0 comments on commit cc83b83

Please sign in to comment.