ohai icon indicating copy to clipboard operation
ohai copied to clipboard

Fetch the user-data on Alibaba Cloud correctly

Open ETiV opened this issue 2 years ago • 5 comments

The response of user-data API should not be fetched line by line.

Description

On Alibaba Cloud, the response of user-data metadata API is not processed properly.

Related Issue

#1765

Types of changes

  • [x] Bug fix (non-breaking change which fixes an issue)
  • [ ] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to change)
  • [ ] Chore (non-breaking change that does not add functionality or fix an issue)

Checklist:

  • [x] I have read the CONTRIBUTING document.
  • [x] I have run the pre-merge tests locally and they pass.
  • [ ] I have updated the documentation accordingly.
  • [x] I have added tests to cover my changes.
  • [x] All new and existing tests passed.
  • [x] All commits have been signed-off for the Developer Certificate of Origin.

This is my first time to coding in Ruby, I've did my best 😂. If there's any error or the coding style is not meet the repo, please just fix it, thank you.

ETiV avatar Aug 11 '22 03:08 ETiV

And, in my opinion, if the purpose of this module is to ONLY retrieve the [meta-data/...](the meta-data and its sub-directory's contents), the root URL should be http://100.100.100.200/2016-01-01/meta-data/, not http://100.100.100.200/2016-01-01/.

If the starting point is http://100.100.100.200/2016-01-01/(as the code here), it will also get [user-data], [dynamic/...], [global-config], [maintenance/...], these things are not [meta-data/...] related I think.

ETiV avatar Aug 17 '22 10:08 ETiV

Currently the meta-data API's structure is like this, I've pasted some of the file's content after =>

http://100.100.100.200/2016-01-01/meta-data/
├── dns-conf/
│   └── nameservers        => `100.100.2.136\n100.100.2.138`
├── eipv4                  => ``
├── hibernation/
│   └── configured         => `false`
├── hostname               => `iZuf64XXXXXXXXXXXX`
├── image-id               => `debian_10_9_x64_20G_alibase_20210521.vhd`
├── instance/
│   ├── instance-name      => `vm-instance-name`
│   ├── instance-type      => `ecs.c5.2xlarge`
│   ├── last-host-landing-time
│   ├── max-netbw-egress
│   ├── max-netbw-ingress
│   ├── virtualization-solution
│   └── virtualization-solution-version
├── instance-id
├── mac
├── network/
│   └── interfaces/
│       └── macs/
│           └── 00:11:22:xx:yy:zz/
│               ├── gateway
│               ├── netmask
│               ├── network-interface-id
│               ├── primary-ip-address
│               ├── private-ipv4s
│               ├── vpc-cidr-block
│               ├── vpc-id
│               ├── vswitch-cidr-block
│               └── vswitch-id
├── network-type
├── ntp-conf/
│   └── ntp-servers
├── owner-account-id
├── private-ipv4
├── public-keys/
│   └── 0/
│       └── openssh-key
├── ram/
│   └── security-credentials/
│       └── AnRAMRoleName
├── region-id
├── serial-number
├── source-address
├── sub-private-ipv4-list
├── vpc-cidr-block
├── vpc-id
├── vswitch-cidr-block
├── vswitch-id
└── zone-id

ETiV avatar Aug 17 '22 10:08 ETiV

Thanks for the additional info @ETiV ; these changes look good.

I agree that it would make more sense to include meta-data at the URL; that would also let us get rid of the special case for user-data; could you make those updates?

marcparadise avatar Aug 23 '22 19:08 marcparadise

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

sonarqubecloud[bot] avatar Aug 25 '22 14:08 sonarqubecloud[bot]

hi @marcparadise , I just pushed a commit to apply what we've talked earlier.

ETiV avatar Aug 25 '22 14:08 ETiV

@ETiV - ping?

jaymzh avatar Jan 17 '23 20:01 jaymzh

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

sonarqubecloud[bot] avatar Mar 05 '23 23:03 sonarqubecloud[bot]

@ETiV these changes look good to me, but we're still seeing test failures in the new specs.

marcparadise avatar Mar 14 '23 19:03 marcparadise

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

sonarqubecloud[bot] avatar Apr 17 '23 21:04 sonarqubecloud[bot]

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

sonarqubecloud[bot] avatar Jul 30 '23 20:07 sonarqubecloud[bot]

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

sonarqubecloud[bot] avatar Jul 30 '23 20:07 sonarqubecloud[bot]