-
Notifications
You must be signed in to change notification settings - Fork 51
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
Waiting for custom condition to be met #1595
Comments
Hi @RaicuRobert. You should be able to create a dependency between resources via: a = new ResourceA("A", args);
b = new ResourceB("B", { a.output.apply(o => { waitOnA(); o}) }); This is typescript. You can do the same thing in C#, I'm just less familiar with the language. If you post the code for two resource you need a dependency between, I can probably figure out the correct |
This would be the current code without unrelated things. var name = "MySite";
var rgName = "MyResourceGroup";
var domain = "mydomain.com";
var subdomain = "mysubdomain";
var staticSite = new StaticSite($"{name}-StaticSite", new StaticSiteArgs
{
ResourceGroupName = rgName,
Location = "westeurope",
Sku = new SkuDescriptionArgs
{
Name = "Free",
Tier = "Free"
},
StagingEnvironmentPolicy = StagingEnvironmentPolicy.Enabled,
AllowConfigFileUpdates = true,
EnterpriseGradeCdnStatus = EnterpriseGradeCdnStatus.Disabled,
PublicNetworkAccess = "Enabled",
Name = name
},
new CustomResourceOptions
{
Parent = this
});
var staticSiteCnameDelegation = new RecordSet($"{name}-StaticSite-CName-Delegation", new RecordSetArgs
{
ZoneName = domain,
ResourceGroupName = rgName,
RelativeRecordSetName = subdomain,
RecordType = "CNAME",
Ttl = 3600,
CnameRecord = new CnameRecordArgs
{
Cname = staticSite.DefaultHostname
}
},
new CustomResourceOptions
{
Parent = this
});
var staticSiteCustomDomain = new StaticSiteCustomDomain($"{name}-StaticSite-CustomDomain", new StaticSiteCustomDomainArgs()
{
ResourceGroupName = rgName,
Name = staticSite.Name,
DomainName = $"{subdomain}.{domain}",
ValidationMethod = "cname-delegation"
},
new CustomResourceOptions
{
Parent = this,
DependsOn = [staticSiteCnameDelegation]
}); |
The issue is not with pulumi not waiting for completion. The resources do get created in the right order. The problem is the async nature of the DNS propagation and lack of acknowledgment on either the Pulumi provider or microsofts' implementation. I have even tried something more crazy like mixing apply with some async code. But with no luck
|
Managed to make it work this time tho. Key was to call WaitForTxtEntryDnsPropagation with .GetAwaiter().GetResult() |
I'm glad you found a solution that works! |
Well, I was happy a bit too soon @iwahbe . It seems that even if the code now waits for the dns check to succed, I am not using the same dns server as the StaticSiteCustomDomain provider does. As such, my check succeded, then the StaticSiteCustomDomain executed and failed. My initial run seems to have succeded by the chance of a race condition between dns servers propagating my info |
Here is a very bad log of things that happened
|
Adding custom timeouts does not seem to help either as the error is returned and is considered final although I set At this point, I think something like this pulumi/pulumi#7932 would have probably solved my issue. |
pulumi/pulumi#7932 would provide some support. I think you had the right idea vis a vis checking DNS propagation, you just need to do it against azure. P.S. AWS has an equivalent problem, and it solved it with https://www.pulumi.com/registry/packages/aws/api-docs/acm/certificatevalidation/. The resource implements the same kind of DNS check that you implemented. |
So I did not specify it, but I did use the exact Microsoft nameservers that the DNS Zone uses for my custom check and that went fine. The issue is with the Certificate resource itself. After my check on the servers that I know should be good passes, the Certificate is deployed but it uses some other nameserver to check for the records and it fails to find them in time. |
I have the same issue with asuid txt records that is required to make a web app name binding. There is no way for me to ensure that I check with the internal dns servers Azure uses when checking this, so I need to re-run the whole deployment until all the checks goes through. I've even set the creation of the dns records as something that happens before the web apps are created, but it still randomly fails.
(Text record name changed to asuid.foo and ASUID value to cafebabe) Edit: I've also added a wrapper that waits for the TXT record to be created, then waits additional time before creating the binding. It helps, but it's no guarantee. |
Hello!
Issue details
I have an existing Zone and I am trying to create a StaticSite, RecordSet, and then a StaticSiteCustomDomain.
The problem is that the time between adding a RecordSet with the CNAME for the StaticSite to the Zone and the time of execution for the StaticSiteCustomDomain is too short.
I often get the following error and I have to rerun "azure-native:web:StaticSiteCustomDomain StaticSite-CustomDomain creating (2s) error: Code="BadRequest" Message="CNAME Record is invalid. Please ensure the CNAME record has been created." Details=[{"Message":"CNAME Record is invalid. Please ensure the CNAME record has been created."},{"Code":"BadRequest"},{"ErrorEntity":{"Code":"BadRequest","ExtendedCode":"51021","Message":"CNAME Record is invalid. Please ensure the CNAME record has been created.","MessageTemplate":"{0} is invalid. {1}","Parameters":["CNAME Record","Please ensure the CNAME record has been created."]}}]"
Is there a way to inject custom code to wait until a certain condition is met?
I have a method "Task WaitForTxtEntryDnsPropagation(string domain, string expectedValue, TimeSpan checkFrequency, TimeSpan timeout, string[] nameServersToUse)" that I would like to await before creating the StaticSiteCustomDomain resource.
I could not find a straightforward way of doing it.
The only way I see it being done currently is by using the automation API and having two stacks.
Execute stack 1 (StaticSite and RecordSet)
run WaitForTxtEntryDnsPropagation
Execute stack 2 (StaticSiteCustomDomain)
Thus I have to split what could have been a ComponentResource into two parts.
Affected area/feature
The text was updated successfully, but these errors were encountered: