From 30260f06e874d3cba077b0c26268f6b83875b541 Mon Sep 17 00:00:00 2001 From: hc-github-team-nomad-core <82989552+hc-github-team-nomad-core@users.noreply.github.com> Date: Thu, 20 Jul 2023 15:05:16 -0500 Subject: [PATCH] Backport of state: canonicalize namespace on restore into release/1.6.x (#18018) This pull request was automerged via backport-assistant --- .changelog/18017.txt | 3 +++ nomad/state/state_store_restore.go | 2 ++ 2 files changed, 5 insertions(+) create mode 100644 .changelog/18017.txt diff --git a/.changelog/18017.txt b/.changelog/18017.txt new file mode 100644 index 000000000..13611f702 --- /dev/null +++ b/.changelog/18017.txt @@ -0,0 +1,3 @@ +```release-note:bug +core: Fixed a bug where namespaces were not canonicalized on snapshot restore, resulting in potential nil access panic +``` diff --git a/nomad/state/state_store_restore.go b/nomad/state/state_store_restore.go index 166694f6d..4c9dbefb5 100644 --- a/nomad/state/state_store_restore.go +++ b/nomad/state/state_store_restore.go @@ -205,6 +205,8 @@ func (r *StateRestore) ScalingEventsRestore(jobEvents *structs.JobScalingEvents) // NamespaceRestore is used to restore a namespace func (r *StateRestore) NamespaceRestore(ns *structs.Namespace) error { + // Handle upgrade path. + ns.Canonicalize() if err := r.txn.Insert(TableNamespaces, ns); err != nil { return fmt.Errorf("namespace insert failed: %v", err) }