From cc83b8380825d709c9f1ceeba1ff39eb78f14e89 Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Wed, 17 Feb 2021 19:15:02 +0300 Subject: [PATCH] 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 --- api/machine/machine.proto | 2 +- cmd/talosctl/cmd/talos/apply-config.go | 10 +++++++--- .../internal/server/v1alpha1/v1alpha1_server.go | 2 +- internal/app/maintenance/server/server.go | 4 ++-- internal/integration/api/apply-config.go | 8 ++++---- pkg/machinery/api/machine/machine.pb.go | 10 +++++----- website/content/docs/v0.9/Reference/api.md | 2 +- website/content/docs/v0.9/Reference/cli.md | 2 +- 8 files changed, 22 insertions(+), 18 deletions(-) diff --git a/api/machine/machine.proto b/api/machine/machine.proto index 46ac4bc279..a1f1593d5d 100644 --- a/api/machine/machine.proto +++ b/api/machine/machine.proto @@ -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. diff --git a/cmd/talosctl/cmd/talos/apply-config.go b/cmd/talosctl/cmd/talos/apply-config.go index e6d6777f21..5bc6334968 100644 --- a/cmd/talosctl/cmd/talos/apply-config.go +++ b/cmd/talosctl/cmd/talos/apply-config.go @@ -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) } diff --git a/internal/app/machined/internal/server/v1alpha1/v1alpha1_server.go b/internal/app/machined/internal/server/v1alpha1/v1alpha1_server.go index ecc534893a..a7c33a6fd4 100644 --- a/internal/app/machined/internal/server/v1alpha1/v1alpha1_server.go +++ b/internal/app/machined/internal/server/v1alpha1/v1alpha1_server.go @@ -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 } diff --git a/internal/app/maintenance/server/server.go b/internal/app/maintenance/server/server.go index 17464f8b47..f4f9a3ff9b 100644 --- a/internal/app/maintenance/server/server.go +++ b/internal/app/maintenance/server/server.go @@ -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()) diff --git a/internal/integration/api/apply-config.go b/internal/integration/api/apply-config.go index d439c9870e..351e9cfaa1 100644 --- a/internal/integration/api/apply-config.go +++ b/internal/integration/api/apply-config.go @@ -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) diff --git a/pkg/machinery/api/machine/machine.pb.go b/pkg/machinery/api/machine/machine.pb.go index 61fdf0b6fe..39e8d40b98 100644 --- a/pkg/machinery/api/machine/machine.pb.go +++ b/pkg/machinery/api/machine/machine.pb.go @@ -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, diff --git a/website/content/docs/v0.9/Reference/api.md b/website/content/docs/v0.9/Reference/api.md index fb9ce092a9..218c42a925 100644 --- a/website/content/docs/v0.9/Reference/api.md +++ b/website/content/docs/v0.9/Reference/api.md @@ -615,7 +615,7 @@ node. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | | data | [bytes](#bytes) | | | -| no_reboot | [bool](#bool) | | | +| on_reboot | [bool](#bool) | | | diff --git a/website/content/docs/v0.9/Reference/cli.md b/website/content/docs/v0.9/Reference/cli.md index 167ee97f9c..b44317aba4 100644 --- a/website/content/docs/v0.9/Reference/cli.md +++ b/website/content/docs/v0.9/Reference/cli.md @@ -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