-
Notifications
You must be signed in to change notification settings - Fork 8
Emit and create contract for FQDN #4317
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: development
Are you sure you want to change the base?
Conversation
@@ -492,6 +497,11 @@ class TwinDeploymentHandler { | |||
events.emit("logs", `Check the name contract for the workload with name: ${workload.name}`); | |||
const extrinsic = await this.createNameContract(workload.data["name"]); | |||
nameExtrinsics.push(extrinsic); | |||
} else if (workload.type === WorkloadTypes.gatewayfqdnproxy) { | |||
events.emit("logs", `Check the name contract for the FQDN workload with name: ${workload.name}`); | |||
const contractName = workload.name.replace(/[^a-zA-Z0-9]/g, "").toLowerCase(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i suggest having this logic in a function and reusing it
to avoid code redundancy, andit will be easier to maintain
} | ||
} | ||
const gatewayResults = await this.handleGatewayWorkloads(twinDeployment.deployment.workloads, Operations.update); | ||
nameExtrinsics = gatewayResults.nameExtrinsics; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should push the result, not reassign it.
also we can have
const gatewayResults = await this.handleGatewayWorkloads(twinDeployment.deployment.workloads, twinDeployment.operation)
then insdie the operation check block:
else if (twinDeployment.operation === Operations.update) {
...
nameExtrinsics.push(gatewayResults.nameExtrinsics)
}
same on delete
} | ||
} else if (workload.type === WorkloadTypes.gatewayfqdnproxy) { | ||
events.emit("logs", `Check the name contract for the FQDN workload with name: ${workload.name}`); | ||
const contractName = workload.name.replace(/[^a-zA-Z0-9]/g, "").toLowerCase(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's wrong. Why should the workload name be a unique identifier?! The workload name should be unique on the deployment object only. The unique identifier that should be on the name contract is the FQDN.
- Changing the reassignment operations to push operations
Test scenarios:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
created a fqdn with fqdn kassem-test.elgrid.xyz
this created
gateway contract
details
{
"version": 0,
"twin_id": 800,
"contract_id": 225610,
"metadata": "",
"description": "",
"expiration": 0,
"signature_requirement": {
"requests": [
{
"twin_id": 800,
"required": false,
"weight": 1
}
],
"weight_required": 1,
"signatures": [
{
"twin_id": 800,
"signature": "1aa73655d7bc6fdb6e6488fbac42365d6cc9155af79abf668adc1d9d4ccffb529419859e37cd52375511959af546a2c471ec3bca8578a9776d37094ccdf5d881",
"signature_type": "sr25519"
}
],
"signature_style": ""
},
"workloads": [
{
"version": 0,
"name": "kassem8",
"type": "gateway-fqdn-proxy",
"data": {
"__type": "gateway-fqdn-proxy",
"fqdn": "kassem-test.elgrid.xyz",
"tls_passthrough": false,
"backends": [
"http://10.20.2.2:80"
],
"network": "nwcnn2q"
},
"metadata": "",
"description": "",
"result": {
"created": 1754566136,
"state": "ok",
"message": "",
"data": {}
}
}
]
}
and name contract
{
"contract_id": 225611,
"twin_id": 800,
"type": "name",
"state": "Created",
"created_at": 1754566128,
"details": {
"nodeId": "-",
"farm_id": "-"
},
"solutionName": "kassemtestelgridxyz",
"solutionType": "-",
"expiration": "-",
"consumption": 0,
"discountPackage": "None"
}
then tried to create new fqdn pointing to kassem.test.elgrid.xyz

}> { | ||
const nameExtrinsics: ExtrinsicResult<Contract>[] = []; | ||
const deletedExtrinsics: ExtrinsicResult<number>[] = []; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can add a function here to reduce code redundancy, so you can define the contract name, based on workload type, then pass it to this function, whatever the operation is
const processContract = async (contractName: string) => {
if (operation === Operations.delete) {
const extrinsic = await this.deleteNameContract(contractName);
if (extrinsic) deletedExtrinsics.push(extrinsic);
} else {
const extrinsic = await this.createNameContract(contractName);
nameExtrinsics.push(extrinsic);
}
};
} | ||
} else if (workload.type === WorkloadTypes.gatewayfqdnproxy) { | ||
events.emit("logs", `Check the name contract for the FQDN workload with name: ${workload.name}`); | ||
const contractName = workload.data["fqdn"].replace(/[^a-zA-Z0-9]/g, "").toLowerCase(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should store the full fqdn name and do not remove anything
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we shouldn't as tf chain doesn't support the characters like dots for example
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we can't store the FQDN as is, there will be many variations of domains that will end up with the same string after removing .
, -
, and _
. So, no unique records, which is the target of having the name contract.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so, any recommended ideas?
Description
FQDN gateways will create name contracts using the workload name (which is alphanumeric) instead of the FQDN (which contains invalid characters)
Changes
Related Issues
Tested Scenarios
Documentation PR
For UI changes, Please provide the Documentation PR on info_grid
To consider
Preliminary Checks:
UI Checks:
Code Quality Checks:
Testing Checklist
General Checklist