Add automatic cluster pool allocation.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
keyhan
2026-05-18 23:08:06 +03:30
parent 97e4c865b6
commit 72a1519ea0
19 changed files with 983 additions and 151 deletions
@@ -0,0 +1,64 @@
import {
Entity,
PrimaryGeneratedColumn,
Column,
ManyToOne,
JoinColumn,
CreateDateColumn,
} from 'typeorm';
import { Cluster } from './cluster.entity';
import { ClusterPool, PoolStrategy } from './cluster-pool.entity';
import { Application } from '../../applications/entities/application.entity';
export type ClusterAllocationStatus = 'success' | 'failed';
@Entity('cluster_allocation_logs')
export class ClusterAllocationLog {
@PrimaryGeneratedColumn('uuid')
id: string;
@Column({ nullable: true })
applicationId?: string | null;
@ManyToOne(() => Application, { nullable: true, onDelete: 'SET NULL' })
@JoinColumn({ name: 'applicationId' })
application: Application;
@Column()
userId: string;
@Column({ nullable: true })
poolId?: string | null;
@ManyToOne(() => ClusterPool, { nullable: true, onDelete: 'SET NULL' })
@JoinColumn({ name: 'poolId' })
pool: ClusterPool;
@Column({ nullable: true })
selectedClusterId?: string | null;
@ManyToOne(() => Cluster, { nullable: true, onDelete: 'SET NULL' })
@JoinColumn({ name: 'selectedClusterId' })
selectedCluster: Cluster;
@Column({ default: 'weighted-resource' })
strategy: PoolStrategy;
@Column({ type: 'jsonb', nullable: true })
estimatedRequest: Record<string, any>;
@Column({ type: 'jsonb', nullable: true })
candidateScores: Record<string, any>[];
@Column({ type: 'jsonb', nullable: true })
rejectionReasons: Record<string, any>[];
@Column({ default: 'success' })
status: ClusterAllocationStatus;
@Column({ nullable: true })
message: string;
@CreateDateColumn()
createdAt: Date;
}