Skip to content
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

Fix Broker Hostname Records #46

Merged
merged 8 commits into from Nov 9, 2021
Merged

Fix Broker Hostname Records #46

merged 8 commits into from Nov 9, 2021

Conversation

ghost
Copy link

@ghost ghost commented Nov 5, 2021

what

  • Replaced the way the broker hostname records are created.
  • Also fixed a typo in the bootstrap_brokers_tls output.

why

Because right now the bootstrap brokers are used to build the hostnames. AWS doesn't give a complete list of brokers in the bootstrap brokers list (see references). So if you have 4 brokers but 3 reported bootstrap brokers then the hostnames for the 4 DNS records are wrong. Also the bootstrap brokers change between refreshes, so the hostnames change with every apply.

references

@ghost ghost requested review from a team as code owners November 5, 2021 15:09
@ghost ghost requested review from r351574nc3 and Makeshift November 5, 2021 15:09
@mergify
Copy link

mergify bot commented Nov 5, 2021

This pull request is now in conflict. Could you fix it @stephanECD? 🙏

Stephan Eckweiler and others added 2 commits November 5, 2021 15:23
The bootstrap broker lists can't be reliably used to create the DNS
hostsnmes, since it only shows up to 3 brokers. If you have more than 3
brokers the hostname records start dancing from one apply to the next.
main.tf Outdated Show resolved Hide resolved
@nitrocode
Copy link
Member

@stephanECD thanks for the contribution! I'll run the tests

@nitrocode
Copy link
Member

/test all

@nitrocode
Copy link
Member

/test all

@nitrocode
Copy link
Member

/test all

@nitrocode
Copy link
Member

/test all

@nitrocode
Copy link
Member

@stephanECD seems like it cannot retrieve the endpoints immediately after creating the cluster. A delay may be needed after cluster creation and before the data source pulls the broker information. This is most likely due to the AWS api not returning consistent results.

were you tested this locally to see if this works as expected?

@ghost
Copy link
Author

ghost commented Nov 9, 2021

@nitrocode thanks for looking into this. I don't think the AWS API is the root cause. I was able to fix this error:

│   on .../terraform-aws-msk-apache-kafka-cluster/main.tf line 5, in locals:
│    5:   brokers        = local.enabled ? flatten(local.node_info_list.*.endpoints) : []
│ 
│ This value does not have any attributes.

by simply going back to one line in the code for the brokers. So I would guess your local.node_info_list doesn't look as expected at the time this code runs, maybe there's a race condition when the local.node_info_list is filled, as opposed to when its content is needed for the dns records. Have a look at my newest commit, I think that should solve it. We don't need a splash for data.aws_msk_broker_nodes, since you only use the count to enable or disable it.

@nitrocode
Copy link
Member

@stephanECD cool. Were you able to test out the change ?

@nitrocode
Copy link
Member

/test all

@ghost
Copy link
Author

ghost commented Nov 9, 2021

Reverted the hostname count, seems that was a bad idea.

@nitrocode
Copy link
Member

/test all

@nitrocode nitrocode added the patch A minor, backward compatible change label Nov 9, 2021
@nitrocode nitrocode merged commit 3fe23c4 into cloudposse:master Nov 9, 2021
@nitrocode
Copy link
Member

Thanks @stephanECD for the contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch A minor, backward compatible change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants