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

nixos/ec2: don't populate nonexistent metadata files #218482

Merged
merged 1 commit into from
Mar 15, 2023

Conversation

illustris
Copy link
Contributor

@illustris illustris commented Feb 26, 2023

Description of changes

Relevant issue: #212614

curl http://169.254.169.254/1.0/user-data returns an HTML 404 response page. This gets written to /etc/ec2-metadata/user-data by the fetch-ec2-metadata.service, and eventually picked up by amazon-init.service. This service overwrites /etc/nixos/configuration.nix with this 404 page.

adding --fail to the curl call will prevent files from being created in /etc/ec2-metadata if the response is not 200.

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 23.05 Release Notes (or backporting 22.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

@illustris
Copy link
Contributor Author

tested on an EC2 instance:

Feb 26 17:53:41 systemd[1]: Starting fetch-ec2-metadata.service...
Feb 26 17:53:41 fetch-ec2-metadata-start[17721]: (attempt 1/3) getting an EC2 instance metadata service v2 token...
Feb 26 17:53:41 fetch-ec2-metadata-start[17721]: (attempt 1/10) validating the EC2 instance metadata service v2 token...
Feb 26 17:53:41 fetch-ec2-metadata-start[17721]: getting EC2 instance metadata...
Feb 26 17:53:41 fetch-ec2-metadata-start[17734]: curl: (22) The requested URL returned error: 404
Feb 26 17:53:41 systemd[1]: fetch-ec2-metadata.service: Deactivated successfully.
Feb 26 17:53:41 systemd[1]: Finished fetch-ec2-metadata.service.
Feb 26 17:53:41 systemd[1]: fetch-ec2-metadata.service: Consumed 60ms CPU time, received 3.7K IP traffic, sent 2.6K IP traffic.
$ ls -lah /etc/ec2-metadata/
total 20K
drwxr-xr-x  2 root root 4.0K Feb 26 17:53 .
drwxr-xr-x 31 root root 4.0K Feb 26 17:53 ..
-rw-r--r--  1 root root    9 Feb 26 17:53 ami-manifest-path
-rw-r--r--  1 root root   44 Feb 26 17:53 hostname
-rw-r--r--  1 root root  388 Feb 26 17:53 public-keys-0-openssh-key

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-ready-for-review/3032/1890

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-ready-for-review/3032/1932

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-ready-for-review/3032/1933

@yrichardcrak
Copy link

Hmm was going to play around with nixos on ec2 today but am running into this issue. Will wait for the merge and try again :)

Thank you!

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-already-reviewed/2617/868

@SuperSandro2000 SuperSandro2000 merged commit 83dcada into NixOS:master Mar 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants