From c49f9f26111ba26fa3aceecb27c1d47710411797 Mon Sep 17 00:00:00 2001 From: Lang Martin Date: Tue, 15 Oct 2019 11:43:55 -0400 Subject: [PATCH] schema: csi_volumes schema --- nomad/state/schema.go | 44 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/nomad/state/schema.go b/nomad/state/schema.go index a5ec55e71..ffef13f0e 100644 --- a/nomad/state/schema.go +++ b/nomad/state/schema.go @@ -47,6 +47,7 @@ func init() { autopilotConfigTableSchema, schedulerConfigTableSchema, clusterMetaTableSchema, + csiVolumeTableSchema, }...) } @@ -677,3 +678,46 @@ func clusterMetaTableSchema() *memdb.TableSchema { }, } } + +func csiVolumeTableSchema() *memdb.TableSchema { + return &memdb.TableSchema{ + Name: "csi_volumes", + Indexes: map[string]*memdb.IndexSchema{ + // Primary index is used for volume upsert + // and simple direct lookup. ID is required to be + // unique. + "id": { + Name: "id", + AllowMissing: false, + Unique: true, + + // Use a compound so (Namespace, ID) is unique + Indexer: &memdb.CompoundIndex{ + Indexes: []memdb.Indexer{ + &memdb.StringFieldIndex{ + Field: "Namespace", + }, + &memdb.StringFieldIndex{ + Field: "ID", + }, + }, + }, + }, + "driver": { + Name: "driver", + AllowMissing: false, + Unique: false, + Indexer: &memdb.CompoundIndex{ + Indexes: []memdb.Indexer{ + &memdb.StringFieldIndex{ + Field: "Namespace", + }, + &memdb.StringFieldIndex{ + Field: "Driver", + }, + }, + }, + }, + }, + } +}