Hey everyone! I am trying to set up a k8s cluster ...
# getting-started
h
Hey everyone! I am trying to set up a k8s cluster including a deployment with a load balancer and a DNS Record in CIVO with the Go SDK. So far, I got everything working (initial run sets up everything). Now, running the same code again (without changes) gives me an error, creating the DNS Record. I tried it, to check if execution was idempotent which I assumed it should be. The critical Code is that part:
Copy code
func (c *Civo) WithDnsDomainNameRecord(ctx *pulumi.Context, ip string, prefix pulumi.StringOutput) error {
    _, err := civo.NewDnsDomainRecord(ctx, ip, &civo.DnsDomainRecordArgs{
       Ttl:      pulumi.Int(600),
       Type:     pulumi.String("A"),
       DomainId: c.DomainName.ID(),
       Name:     prefix,
       Value:    pulumi.String(ip),
    },
       pulumi.Parent(c),
    )

    if err != nil {
       return err
    }
    return nil
}
The following error occurs: > Diagnostics: > civoindexDnsDomainRecord (74.220.31.244): > error: 1 error occurred: > * updating urnpulumistg:bringalongbringalonginfra:civo$civoindex/dnsDomainRecordDnsDomainRecord:74.220.31.244 1 error occurred: > * [ERR] an error occurred while renamed the domain record bc2db7f1-9fc7-4ad1-a907-d122688a1800, ParameterDnsRecordTypeError: The type of the DNS record was invalid - only 'A', 'MX', 'CNAME' or 'TXT' are supported Is this an error on my end and I did something wrong or is there nothing I can improve? Thanks in advance!
c
to check if execution was idempotent which I assumed it should be.
Yes it should be, without changes. Are you getting this error consistently and do you actually see the DNS record in your cloud console?
h
I can see the record and actually access the cluster via it, the error is happening consistently. If I comment the code, execute it and add it back, executing it again, it works as expected that the record is being removed and created anew
c
That is strange. The only thing I can think of is that the value of
prefix
that you are using as the value of
Name
is changing somehow and that's triggering an update. The error message from the provider is misleading in my opinion. Civo's API is complaining about the value of the type being invalid but you are not changing the type clearly. Can you try to update the DNS record manually in Civo's console and see if it lets you update it without any issues?
h
Alright, I tried and I am able to change it on the CIVO website. I also played around with further and replaced the prefix and the IP by its static values, so the only variable left is the DNS-ID but nothing changes. Two interesting observations: 1. The error sometimes shows what I already mentioned, sometimes it gives the following:
[ERR] an error occurred while renamed the domain record 0b03252e-f4ad-402a-a360-e67d7602473c, Error: Unknown error response - status: 400 Bad Request, code: 400, reason: {"code":"database_dns_record_already_exist","reason":"Failed to create a DNS record name in the internal database, that already exists"}
2. The diff on the pulumi console in the browser shows nothing to change (as seen in the image)
c
Can you please run a
pulumi preview --diff
and paste the results just for the DNS domain record?
h
Sure, so this is the whole output
Copy code
~ civo:index/dnsDomainRecord:DnsDomainRecord: (update)
            [id=0b03252e-f4ad-402a-a360-e67d7602473c]
            [urn=urn:pulumi:stg::bringalong::bringalong:infra:cloud:civo$civo:index/dnsDomainRecord:DnsDomainRecord::74.220.31.244]
            domainId  : "44cdafcc-2316-47ea-b279-60ebd3601d2d"
            name      : "<http://api-stg.bringalong.io|api-stg.bringalong.io>"
            ttl       : 600
            type      : "A"
            value     : "74.220.31.244"
c
My guess is their API is returning something that is not matching the inputs, leading to an update. But even stranger is that it is a replacement. I am suspecting it has to do with the
type
. Can you try adding
type
to the ignoreChanges resource option? (
type
should be lower-cased when adding it to ignoreChanges.)
h
Adding
pulumi.IgnoreChanges([]string{"type"})
as well as
pulumi.IgnoreChanges([]string{"type", "ttl", "value", "name"})
to the ResourceOptions calling
NewDnsDomainRecord
does not make any difference. Is there a way to check what the API is returning somehow (other than checking it manually)?