-
Notifications
You must be signed in to change notification settings - Fork 1.5k
AGENT-858: Agent day2 ignition services #8093
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
Merged
openshift-merge-bot
merged 14 commits into
openshift:master
from
andfasano:agent-day2-ignition-services
Apr 8, 2024
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
932487d
add agent-add-node and import cluster services
andfasano 9716c1f
modify Ignition asset to enable add-node workflow services
andfasano 3c70dc7
retrieve os image data in ClusterInfo
andfasano a890cb1
allow Ignition and BaseIso assets to retrieve coreos metadata from Cl…
andfasano 298975a
utlity script for building node-joiner binary
andfasano e5048da
lint/fmt fixes
andfasano 0bf79d6
Fix build script
andfasano 015f228
add log levels support
andfasano abf1852
minor updates
andfasano 13c8db4
inject ClusterInfo into NMStateConfig asset
andfasano 8ea9b93
use different iso name for node-joiner add-nodes command
andfasano 28fdc6e
various add-node.sh fixes
andfasano c1ac237
support adding multiple hosts
andfasano cac843c
additional lint/script fixes
andfasano File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| #!/bin/bash | ||
| set -e | ||
|
|
||
| # shellcheck disable=SC1091 | ||
| source issue_status.sh | ||
|
|
||
| BASE_URL="${SERVICE_BASE_URL}api/assisted-install/v2" | ||
|
|
||
| cluster_id="" | ||
| while [[ "${cluster_id}" = "" ]] | ||
| do | ||
| # Get cluster id | ||
| cluster_id=$(curl -s -S "${BASE_URL}/clusters" | jq -r .[].id) | ||
| if [[ "${cluster_id}" = "" ]]; then | ||
| sleep 2 | ||
| fi | ||
| done | ||
|
|
||
| printf '\nInfra env id is %s\n' "${INFRA_ENV_ID}" 1>&2 | ||
|
|
||
| status_issue="90_add-node" | ||
|
|
||
| # Wait for the current host to be ready | ||
| host_ready=false | ||
| while [[ $host_ready == false ]] | ||
| do | ||
| host_status=$(curl -s -S "${BASE_URL}/infra-envs/${INFRA_ENV_ID}/hosts" | jq -r ".[].status") | ||
| if [[ "${host_status}" != "known" ]]; then | ||
| printf '\\e{yellow}Waiting for the host to be ready' | set_issue "${status_issue}" | ||
| sleep 10 | ||
| else | ||
| host_ready=true | ||
| fi | ||
| done | ||
|
|
||
| HOST_ID=$(curl -s "${BASE_URL}/infra-envs/${INFRA_ENV_ID}/hosts" | jq -r '.[].id') | ||
| printf '\nHost %s is ready for installation\n' "${HOST_ID}" 1>&2 | ||
| clear_issue "${status_issue}" | ||
|
|
||
| # Add the current host to the cluster | ||
| res=$(curl -X POST -s -S -w "%{http_code}\\n" -o /dev/null "${BASE_URL}/infra-envs/${INFRA_ENV_ID}/hosts/${HOST_ID}/actions/install") | ||
| if [[ $res = "202" ]]; then | ||
| printf '\nHost installation started\n' 1>&2 | ||
| else | ||
| printf '\nHost installation failed\n' 1>&2 | ||
| exit 1 | ||
| fi | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| [Unit] | ||
| Description=Adds the current node to an already existing cluster | ||
| Wants=network-online.target | ||
| Requires=apply-host-config.service | ||
| PartOf=assisted-service-pod.service | ||
| After=network-online.target apply-host-config.service | ||
| ConditionPathExists=/etc/assisted/node0 | ||
|
|
||
| [Service] | ||
| EnvironmentFile=/usr/local/share/assisted-service/assisted-service.env | ||
| EnvironmentFile=/usr/local/share/start-cluster/start-cluster.env | ||
| EnvironmentFile=/etc/assisted/rendezvous-host.env | ||
| ExecStartPre=/usr/local/bin/wait-for-assisted-service.sh | ||
| ExecStart=/usr/local/bin/add-node.sh | ||
|
|
||
| KillMode=none | ||
| Type=oneshot | ||
| RemainAfterExit=true | ||
|
|
||
| [Install] | ||
| WantedBy=multi-user.target |
28 changes: 28 additions & 0 deletions
28
data/data/agent/systemd/units/agent-import-cluster.service.template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| [Unit] | ||
| Description=Imports an already existing cluster | ||
| Wants=network-online.target assisted-service.service | ||
| PartOf=assisted-service-pod.service | ||
| After=network-online.target assisted-service.service | ||
| ConditionPathExists=/etc/assisted/node0 | ||
|
|
||
| [Service] | ||
| Environment=PODMAN_SYSTEMD_UNIT=%n | ||
| Environment=OPENSHIFT_INSTALL_RELEASE_IMAGE_MIRROR={{.ReleaseImageMirror}} | ||
| EnvironmentFile=/etc/assisted/rendezvous-host.env | ||
| EnvironmentFile=/usr/local/share/assisted-service/agent-images.env | ||
| EnvironmentFile=/usr/local/share/assisted-service/assisted-service.env | ||
| EnvironmentFile=/etc/assisted/add-nodes.env | ||
| ExecStartPre=/bin/rm -f %t/%n.ctr-id | ||
| ExecStartPre=/usr/local/bin/wait-for-assisted-service.sh | ||
| ExecStart=podman run --net host --cidfile=%t/%n.ctr-id --cgroups=no-conmon --log-driver=journald --rm --pod-id-file=%t/assisted-service-pod.pod-id --replace --name=agent-import-cluster -v /etc/assisted/manifests:/manifests -v /etc/assisted/extra-manifests:/extra-manifests -v /etc/pki/ca-trust:/etc/pki/ca-trust:z {{ if .HaveMirrorConfig }}-v /etc/containers:/etc/containers{{ end }} --env SERVICE_BASE_URL --env OPENSHIFT_INSTALL_RELEASE_IMAGE_MIRROR --env CLUSTER_ID --env CLUSTER_NAME --env CLUSTER_API_VIP_DNS_NAME $SERVICE_IMAGE /usr/local/bin/agent-installer-client importCluster | ||
| ExecStop=/usr/bin/podman stop --ignore --cidfile=%t/%n.ctr-id | ||
| ExecStopPost=/usr/bin/podman rm -f --ignore --cidfile=%t/%n.ctr-id | ||
|
|
||
| KillMode=none | ||
| Type=oneshot | ||
| Restart=on-failure | ||
| RestartSec=30 | ||
| RemainAfterExit=true | ||
|
|
||
| [Install] | ||
| WantedBy=multi-user.target |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| #!/bin/sh | ||
|
|
||
| set -ex | ||
|
|
||
| # shellcheck disable=SC2068 | ||
| version() { IFS="."; printf "%03d%03d%03d\\n" $@; unset IFS;} | ||
|
|
||
| minimum_go_version=1.21 | ||
| current_go_version=$(go version | cut -d " " -f 3) | ||
|
|
||
| if [ "$(version "${current_go_version#go}")" -lt "$(version "$minimum_go_version")" ]; then | ||
| echo "Go version should be greater or equal to $minimum_go_version" | ||
| exit 1 | ||
| fi | ||
|
|
||
| export CGO_ENABLED=0 | ||
| MODE="${MODE:-release}" | ||
|
|
||
| GIT_COMMIT="${SOURCE_GIT_COMMIT:-$(git rev-parse --verify 'HEAD^{commit}')}" | ||
| GIT_TAG="${BUILD_VERSION:-$(git describe --always --abbrev=40 --dirty)}" | ||
| DEFAULT_ARCH="${DEFAULT_ARCH:-amd64}" | ||
| GOFLAGS="${GOFLAGS:--mod=vendor}" | ||
| GCFLAGS="" | ||
| LDFLAGS="${LDFLAGS} -X github.com/openshift/installer/pkg/version.Raw=${GIT_TAG} -X github.com/openshift/installer/pkg/version.Commit=${GIT_COMMIT} -X github.com/openshift/installer/pkg/version.defaultArch=${DEFAULT_ARCH}" | ||
| TAGS="${TAGS:-}" | ||
| OUTPUT="${OUTPUT:-bin/node-joiner}" | ||
|
|
||
| case "${MODE}" in | ||
| release) | ||
| LDFLAGS="${LDFLAGS} -s -w" | ||
| TAGS="${TAGS} release" | ||
| ;; | ||
| dev) | ||
| GCFLAGS="${GCFLAGS} all=-N -l" | ||
| ;; | ||
| *) | ||
| echo "unrecognized mode: ${MODE}" >&2 | ||
| exit 1 | ||
| esac | ||
|
|
||
| if test "${SKIP_GENERATION}" != y | ||
| then | ||
| # this step has to be run natively, even when cross-compiling | ||
| GOOS='' GOARCH='' go generate ./data | ||
| fi | ||
|
|
||
| echo "building node-joiner" | ||
|
|
||
| # shellcheck disable=SC2086 | ||
| go build ${GOFLAGS} -gcflags "${GCFLAGS}" -ldflags "${LDFLAGS}" -tags "${TAGS}" -o "${OUTPUT}" ./cmd/node-joiner |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need a timeout followed by error message here? Alternatively, do we need a status_issue for this step?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question. I think here, the cluster_id should be available fairly quickly as the agent-add-node service has an After dependency on apply-host-config.service, which itself, has a dependency on agent-register-infra.service and it on agent-import-cluster.service. So by the time this script/service runs the cluster_id should be available.
@sadasu What is a status_issue? Could you explain? Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, as per the agent services architecture I'd expect that in case of issue the
agent-register-clusterwould prevent the other services, the loop here it's just to cope in case of slower execution (similar approach in another scritps)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sadasu Please disregard my question. I see status_issue updated below.