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

Baremetal: Bug 1801238: Pull data from ironic inspector and annotate BareMetalHost #3591

Merged
merged 1 commit into from May 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions data/data/baremetal/masters/main.tf
Expand Up @@ -3,6 +3,7 @@ resource "ironic_node_v1" "openshift-master-host" {
name = var.hosts[count.index]["name"]
resource_class = "baremetal"

inspect = true
imain marked this conversation as resolved.
Show resolved Hide resolved
clean = true
available = true

Expand Down
@@ -0,0 +1,44 @@
#!/bin/sh

# shellcheck disable=SC1091
. /usr/local/bin/release-image.sh
imain marked this conversation as resolved.
Show resolved Hide resolved

export KUBECONFIG=/etc/kubernetes/kubeconfig
Copy link
Contributor

Choose a reason for hiding this comment

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


# Wait till the baremetalhosts are populated
until oc get baremetalhosts -n openshift-machine-api; do
echo Waiting for BareMetalHosts to appear...
sleep 20
done

# Wait for a master to appear.
while [ "$(curl -s http://localhost:6385/v1/nodes | jq '.nodes[] | .uuid' | wc -l)" -lt 1 ]; do
Copy link
Contributor

Choose a reason for hiding this comment

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

also do we expect the RHCOS image to ship jq ? that's odd.

Copy link
Member

Choose a reason for hiding this comment

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

Why’s that odd? It’s there.

echo waiting for a master node to show up
sleep 20
done

# Wait for the nodes to become active after introspection.
# Probably don't need this but I want to be 100% sure.
while curl -s http://localhost:6385/v1/nodes | jq '.nodes[] | .provision_state' | grep -v active; do
echo Waiting for nodes to become active
sleep 20
done
imain marked this conversation as resolved.
Show resolved Hide resolved

echo Nodes are all active

BAREMETAL_OPERATOR_IMAGE=$(image_for baremetal-operator)

for node in $(curl -s http://localhost:6385/v1/nodes | jq -r '.nodes[] | .uuid'); do
name=$(curl -H "X-OpenStack-Ironic-API-Version: 1.9" -s "http://localhost:6385/v1/nodes/$node" | jq -r .name)
echo "Host $name, UUID: $node"
# And use the baremetal operator tool to load the introspection data into
# the BareMetalHost CRs as annotations, which BMO then picks up.
HARDWARE_DETAILS=$(podman run --quiet --net=host \
--rm \
--name baremetal-operator \
Copy link
Contributor

Choose a reason for hiding this comment

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

do you need to use a specific name? there are times where names container will fail if previous one was not cleaned up..

--entrypoint /get-hardware-details \
"${BAREMETAL_OPERATOR_IMAGE}" \
http://localhost:5050/v1 "$node" | jq '{hardware: .}')

oc annotate --overwrite -n openshift-machine-api baremetalhosts "$name" 'baremetalhost.metal3.io/status'="$HARDWARE_DETAILS"
Copy link
Contributor

Choose a reason for hiding this comment

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

what if you get an error when trying to update, like maybe machine-api isn't registered yet?

Copy link
Member

@stbenjam stbenjam May 15, 2020

Choose a reason for hiding this comment

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

The first thing we check at the start of the script is for the presence of the CR’s

done
@@ -0,0 +1,11 @@
[Unit]
Description=Update master BareMetalHosts with introspection data
Wants=bootkube.service
After=release-image.service

[Service]
Type=oneshot
ExecStart=/usr/local/bin/master-bmh-update.sh
imain marked this conversation as resolved.
Show resolved Hide resolved

[Install]
WantedBy=multi-user.target
7 changes: 4 additions & 3 deletions pkg/asset/ignition/bootstrap/bootstrap.go
Expand Up @@ -331,9 +331,10 @@ func (a *Bootstrap) addSystemdUnits(uri string, templateData *bootstrapTemplateD
"systemd-journal-gatewayd.socket": {},
"approve-csr.service": {},
// baremetal & openstack platform services
"keepalived.service": {},
"coredns.service": {},
"ironic.service": {},
"keepalived.service": {},
"coredns.service": {},
"ironic.service": {},
"master-bmh-update.service": {},
Comment on lines +336 to +337
Copy link
Contributor

Choose a reason for hiding this comment

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

Can there be some wants/depends_on relationship between these 2 services that allows us to not activate each individual service? or are these actually 2 independent services?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are 2 independent .service files for them if that's what you mean. I did try it with a dependency but the service was just marked as disabled and wouldn't start.

Copy link
Member

Choose a reason for hiding this comment

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

master-bmh-update talks to ironic, but they are independent with different goals. I think it's more obvious to leave both explicitly enabled

}

directory, err := data.Assets.Open(uri)
Expand Down