Skip to content

Add 'profile' query parameter in cloud-init metadata handlers#3

Closed
bmcdonald3 wants to merge 10 commits into
OpenCHAMI:mainfrom
bmcdonald3:profile-query-param
Closed

Add 'profile' query parameter in cloud-init metadata handlers#3
bmcdonald3 wants to merge 10 commits into
OpenCHAMI:mainfrom
bmcdonald3:profile-query-param

Conversation

@bmcdonald3
Copy link
Copy Markdown
Member

@bmcdonald3 bmcdonald3 commented Jan 28, 2026

Description

Add query parameter as phase 1 of OpenCHAMI/roadmap#121.

This covers the following routes as specified in the RFD:

GET /cloud-init/meta-data?profile=...
GET /cloud-init/user-data?profile=...
GET /cloud-init/vendor-data?profile=...
GET /cloud-init/{group}.yaml?profile=...

Corresponding changes to boot service and a new node service to follow.

Testing:

cd ~/metadata-service
unset SMD_URL
go run . serve --port 8080
2026/01/30 16:05:44 Starting github.com/OpenCHAMI/cloud-init server...
2026/01/30 16:05:44 File storage initialized in ./data
{"level":"warn","time":"2026-01-30T16:05:44-08:00","message":"SMD_URL not configured, using mock SMD client for development"}
{"level":"info","time":"2026-01-30T16:05:44-08:00","message":"Mock SMD client initialized with sample data including EthernetInterface info"}
2026/01/30 16:05:44 Server starting on 0.0.0.0:8080

Since we are running locally with a fresh ./data directory, we must create the group record so the service has a template to serve. We use the generated CLI client for this.

# Create the 'compute' group with a dummy template
go run ./cmd/client --server http://localhost:8080 group create --spec '{"name":"compute", "template":"#cloud-config\n# Final Verification"}'
{
  "apiVersion": "v1",
  "kind": "Group",
  "schemaVersion": "v1",
  "metadata": {
    "name": "compute",
    "uid": "gro-f7dcc09f",
    "createdAt": "2026-01-30T16:07:40.427895-08:00",
    "updatedAt": "2026-01-30T16:07:40.427895-08:00"
  },
  "spec": {
    "template": "#cloud-config\n# Final Verification"
  },
  "status": {
    "valid": true,
    "currentTemplateVersion": "v-10c16567",
    "templateHistory": [
      {
        "version": "v-10c16567",
        "timestamp": "2026-01-31T00:07:40Z",
        "valid": true
      }
    ]
  }
}

We simulate a request from a known mock node (10.252.0.26) and request a specific profile (staging). We verify that the profile query parameter is preserved in the returned #include URLs.

curl -v -H "X-Forwarded-For: 10.252.0.26" "http://localhost:8080/vendor-data?profile=staging"
#include
/compute.yaml?profile=staging
/green.yaml?profile=staging

Seeing ?profile=staging in the response confirms this change works as expected.

Signed-off-by: Ben McDonald <ben.mcdonald@hpe.com>
Signed-off-by: Ben McDonald <ben.mcdonald@hpe.com>
Signed-off-by: Ben McDonald <ben.mcdonald@hpe.com>
Signed-off-by: Ben McDonald <ben.mcdonald@hpe.com>
Signed-off-by: Ben McDonald <ben.mcdonald@hpe.com>
Signed-off-by: Ben McDonald <ben.mcdonald@hpe.com>
Signed-off-by: Ben McDonald <ben.mcdonald@hpe.com>
Signed-off-by: Ben McDonald <ben.mcdonald@hpe.com>
Signed-off-by: Ben McDonald <ben.mcdonald@hpe.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants