Fix DNS records data not getting stored in the DB

This commit is contained in:
Shreerang Kale 2025-01-30 18:19:26 +05:30 committed by IshaVenikar
parent 624f36155a
commit 9784eb4f4a
7 changed files with 26 additions and 18 deletions

View File

@ -16,7 +16,7 @@ import {
ApplicationDeploymentRequest,
ApplicationDeploymentRemovalRequest
} from './entity/Deployment';
import { AppDeploymentRecord, AppDeploymentRemovalRecord, AuctionParams, DeployerRecord, DNSRecordAttributes } from './types';
import { AppDeploymentRecord, AppDeploymentRemovalRecord, AuctionParams, DeployerRecord, DNSRecord, DNSRecordAttributes } from './types';
import { getConfig, getRepoDetails, registryTransactionWithRetry, sleep } from './utils';
const log = debug('snowball:registry');
@ -446,7 +446,7 @@ export class Registry {
/**
* Fetch deployment DNS Records by filter
*/
async getDNSRecordsByFilter(filter: { [key: string]: any }): Promise<DNSRecordAttributes[]> {
async getDNSRecordsByFilter(filter: { [key: string]: any }): Promise<DNSRecord[]> {
return this.registry.queryRecords(
{
type: DNS_RECORD_TYPE,

View File

@ -206,11 +206,11 @@ export class Service {
})
const dnsRecordData: DNSRecordAttributes = {
name: dnsRecords[0].name,
request: dnsRecords[0].request,
resourceType: dnsRecords[0].resourceType,
value: dnsRecords[0].value,
version: dnsRecords[0].version,
name: dnsRecords[0].attributes.name,
request: dnsRecords[0].attributes.request,
resourceType: dnsRecords[0].attributes.resourceType,
value: dnsRecords[0].attributes.value,
version: dnsRecords[0].attributes.version,
}
deployment.applicationDeploymentRecordId = record.id;
@ -665,11 +665,7 @@ export class Service {
const environmentVariablesObj = await this.getEnvVariables(data.project!.id!);
// If a custom domain is present then use that as the DNS in the deployment request
const domain = await this.db.getOldestDomainByProjectId(data.projectId!);
let dns: string | undefined = undefined;
if (domain) {
dns = domain[0].name;
}
const domain = await this.db.getOldestDomainByProjectId(data.project!.id!);
// To set project DNS
if (data.environment === Environment.Production) {
@ -680,7 +676,7 @@ export class Service {
appName: repo,
repository: repoUrl,
environmentVariables: environmentVariablesObj,
dns: `${newDeployment.project.name}`,
dns: domain?.[0]?.name ?? `${newDeployment.project.name}`,
lrn: deployer!.deployerLrn!,
apiUrl: deployer!.deployerApiUrl!,
payment: data.project.txHash,
@ -698,7 +694,7 @@ export class Service {
lrn: deployer!.deployerLrn!,
apiUrl: deployer!.deployerApiUrl!,
environmentVariables: environmentVariablesObj,
dns: dns || `${newDeployment.project.name}-${newDeployment.id}`,
dns: `${newDeployment.project.name}-${newDeployment.id}`,
payment: data.project.txHash,
auctionId: data.project.auctionId,
requesterAddress: address,

View File

@ -72,6 +72,10 @@ export interface AppDeploymentRemovalRecord extends RegistryRecord {
attributes: AppDeploymentRemovalRecordAttributes;
}
export interface DNSRecord extends RegistryRecord {
attributes: DNSRecordAttributes
}
export interface AddProjectFromTemplateInput {
templateOwner: string;
templateRepo: string;

View File

@ -100,6 +100,10 @@ const DomainCard = ({
const dnsData = await client.getLatestDNSDataByProjectId(id);
if (!dnsData || !dnsData.value) {
setIPAddress('Not Configured');
}
setIPAddress(dnsData.value);
};

View File

@ -74,9 +74,13 @@ const Config = () => {
return;
}
const dnsData = await client.getLatestDNSDataByProjectId(id);
const dnsData = await client.getLatestDNSDataByProjectId(id);
setIPAddress(dnsData.value);
setIPAddress(dnsData.value);
if (!dnsData || !dnsData.value) {
setIPAddress("Not Configured")
}
};
fetchDNSData();

View File

@ -462,6 +462,6 @@ export class GQLClient {
},
});
return data.dnsRecordData;
return data.getLatestDNSDataByProjectId;
}
}

View File

@ -346,7 +346,7 @@ query ($txHash: String!, $amount: String!, $senderAddress: String!) {
export const getLatestDNSDataByProjectId = gql`
query($projectId: String!) {
dnsRecordData(projectId: $projectId) {
getLatestDNSDataByProjectId(projectId: $projectId) {
name
value
request