Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions internal/ignition/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,22 @@ IMAGE=$(echo $1 | sed 's/[@:].*//')
podman images | grep $IMAGE || podman rmi --force $1 || true
`

const agentPullImage = `#!/usr/bin/sh
IMAGE=$1
DELAY=5
MAX_DELAY=300
podman image exists "$IMAGE" && exit 0
while true; do
podman pull "$IMAGE" && exit 0
echo "Pull failed for $IMAGE, retrying in ${DELAY}s..."
sleep $DELAY
DELAY=$((DELAY * 2))
if [ $DELAY -gt $MAX_DELAY ]; then
DELAY=$MAX_DELAY
fi
done
`

const okdBinariesOverlayTemplate = `#!/bin/env bash
set -eux
# Fetch an image with OKD rpms
Expand Down Expand Up @@ -303,6 +319,7 @@ func (ib *ignitionBuilder) FormatDiscoveryIgnitionFile(ctx context.Context, infr
"PullSecretToken": pullSecretToken,
"AGENT_MOTD": url.PathEscape(agentMessageOfTheDay),
"AGENT_FIX_BZ1964591": url.PathEscape(agentFixBZ1964591),
"AGENT_PULL_IMAGE": url.PathEscape(agentPullImage),
"IPv6_CONF": url.PathEscape(common.Ipv6DuidDiscoveryConf),
"PULL_SECRET": url.PathEscape(infraEnv.PullSecret),
"RH_ROOT_CA": rhCa,
Expand Down
3 changes: 2 additions & 1 deletion internal/ignition/templates/agent.service
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ Environment=no_proxy={{.NoProxy}}{{if .PullSecretToken}}
Environment=PULL_SECRET_TOKEN={{.PullSecretToken}}{{end}}
TimeoutStartSec={{.AgentTimeoutStartSec}}
ExecStartPre=/usr/local/bin/agent-fix-bz1964591 {{.AgentDockerImg}}
ExecStartPre=podman run --privileged --rm -v /usr/local/bin:/hostbin {{.AgentDockerImg}} cp /usr/bin/agent /hostbin
ExecStartPre=/usr/local/bin/agent-pull-image {{.AgentDockerImg}}
ExecStartPre=podman run --pull=never --privileged --rm -v /usr/local/bin:/hostbin {{.AgentDockerImg}} cp /usr/bin/agent /hostbin
ExecStart=/usr/local/bin/agent --url {{.ServiceBaseURL}} --infra-env-id {{.infraEnvId}} --agent-version {{.AgentDockerImg}} --insecure={{.SkipCertVerification}} {{if .HostCACertPath}}--cacert {{.HostCACertPath}}{{end}}

[Unit]
Expand Down
9 changes: 9 additions & 0 deletions internal/ignition/templates/discovery.ign
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@
},
"contents": { "source": "data:,{{.AGENT_FIX_BZ1964591}}" }
},
{
"overwrite": true,
"path": "/usr/local/bin/agent-pull-image",
"mode": 493,
"user": {
"name": "root"
},
"contents": { "source": "data:,{{.AGENT_PULL_IMAGE}}" }
},
{
"overwrite": true,
"path": "/etc/motd",
Expand Down