feat: rename apply-config --no-reboot to --on-reboot

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>
This commit is contained in:
Andrey Smirnov 2021-02-17 19:15:02 +03:00 committed by talos-bot
parent 254e0e91e1
commit cc83b83808
8 changed files with 22 additions and 18 deletions

View File

@ -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.

View File

@ -23,7 +23,7 @@ var applyConfigCmdFlags struct {
filename string
insecure bool
interactive bool
noReboot bool
onReboot bool
}
// applyConfigCmd represents the applyConfiguration command.
@ -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)
}
@ -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)
}

View File

@ -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
}

View File

@ -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())

View File

@ -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()
@ -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)
@ -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)

View File

@ -400,7 +400,7 @@ type ApplyConfigurationRequest struct {
unknownFields protoimpl.UnknownFields
Data []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
NoReboot bool `protobuf:"varint,2,opt,name=no_reboot,json=noReboot,proto3" json:"no_reboot,omitempty"`
OnReboot bool `protobuf:"varint,2,opt,name=on_reboot,json=onReboot,proto3" json:"on_reboot,omitempty"`
}
func (x *ApplyConfigurationRequest) Reset() {
@ -442,9 +442,9 @@ func (x *ApplyConfigurationRequest) GetData() []byte {
return nil
}
func (x *ApplyConfigurationRequest) GetNoReboot() bool {
func (x *ApplyConfigurationRequest) GetOnReboot() bool {
if x != nil {
return x.NoReboot
return x.OnReboot
}
return false
}
@ -8211,8 +8211,8 @@ var file_machine_machine_proto_rawDesc = []byte{
0x0a, 0x19, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61,
0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x64,
0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12,
0x1b, 0x0a, 0x09, 0x6e, 0x6f, 0x5f, 0x72, 0x65, 0x62, 0x6f, 0x6f, 0x74, 0x18, 0x02, 0x20, 0x01,
0x28, 0x08, 0x52, 0x08, 0x6e, 0x6f, 0x52, 0x65, 0x62, 0x6f, 0x6f, 0x74, 0x22, 0x42, 0x0a, 0x12,
0x1b, 0x0a, 0x09, 0x6f, 0x6e, 0x5f, 0x72, 0x65, 0x62, 0x6f, 0x6f, 0x74, 0x18, 0x02, 0x20, 0x01,
0x28, 0x08, 0x52, 0x08, 0x6f, 0x6e, 0x52, 0x65, 0x62, 0x6f, 0x6f, 0x74, 0x22, 0x42, 0x0a, 0x12,
0x41, 0x70, 0x70, 0x6c, 0x79, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69,
0x6f, 0x6e, 0x12, 0x2c, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01,
0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x4d, 0x65,

View File

@ -615,7 +615,7 @@ node.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| data | [bytes](#bytes) | | |
| no_reboot | [bool](#bool) | | |
| on_reboot | [bool](#bool) | | |

View File

@ -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