feat: [CDE-698]: Store gateway host in infra provisioned for full sync (#3598)

* feat: [CDE-698]: Remove unwanted changes
* feat: [CDE-698]: Store gateway host in infra provisioned for full sync
main
Vikyath Harekal 2025-03-27 05:11:25 +00:00 committed by Harness
parent 5c05642cce
commit 963197214e
8 changed files with 18 additions and 2 deletions

View File

@ -92,6 +92,7 @@ func (i InfraProvisioner) UpdateInfraProvisioned(
infraProvisionedLatest.ResponseMetadata = &responseMetaDataJSON
infraProvisionedLatest.Updated = time.Now().UnixMilli()
infraProvisionedLatest.GatewayHost = infrastructure.GatewayHost
err = i.infraProvisionedStore.Update(ctx, infraProvisionedLatest)
if err != nil {
return fmt.Errorf("unable to update infraProvisioned %d: %w", infraProvisionedLatest.ID, err)

View File

@ -43,7 +43,8 @@ const (
iprov_server_host_ip,
iprov_server_host_port,
iprov_proxy_host,
iprov_proxy_port
iprov_proxy_port,
iprov_gateway_host
`
infraProvisionedSelectColumns = infraProvisionedIDColumn + `,
` + infraProvisionedColumns
@ -71,6 +72,7 @@ type infraProvisioned struct {
ServerHostPort string `db:"iprov_server_host_port"`
ProxyHost string `db:"iprov_proxy_host"`
ProxyPort int32 `db:"iprov_proxy_port"`
GatewayHost string `db:"iprov_gateway_host"`
}
type infraProvisionedGatewayView struct {
@ -120,7 +122,7 @@ func (i infraProvisionedStore) FindAllLatestByGateway(
iprov_response_metadata`).
From(infraProvisionedTable).
Join(fmt.Sprintf("%s ON iprov_gitspace_id = gits_id", gitspaceInstanceTable)).
Where("iprov_proxy_host = ?", gatewayHost).
Where("iprov_gateway_host = ?", gatewayHost).
Where("iprov_infra_status = ?", enum.InfraStatusProvisioned).
OrderBy("iprov_created DESC")
@ -222,6 +224,7 @@ func (i infraProvisionedStore) Create(ctx context.Context, infraProvisioned *typ
infraProvisioned.ServerHostPort,
infraProvisioned.ProxyHost,
infraProvisioned.ProxyPort,
infraProvisioned.GatewayHost,
).
Suffix(ReturningClause + infraProvisionedIDColumn)
@ -269,6 +272,7 @@ func (i infraProvisionedStore) Update(ctx context.Context, infraProvisioned *typ
Set("iprov_updated", infraProvisioned.Updated).
Set("iprov_proxy_host", infraProvisioned.ProxyHost).
Set("iprov_proxy_port", infraProvisioned.ProxyPort).
Set("iprov_gateway_host", infraProvisioned.GatewayHost).
Where(infraProvisionedIDColumn+" = ?", infraProvisioned.ID)
sql, args, err := stmt.ToSql()
@ -301,5 +305,6 @@ func (entity infraProvisioned) toDTO() *types.InfraProvisioned {
ServerHostPort: entity.ServerHostPort,
ProxyHost: entity.ProxyHost,
ProxyPort: entity.ProxyPort,
GatewayHost: entity.GatewayHost,
}
}

View File

@ -0,0 +1,2 @@
ALTER TABLE infra_provisioned
DROP COLUMN iprov_gateway_host;

View File

@ -0,0 +1,2 @@
ALTER TABLE infra_provisioned
ADD COLUMN iprov_gateway_host TEXT NOT NULL DEFAULT '';

View File

@ -0,0 +1,2 @@
ALTER TABLE infra_provisioned
DROP COLUMN iprov_gateway_host;

View File

@ -0,0 +1,2 @@
ALTER TABLE infra_provisioned
ADD COLUMN iprov_gateway_host TEXT NOT NULL DEFAULT '';

View File

@ -31,6 +31,7 @@ type InfraProvisioned struct {
ServerHostPort string
ProxyHost string
ProxyPort int32
GatewayHost string
}
type InfraProvisionedGatewayView struct {

View File

@ -98,4 +98,5 @@ type Infrastructure struct {
// that are required for execute (start/stop, publish) and cleanup tasks
// to make the runner stateless
InstanceInfo InstanceInfo
GatewayHost string
}