diff --git a/grid-proxy/CHANGELOG.md b/grid-proxy/CHANGELOG.md index db15df589..6f8961075 100644 --- a/grid-proxy/CHANGELOG.md +++ b/grid-proxy/CHANGELOG.md @@ -12,7 +12,7 @@ Check `/version` on any instance to know the version. ## Releases -### v0.15.8 +### v0.15.9 --- diff --git a/grid-proxy/charts/gridproxy/Chart.yaml b/grid-proxy/charts/gridproxy/Chart.yaml index ed974f30b..803b6e124 100644 --- a/grid-proxy/charts/gridproxy/Chart.yaml +++ b/grid-proxy/charts/gridproxy/Chart.yaml @@ -20,6 +20,6 @@ version: 1.0.0 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. -appVersion: 0.15.8 +appVersion: 0.15.9 # make sure to update the changelog with the changes in this release diff --git a/grid-proxy/internal/explorer/db/postgres.go b/grid-proxy/internal/explorer/db/postgres.go index af5c235eb..fadc3d812 100644 --- a/grid-proxy/internal/explorer/db/postgres.go +++ b/grid-proxy/internal/explorer/db/postgres.go @@ -136,23 +136,25 @@ func (d *PostgresDatabase) GetLastUpsertsTimestamp() (types.IndexersState, error } func (d *PostgresDatabase) Initialize() error { - err := d.gormDB.AutoMigrate( + if err := d.gormDB.AutoMigrate( &types.NodeGPU{}, &types.HealthReport{}, &types.Dmi{}, &types.Speed{}, &types.HasIpv6{}, &types.NodesWorkloads{}, - ) - if err != nil { + ); err != nil { return errors.Wrap(err, "failed to migrate indexer tables") } - err = d.gormDB.Exec(setupFile).Error - if err != nil { + if err := d.gormDB.Exec(setupFile).Error; err != nil { return errors.Wrap(err, "failed to setup cache tables") } + if err := d.gormDB.Exec(`ALTER TABLE node_gpu DROP CONSTRAINT IF EXISTS node_gpu_pkey;`).Error; err != nil { + return errors.Wrap(err, "failed to drop the node_gpu_pkey constraint") + } + return nil } diff --git a/grid-proxy/internal/indexer/health.go b/grid-proxy/internal/indexer/health.go index cf891e7ba..b1ee68e84 100644 --- a/grid-proxy/internal/indexer/health.go +++ b/grid-proxy/internal/indexer/health.go @@ -39,6 +39,8 @@ func (w *HealthWork) Get(ctx context.Context, rmb *peer.RpcClient, twinId uint32 } func (w *HealthWork) Upsert(ctx context.Context, db db.Database, batch []types.HealthReport) error { + // to prevent having multiple data for the same twin from different finders + batch = removeDuplicates(batch) return db.UpsertNodeHealth(ctx, batch) } @@ -57,3 +59,16 @@ func getHealthReport(response interface{}, err error, twinId uint32) types.Healt report.Healthy = true return report } + +func removeDuplicates(reports []types.HealthReport) []types.HealthReport { + seen := make(map[uint32]bool) + result := []types.HealthReport{} + for _, report := range reports { + if _, ok := seen[report.NodeTwinId]; !ok { + seen[report.NodeTwinId] = true + result = append(result, report) + } + } + + return result +}