diff --git a/agent/consul/state/catalog_test.go b/agent/consul/state/catalog_test.go index b68a76aca2..054e3a5e88 100644 --- a/agent/consul/state/catalog_test.go +++ b/agent/consul/state/catalog_test.go @@ -2950,7 +2950,7 @@ func ensureIndexForService(t *testing.T, s *Store, serviceName string, expectedI t.Helper() tx := s.db.Txn(false) defer tx.Abort() - transaction, err := tx.First("index", "id", serviceIndexName(serviceName, nil)) + transaction, err := tx.First(tableIndex, "id", serviceIndexName(serviceName, nil)) if err == nil { if idx, ok := transaction.(*IndexEntry); ok { if expectedIndex != idx.Value { diff --git a/agent/consul/state/config_entry.go b/agent/consul/state/config_entry.go index 318178a2f0..e396ab7b2d 100644 --- a/agent/consul/state/config_entry.go +++ b/agent/consul/state/config_entry.go @@ -295,7 +295,7 @@ func deleteConfigEntryTxn(tx WriteTxn, idx uint64, kind, name string, entMeta *s if err := tx.Delete(tableConfigEntries, existing); err != nil { return fmt.Errorf("failed removing config entry: %s", err) } - if err := tx.Insert("index", &IndexEntry{tableConfigEntries, idx}); err != nil { + if err := tx.Insert(tableIndex, &IndexEntry{tableConfigEntries, idx}); err != nil { return fmt.Errorf("failed updating index: %s", err) } diff --git a/agent/consul/state/connect_ca.go b/agent/consul/state/connect_ca.go index 44225ddd3e..e3e89f852d 100644 --- a/agent/consul/state/connect_ca.go +++ b/agent/consul/state/connect_ca.go @@ -326,7 +326,7 @@ func (s *Store) CARootSetCAS(idx, cidx uint64, rs []*structs.CARoot) (bool, erro } // Update the index - if err := tx.Insert("index", &IndexEntry{tableConnectCARoots, idx}); err != nil { + if err := tx.Insert(tableIndex, &IndexEntry{tableConnectCARoots, idx}); err != nil { return false, fmt.Errorf("failed updating index: %s", err) } @@ -407,7 +407,7 @@ func (s *Store) CASetProviderState(idx uint64, state *structs.CAConsulProviderSt } // Update the index - if err := tx.Insert("index", &IndexEntry{tableConnectCABuiltin, idx}); err != nil { + if err := tx.Insert(tableIndex, &IndexEntry{tableConnectCABuiltin, idx}); err != nil { return false, fmt.Errorf("failed updating index: %s", err) } @@ -436,7 +436,7 @@ func (s *Store) CADeleteProviderState(idx uint64, id string) error { if err := tx.Delete(tableConnectCABuiltin, providerState); err != nil { return err } - if err := tx.Insert("index", &IndexEntry{tableConnectCABuiltin, idx}); err != nil { + if err := tx.Insert(tableIndex, &IndexEntry{tableConnectCABuiltin, idx}); err != nil { return fmt.Errorf("failed updating index: %s", err) } @@ -476,7 +476,7 @@ func (s *Store) CAIncrementProviderSerialNumber(idx uint64) (uint64, error) { tx := s.db.WriteTxn(idx) defer tx.Abort() - existing, err := tx.First("index", "id", tableConnectCABuiltinSerial) + existing, err := tx.First(tableIndex, "id", tableConnectCABuiltinSerial) if err != nil { return 0, fmt.Errorf("failed built-in CA serial number lookup: %s", err) } @@ -491,7 +491,7 @@ func (s *Store) CAIncrementProviderSerialNumber(idx uint64) (uint64, error) { } next := last + 1 - if err := tx.Insert("index", &IndexEntry{tableConnectCABuiltinSerial, next}); err != nil { + if err := tx.Insert(tableIndex, &IndexEntry{tableConnectCABuiltinSerial, next}); err != nil { return 0, fmt.Errorf("failed updating index: %s", err) } diff --git a/agent/consul/state/coordinate.go b/agent/consul/state/coordinate.go index 0a9c43d09a..e5b3ec7464 100644 --- a/agent/consul/state/coordinate.go +++ b/agent/consul/state/coordinate.go @@ -160,7 +160,7 @@ func (s *Store) CoordinateBatchUpdate(idx uint64, updates structs.Coordinates) e } // Update the index. - if err := tx.Insert("index", &IndexEntry{"coordinates", idx}); err != nil { + if err := tx.Insert(tableIndex, &IndexEntry{"coordinates", idx}); err != nil { return fmt.Errorf("failed updating index: %s", err) } diff --git a/agent/consul/state/federation_state.go b/agent/consul/state/federation_state.go index c4026e4063..c7eababf26 100644 --- a/agent/consul/state/federation_state.go +++ b/agent/consul/state/federation_state.go @@ -117,7 +117,7 @@ func federationStateSetTxn(tx WriteTxn, idx uint64, config *structs.FederationSt if err := tx.Insert(tableFederationStates, config); err != nil { return fmt.Errorf("failed inserting federation state: %s", err) } - if err := tx.Insert("index", &IndexEntry{tableFederationStates, idx}); err != nil { + if err := tx.Insert(tableIndex, &IndexEntry{tableFederationStates, idx}); err != nil { return fmt.Errorf("failed updating index: %v", err) } @@ -216,7 +216,7 @@ func federationStateDeleteTxn(tx WriteTxn, idx uint64, datacenter string) error if err := tx.Delete(tableFederationStates, existing); err != nil { return fmt.Errorf("failed removing federation state: %s", err) } - if err := tx.Insert("index", &IndexEntry{tableFederationStates, idx}); err != nil { + if err := tx.Insert(tableIndex, &IndexEntry{tableFederationStates, idx}); err != nil { return fmt.Errorf("failed updating index: %s", err) } return nil diff --git a/agent/consul/state/graveyard_oss.go b/agent/consul/state/graveyard_oss.go index d4ee5848a6..201f77dc03 100644 --- a/agent/consul/state/graveyard_oss.go +++ b/agent/consul/state/graveyard_oss.go @@ -16,7 +16,7 @@ func (g *Graveyard) insertTombstoneWithTxn(tx WriteTxn, _ string, stone *Tombsto return fmt.Errorf("failed updating tombstone index: %v", err) } } else { - if err := tx.Insert("index", &IndexEntry{"tombstones", stone.Index}); err != nil { + if err := tx.Insert(tableIndex, &IndexEntry{"tombstones", stone.Index}); err != nil { return fmt.Errorf("failed updating tombstone index: %s", err) } } diff --git a/agent/consul/state/intention.go b/agent/consul/state/intention.go index 5e661a90b6..418e3ee8d3 100644 --- a/agent/consul/state/intention.go +++ b/agent/consul/state/intention.go @@ -561,7 +561,7 @@ func legacyIntentionSetTxn(tx WriteTxn, idx uint64, ixn *structs.Intention) erro if err := tx.Insert(tableConnectIntentions, ixn); err != nil { return err } - if err := tx.Insert("index", &IndexEntry{tableConnectIntentions, idx}); err != nil { + if err := tx.Insert(tableIndex, &IndexEntry{tableConnectIntentions, idx}); err != nil { return fmt.Errorf("failed updating index: %s", err) } @@ -689,7 +689,7 @@ func legacyIntentionDeleteTxn(tx WriteTxn, idx uint64, queryID string) error { if err := tx.Delete(tableConnectIntentions, wrapped); err != nil { return fmt.Errorf("failed intention delete: %s", err) } - if err := tx.Insert("index", &IndexEntry{tableConnectIntentions, idx}); err != nil { + if err := tx.Insert(tableIndex, &IndexEntry{tableConnectIntentions, idx}); err != nil { return fmt.Errorf("failed updating index: %s", err) } @@ -706,13 +706,13 @@ func (s *Store) LegacyIntentionDeleteAll(idx uint64) error { if _, err := tx.DeleteAll(tableConnectIntentions, "id"); err != nil { return fmt.Errorf("failed intention delete-all: %s", err) } - if err := tx.Insert("index", &IndexEntry{tableConnectIntentions, idx}); err != nil { + if err := tx.Insert(tableIndex, &IndexEntry{tableConnectIntentions, idx}); err != nil { return fmt.Errorf("failed updating index: %s", err) } // Also bump the index for the config entry table so that // secondaries can correctly know when they've replicated all of the service-intentions // config entries that USED to exist in the old intentions table. - if err := tx.Insert("index", &IndexEntry{tableConfigEntries, idx}); err != nil { + if err := tx.Insert(tableIndex, &IndexEntry{tableConfigEntries, idx}); err != nil { return fmt.Errorf("failed updating index: %s", err) } diff --git a/agent/consul/state/prepared_query.go b/agent/consul/state/prepared_query.go index 0bbcb1d747..8d23645112 100644 --- a/agent/consul/state/prepared_query.go +++ b/agent/consul/state/prepared_query.go @@ -234,7 +234,7 @@ func preparedQuerySetTxn(tx WriteTxn, idx uint64, query *structs.PreparedQuery) if err := tx.Insert("prepared-queries", &queryWrapper{query, ct}); err != nil { return fmt.Errorf("failed inserting prepared query: %s", err) } - if err := tx.Insert("index", &IndexEntry{"prepared-queries", idx}); err != nil { + if err := tx.Insert(tableIndex, &IndexEntry{"prepared-queries", idx}); err != nil { return fmt.Errorf("failed updating index: %s", err) } @@ -269,7 +269,7 @@ func preparedQueryDeleteTxn(tx WriteTxn, idx uint64, queryID string) error { if err := tx.Delete("prepared-queries", wrapped); err != nil { return fmt.Errorf("failed prepared query delete: %s", err) } - if err := tx.Insert("index", &IndexEntry{"prepared-queries", idx}); err != nil { + if err := tx.Insert(tableIndex, &IndexEntry{"prepared-queries", idx}); err != nil { return fmt.Errorf("failed updating index: %s", err) } diff --git a/agent/consul/state/session_oss.go b/agent/consul/state/session_oss.go index 52c0593f86..16eb026ddf 100644 --- a/agent/consul/state/session_oss.go +++ b/agent/consul/state/session_oss.go @@ -42,7 +42,7 @@ func sessionDeleteWithSession(tx WriteTxn, session *structs.Session, idx uint64) } // Update the indexes - err := tx.Insert("index", &IndexEntry{"sessions", idx}) + err := tx.Insert(tableIndex, &IndexEntry{"sessions", idx}) if err != nil { return fmt.Errorf("failed updating sessions index: %v", err) } @@ -72,7 +72,7 @@ func insertSessionTxn(tx WriteTxn, session *structs.Session, idx uint64, updateM return fmt.Errorf("failed updating sessions index: %v", err) } } else { - err := tx.Insert("index", &IndexEntry{"sessions", idx}) + err := tx.Insert(tableIndex, &IndexEntry{"sessions", idx}) if err != nil { return fmt.Errorf("failed updating sessions index: %v", err) }