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

Terraform in Equinix Metal: Fix NAT to reference correct interfaces #76

Merged
merged 1 commit into from
Apr 8, 2021

Conversation

nshalman
Copy link
Member

@nshalman nshalman commented Apr 7, 2021

Description

The NAT setup commands assume that the interface is named eth1, when clearly from the documentation it is named enp1s0f1. This commit fixes the NAT setup commands accordingly.

Why is this needed

NAT doesn't work by default on Equinix Metal when following the documentation

How Has This Been Tested?

  • Tested with Terraform in Equinix Metal

How are existing users impacted? What migration steps/scripts do we need?

Existing sandboxes (that are broken) should either be rebuilt, or can run the commands manually to enable NAT

Checklist:

I have:

  • updated the documentation and/or roadmap (if required)
  • added unit or e2e tests
  • provided instructions on how to upgrade

@nshalman nshalman self-assigned this Apr 7, 2021
@nshalman
Copy link
Member Author

nshalman commented Apr 7, 2021

Still need to do a full reprovision test. The commands worked manually.

Copy link

@markjacksonfishing markjacksonfishing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch

deploy/terraform/main.tf Outdated Show resolved Hide resolved
@nshalman nshalman marked this pull request as ready for review April 8, 2021 15:23
@nshalman
Copy link
Member Author

nshalman commented Apr 8, 2021

Updated per feedback from @mmlb. Looking for further feedback if this new approach is good.

NAT_INTERFACE=$(cat .nat_interface)
fi
if [ -n "$NAT_INTERFACE" ] && ip addr show "$NAT_INTERFACE" &>/dev/null; then
# TODO(nshalman) the terraform code would just run these commands as-is once
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ubuntu has some sort of iptables-persist package iirc. Yep iptables-persistent

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I try to get that wired up, or land as is with the TODO?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

todo is fine imo, hasn't been an issue so far I think.

This moves the NAT commands from terraform to setup.sh

Signed-off-by: Nahum Shalman <nshalman@equinix.com>
@nshalman
Copy link
Member Author

nshalman commented Apr 8, 2021

Squashed and ready to land if everyone likes this.

@markjacksonfishing
Copy link

I say it is ready to ship
/shipit

@nshalman nshalman added the ready-to-merge Signal to Mergify to merge the PR. label Apr 8, 2021
@mergify mergify bot merged commit 3fc23c5 into tinkerbell:master Apr 8, 2021
@nshalman nshalman deleted the fix-nat branch April 8, 2021 20:24
mergify bot added a commit that referenced this pull request Apr 12, 2021
## Description

This is a follow-up to #76 which introduced a failure:
```
provisioner: ./setup.sh: line 117: NAT_INTERFACE: unbound variable
```

## Why is this needed

Unbreak `setup.sh` when used by Vagrant

Fixes #77 

## How Has This Been Tested?

I used the following simple test case. It works now that the variable is declared first, but still breaks as reported without the fix.
```bash
#!/bin/bash
set -eu
NAT_INTERFACE=""
if [ -r .nat_interface ]; then
	NAT_INTERFACE=$(cat .nat_interface)
fi
if [ -n "$NAT_INTERFACE" ] && ip addr show "$NAT_INTERFACE" &>/dev/null; then
	echo "$NAT_INTERFACE"
fi
```

## How are existing users impacted? What migration steps/scripts do we need?

Vagrant users are currently broken as reported in the community Slack.

## Checklist:

I have:

- [ ] updated the documentation and/or roadmap (if required)
- [ ] added unit or e2e tests
- [ ] provided instructions on how to upgrade
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge Signal to Mergify to merge the PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants