GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — perf(sac): remove cluster and namespace store caches · stackrox/stackrox@9c07886

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • central
    • cluster
      • datastore
        • datastore.go
        • datastore_impl.go
        • datastore_impl_postgres_test.go
        • datastore_sac_test.go
        • mocks
          • datastore.go
      • store/cluster
        • mocks
          • store.go
        • postgres
          • gen.go
          • store.go
          • store_consistency_test.go
        • store.go
    • namespace/datastore
      • datastore.go
      • datastore_sac_test.go
      • datastore_test.go
      • internal/store
        • mocks
          • store.go
        • postgres
          • gen.go
          • store.go
          • store_consistency_test.go
        • store.go
      • mocks
        • datastore.go
    • sac/authorizer
      • README.md
      • builtin_scoped_authorizer.go
      • scope_inventory.go
      • scope_inventory_benchmark_test.go
      • scope_inventory_test.go
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎central/cluster/datastore/datastore.go‎

Copy file name to clipboardExpand all lines: central/cluster/datastore/datastore.go
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ type DataStore interface {
4949
GetClusterID(ctx context.Context, name string) (string, bool, error)
5050
GetClusterName(ctx context.Context, id string) (string, bool, error)
5151
GetClusters(ctx context.Context) ([]*storage.Cluster, error)
52-
GetClustersForSAC() ([]effectiveaccessscope.Cluster, error)
52+
GetClustersForSAC(ctx context.Context) ([]effectiveaccessscope.Cluster, error)
5353
GetClusterLabels(ctx context.Context, clusterID string) (map[string]string, error)
5454
CountClusters(ctx context.Context) (int, error)
5555
Exists(ctx context.Context, id string) (bool, error)
Collapse file

‎central/cluster/datastore/datastore_impl.go‎

Copy file name to clipboardExpand all lines: central/cluster/datastore/datastore_impl.go
+14-3Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717
clusterHealthStore "github.com/stackrox/rox/central/cluster/store/clusterhealth"
1818
clusterInitStore "github.com/stackrox/rox/central/clusterinit/store"
1919
compliancePruning "github.com/stackrox/rox/central/complianceoperator/v2/pruner"
20-
"github.com/stackrox/rox/central/convert/storagetoeffectiveaccessscope"
2120
clusterCVEDS "github.com/stackrox/rox/central/cve/cluster/datastore"
2221
deploymentDataStore "github.com/stackrox/rox/central/deployment/datastore"
2322
imageIntegrationDataStore "github.com/stackrox/rox/central/imageintegration/datastore"
@@ -364,8 +363,20 @@ func (ds *datastoreImpl) GetClusters(ctx context.Context) ([]*storage.Cluster, e
364363
return ds.searchRawClusters(ctx, pkgSearch.EmptyQuery())
365364
}
366365

367-
func (ds *datastoreImpl) GetClustersForSAC() ([]effectiveaccessscope.Cluster, error) {
368-
return storagetoeffectiveaccessscope.Clusters(ds.clusterStorage.GetAllFromCacheForSAC()), nil
366+
func (ds *datastoreImpl) GetClustersForSAC(ctx context.Context) ([]effectiveaccessscope.Cluster, error) {
367+
var clusters []effectiveaccessscope.Cluster
368+
err := ds.clusterStorage.Walk(sac.WithAllAccess(ctx), func(cluster *storage.Cluster) error {
369+
clusters = append(clusters, &storage.Cluster{
370+
Id: cluster.GetId(),
371+
Name: cluster.GetName(),
372+
Labels: cluster.GetLabels(),
373+
})
374+
return nil
375+
})
376+
if err != nil {
377+
return nil, err
378+
}
379+
return clusters, nil
369380
}
370381

371382
func (ds *datastoreImpl) GetClusterName(ctx context.Context, id string) (string, bool, error) {
Collapse file

‎central/cluster/datastore/datastore_impl_postgres_test.go‎

Copy file name to clipboardExpand all lines: central/cluster/datastore/datastore_impl_postgres_test.go
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ import (
5757
)
5858

5959
const (
60-
fakeClusterID = "FAKECLUSTERID"
60+
fakeClusterID = "00000000-0000-4000-8000-000000000001"
6161
mainImage = "docker.io/stackrox/rox:latest"
6262
centralEndpoint = "central.stackrox:443"
6363
)
Collapse file

‎central/cluster/datastore/datastore_sac_test.go‎

Copy file name to clipboardExpand all lines: central/cluster/datastore/datastore_sac_test.go
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ func (s *clusterDatastoreSACSuite) TestGetClustersForSAC() {
349349
defer s.deleteCluster(clusterID2)
350350
s.Require().NoError(err)
351351

352-
clusters, err := s.datastore.GetClustersForSAC()
352+
clusters, err := s.datastore.GetClustersForSAC(context.Background())
353353
s.NoError(err)
354354
clusterNames := make([]string, 0, len(clusters))
355355
for _, cluster := range clusters {
Collapse file

‎central/cluster/datastore/mocks/datastore.go‎

Copy file name to clipboardExpand all lines: central/cluster/datastore/mocks/datastore.go
+4-4Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file

‎central/cluster/store/cluster/mocks/store.go‎

Copy file name to clipboardExpand all lines: central/cluster/store/cluster/mocks/store.go
-14Lines changed: 0 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file

‎central/cluster/store/cluster/postgres/gen.go‎

Copy file name to clipboardExpand all lines: central/cluster/store/cluster/postgres/gen.go
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ package postgres
22

33
// Cluster store does not use Postgres CopyFrom operation to copy data into DB. This is because copyFrom requires an
44
// explicit delete prior to copy consequently prohibiting references to clusters table.
5-
//go:generate pg-table-bindings-wrapper --type=storage.Cluster --cached-store --for-sac --search-category CLUSTERS --no-copy-from --default-sort search.Cluster.String()
5+
//go:generate pg-table-bindings-wrapper --type=storage.Cluster --search-category CLUSTERS --no-copy-from --default-sort search.Cluster.String()
Collapse file

‎central/cluster/store/cluster/postgres/store.go‎

Copy file name to clipboardExpand all lines: central/cluster/store/cluster/postgres/store.go
+1-12Lines changed: 1 addition & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file

‎central/cluster/store/cluster/postgres/store_consistency_test.go‎

Copy file name to clipboard
+43Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
//go:build sql_integration
2+
3+
package postgres
4+
5+
import (
6+
"context"
7+
8+
"github.com/stackrox/rox/generated/storage"
9+
"github.com/stackrox/rox/pkg/sac"
10+
"github.com/stackrox/rox/pkg/uuid"
11+
)
12+
13+
func (s *ClustersStoreSuite) TestReadsObserveOtherStoreWrites() {
14+
ctx := sac.WithAllAccess(context.Background())
15+
writer := New(s.testDB.DB)
16+
cluster := &storage.Cluster{Id: uuid.NewV4().String(), Name: "shared-cluster", Labels: map[string]string{"team": "initial"}}
17+
_, found, err := s.store.Get(ctx, cluster.GetId())
18+
s.Require().NoError(err)
19+
s.Require().False(found)
20+
21+
s.Require().NoError(writer.Upsert(ctx, cluster))
22+
result, found, err := s.store.Get(ctx, cluster.GetId())
23+
s.Require().NoError(err)
24+
s.Require().True(found)
25+
s.Equal(cluster.GetLabels(), result.GetLabels())
26+
27+
cluster.Labels = map[string]string{"team": "updated"}
28+
s.Require().NoError(writer.Upsert(ctx, cluster))
29+
results, missing, err := s.store.GetMany(ctx, []string{cluster.GetId()})
30+
s.Require().NoError(err)
31+
s.Require().Empty(missing)
32+
s.Require().Len(results, 1)
33+
s.Equal(cluster.GetLabels(), results[0].GetLabels())
34+
35+
s.Require().NoError(writer.Delete(ctx, cluster.GetId()))
36+
_, found, err = s.store.Get(ctx, cluster.GetId())
37+
s.Require().NoError(err)
38+
s.False(found)
39+
results, missing, err = s.store.GetMany(ctx, []string{cluster.GetId()})
40+
s.Require().NoError(err)
41+
s.Empty(results)
42+
s.Equal([]int{0}, missing)
43+
}
Collapse file

‎central/cluster/store/cluster/store.go‎

Copy file name to clipboardExpand all lines: central/cluster/store/cluster/store.go
-3Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,4 @@ type Store interface {
2121

2222
Walk(ctx context.Context, fn func(obj *storage.Cluster) error) error
2323
WalkByQuery(ctx context.Context, query *v1.Query, fn func(obj *storage.Cluster) error) error
24-
25-
// Deprecated: It will not clone the object so it should be used only for SAC.
26-
GetAllFromCacheForSAC() []*storage.Cluster
2724
}

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.