From f7de2cc0225b8b377b09124704860b2748b458df Mon Sep 17 00:00:00 2001 From: cskh Date: Mon, 8 May 2023 14:06:41 +0000 Subject: [PATCH 1/5] backport of commit 99c3322dc1d07b22500d47c6a8f13468b3083022 --- agent/consul/server.go | 2 +- snapshot/snapshot.go | 3 ++- website/content/commands/snapshot/save.mdx | 5 ++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/agent/consul/server.go b/agent/consul/server.go index 1a8f40004180..34de77d63f92 100644 --- a/agent/consul/server.go +++ b/agent/consul/server.go @@ -1050,7 +1050,7 @@ func (s *Server) setupRaft() error { log = cacheStore // Create the snapshot store. - snapshots, err := raft.NewFileSnapshotStoreWithLogger(path, snapshotsRetained, s.logger.Named("snapshot")) + snapshots, err := raft.NewFileSnapshotStoreWithLogger(path, snapshotsRetained, s.logger.Named("raft.snapshot")) if err != nil { return err } diff --git a/snapshot/snapshot.go b/snapshot/snapshot.go index 691f4bc8e114..acbc4c86012d 100644 --- a/snapshot/snapshot.go +++ b/snapshot/snapshot.go @@ -50,6 +50,7 @@ func New(logger hclog.Logger, r *raft.Raft) (*Snapshot, error) { if err != nil { return nil, fmt.Errorf("failed to create snapshot file: %v", err) } + logger.Info("creating temporary file of snapshot", "path", archive.Name()) // If anything goes wrong after this point, we will attempt to clean up // the temp file. The happy path will disarm this. @@ -109,7 +110,7 @@ func (s *Snapshot) Read(p []byte) (n int, err error) { } // Close closes the snapshot and removes any temporary storage associated with -// it. You must arrange to call this whenever NewSnapshot() has been called +// it. You must arrange to call this whenever New() has been called // successfully. This is safe to call on a nil snapshot. func (s *Snapshot) Close() error { if s == nil { diff --git a/website/content/commands/snapshot/save.mdx b/website/content/commands/snapshot/save.mdx index 63b0fbe48f3d..6e24d453e76e 100644 --- a/website/content/commands/snapshot/save.mdx +++ b/website/content/commands/snapshot/save.mdx @@ -20,7 +20,8 @@ If ACLs are enabled, a management token must be supplied in order to perform a snapshot save. -> Note that saving a snapshot involves the server process writing the snapshot to a -temporary file on-disk before sending that file to the CLI client. The default location +temporary file on-disk before sending that file to the CLI client. Upon successful completion, +the temporary file will be removed. The default location of the temporary file can vary depending on operating system, but typically is `/tmp`. You can get more detailed information on default locations in the Go documentation for [os.TempDir](https://golang.org/pkg/os/#TempDir). If you need to change this location, you can do so by setting the `TMPDIR` environment @@ -28,6 +29,8 @@ variable for the Consul server processes. Keep in mind that setting the environm the CLI client attempting to perform a snapshot save will have no effect. It _must_ be set in the context of the server process. If you're using Systemd to manage your Consul server processes, then adding `Environment=TMPDIR=/path/to/dir` to your Consul unit file will work. +Another side effect is that one snapshot file is also taken at `data_dir/raft/snapshops`, +resulting from Raft snapshot. The table below shows this command's [required ACLs](/consul/api-docs/api-structure#authentication). Configuration of [blocking queries](/consul/api-docs/features/blocking) and [agent caching](/consul/api-docs/features/caching) From d3495e5741eb045f4c01cf27f4370c83a0f4faa0 Mon Sep 17 00:00:00 2001 From: cskh Date: Mon, 8 May 2023 16:22:53 +0000 Subject: [PATCH 2/5] backport of commit 757f22b518f59d97ce5f6b9a60fcc3a39d639000 --- website/content/commands/snapshot/save.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/content/commands/snapshot/save.mdx b/website/content/commands/snapshot/save.mdx index 6e24d453e76e..ab8f81563cfe 100644 --- a/website/content/commands/snapshot/save.mdx +++ b/website/content/commands/snapshot/save.mdx @@ -21,7 +21,7 @@ a snapshot save. -> Note that saving a snapshot involves the server process writing the snapshot to a temporary file on-disk before sending that file to the CLI client. Upon successful completion, -the temporary file will be removed. The default location of the temporary file +Consul removes the temporary file. The default location of the temporary file can vary depending on operating system, but typically is `/tmp`. You can get more detailed information on default locations in the Go documentation for [os.TempDir](https://golang.org/pkg/os/#TempDir). If you need to change this location, you can do so by setting the `TMPDIR` environment From 9fa4c03da099aced23a6032a7f0df55856a8f2d4 Mon Sep 17 00:00:00 2001 From: cskh Date: Tue, 9 May 2023 14:45:04 +0000 Subject: [PATCH 3/5] backport of commit 7eda9c7f220ac29ea0d9ab652e2b1f720dd72c85 --- website/content/commands/snapshot/save.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/content/commands/snapshot/save.mdx b/website/content/commands/snapshot/save.mdx index ab8f81563cfe..bff70f4feea7 100644 --- a/website/content/commands/snapshot/save.mdx +++ b/website/content/commands/snapshot/save.mdx @@ -29,7 +29,7 @@ variable for the Consul server processes. Keep in mind that setting the environm the CLI client attempting to perform a snapshot save will have no effect. It _must_ be set in the context of the server process. If you're using Systemd to manage your Consul server processes, then adding `Environment=TMPDIR=/path/to/dir` to your Consul unit file will work. -Another side effect is that one snapshot file is also taken at `data_dir/raft/snapshops`, +Another side effect is that one snapshot file is also taken at `data_dir/raft/snapshots`, resulting from Raft snapshot. The table below shows this command's [required ACLs](/consul/api-docs/api-structure#authentication). Configuration of From 9e1d35d6571fc4886996ac4174994dc7817fd719 Mon Sep 17 00:00:00 2001 From: cskh Date: Tue, 9 May 2023 15:54:59 +0000 Subject: [PATCH 4/5] backport of commit 8124fb33aeef1bdf830c09f710f62308cae6db24 --- .changelog/17236.txt | 3 +++ snapshot/snapshot.go | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 .changelog/17236.txt diff --git a/.changelog/17236.txt b/.changelog/17236.txt new file mode 100644 index 000000000000..c824bb7ed782 --- /dev/null +++ b/.changelog/17236.txt @@ -0,0 +1,3 @@ +```release-note:improvement +logging: change snapshot log header from `agent.server.snapshot` to `agent.server.raft.snapshot` +``` diff --git a/snapshot/snapshot.go b/snapshot/snapshot.go index acbc4c86012d..eafe7076b2b8 100644 --- a/snapshot/snapshot.go +++ b/snapshot/snapshot.go @@ -50,7 +50,7 @@ func New(logger hclog.Logger, r *raft.Raft) (*Snapshot, error) { if err != nil { return nil, fmt.Errorf("failed to create snapshot file: %v", err) } - logger.Info("creating temporary file of snapshot", "path", archive.Name()) + logger.Debug("creating temporary file of snapshot", "path", archive.Name()) // If anything goes wrong after this point, we will attempt to clean up // the temp file. The happy path will disarm this. From 780cdd0b27e41f56dc658980307cbfa40877e25c Mon Sep 17 00:00:00 2001 From: cskh Date: Tue, 9 May 2023 16:00:37 +0000 Subject: [PATCH 5/5] backport of commit 164cada247fc1e87dd74751c22313e856843e9ff --- website/content/commands/snapshot/save.mdx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/website/content/commands/snapshot/save.mdx b/website/content/commands/snapshot/save.mdx index bff70f4feea7..18ffc50150ab 100644 --- a/website/content/commands/snapshot/save.mdx +++ b/website/content/commands/snapshot/save.mdx @@ -29,8 +29,7 @@ variable for the Consul server processes. Keep in mind that setting the environm the CLI client attempting to perform a snapshot save will have no effect. It _must_ be set in the context of the server process. If you're using Systemd to manage your Consul server processes, then adding `Environment=TMPDIR=/path/to/dir` to your Consul unit file will work. -Another side effect is that one snapshot file is also taken at `data_dir/raft/snapshots`, -resulting from Raft snapshot. +As a result of the Raft snapshot, Consul also saves one snapshot file at `data_dir/raft/snapshots`. The table below shows this command's [required ACLs](/consul/api-docs/api-structure#authentication). Configuration of [blocking queries](/consul/api-docs/features/blocking) and [agent caching](/consul/api-docs/features/caching)