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
1 change: 1 addition & 0 deletions cmd/openshift-install/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func newAgentCmd(ctx context.Context) *cobra.Command {
agentCmd.AddCommand(newAgentCreateCmd(ctx))
agentCmd.AddCommand(agent.NewWaitForCmd())
agentCmd.AddCommand(newAgentGraphCmd())
agentCmd.AddCommand(agent.NewGatherCmd())
return agentCmd
}

Expand Down
104 changes: 104 additions & 0 deletions cmd/openshift-install/agent/gather.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
package agent

import (
"context"
"fmt"
"os"
"time"

"github.com/sirupsen/logrus"
"github.com/spf13/cobra"

"github.com/openshift/installer/cmd/openshift-install/command"
agentpkg "github.com/openshift/installer/pkg/agent"
assetstore "github.com/openshift/installer/pkg/asset/store"
"github.com/openshift/installer/pkg/asset/tls"
)

var agentGatherOpts struct {
sshKeys []string
}

// NewGatherCmd creates the commands for gathering debug data from an agent-based installation.
func NewGatherCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "gather",
Short: "Gather debugging data for a failed agent-based installation",
Long: `Gather debugging data for a failed agent-based installation.

When an agent-based installation fails, this command collects debugging
data from the rendezvous host to help diagnose the issue.`,
RunE: func(cmd *cobra.Command, args []string) error {
return cmd.Help()
},
}

cmd.AddCommand(newAgentGatherCmd())
return cmd
}

func newAgentGatherCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "bootstrap",
Short: "Gather debugging data from the rendezvous host",
Args: cobra.ExactArgs(0),
Run: func(_ *cobra.Command, _ []string) {
cleanup := command.SetupFileHook(command.RootOpts.Dir)
defer cleanup()

bundlePath, err := runAgentGatherCmd(command.RootOpts.Dir)
if err != nil {
logrus.Fatal(err)
}
logrus.Infof("Agent gather logs captured here %q", bundlePath)
},
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.

cmd.PersistentFlags().StringArrayVar(&agentGatherOpts.sshKeys, "key", []string{},
"Path to SSH private keys that should be used for authentication. "+
"If no key was provided, SSH private keys from user's environment will be used")
return cmd
}

func runAgentGatherCmd(directory string) (string, error) {
ctx := context.TODO()

store, err := assetstore.NewStore(directory)
if err != nil {
return "", fmt.Errorf("failed to create asset store: %w", err)
}

rendezvousIP, err := agentpkg.FindRendezvousIPFromAssetStore(store)
if err != nil {
return "", fmt.Errorf("failed to determine rendezvous host: %w", err)
}
logrus.Infof("Rendezvous host IP: %s", rendezvousIP)

// add the bootstrap SSH key pair to the sshKeys list automatically
bootstrapSSHKeyPair := &tls.BootstrapSSHKeyPair{}
if err := store.Fetch(ctx, bootstrapSSHKeyPair); err != nil {
logrus.Debugf("Failed to fetch bootstrap SSH key pair: %v", err)
} else {
tmpfile, err := os.CreateTemp("", "bootstrap-ssh")
if err != nil {
return "", err
}
defer os.Remove(tmpfile.Name())
if _, err := tmpfile.Write(bootstrapSSHKeyPair.Private()); err != nil {
return "", err
}
if err := tmpfile.Close(); err != nil {
return "", err
}
agentGatherOpts.sshKeys = append(agentGatherOpts.sshKeys, tmpfile.Name())
}
Comment on lines +77 to +94

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Avoid persisting a deleted temp-key path in global options.

Line 93 appends the temp key path to package-level agentGatherOpts.sshKeys, but Line 86 removes that file when the function returns. A later in-process invocation or test can inherit a stale key path. Use a local copy for this run.

Proposed fix
+	sshKeys := append([]string{}, agentGatherOpts.sshKeys...)
+
 	// add the bootstrap SSH key pair to the sshKeys list automatically
 	bootstrapSSHKeyPair := &tls.BootstrapSSHKeyPair{}
 	if err := store.Fetch(ctx, bootstrapSSHKeyPair); err != nil {
 		logrus.Debugf("Failed to fetch bootstrap SSH key pair: %v", err)
@@
-		agentGatherOpts.sshKeys = append(agentGatherOpts.sshKeys, tmpfile.Name())
+		sshKeys = append(sshKeys, tmpfile.Name())
 	}

 	gatherID := time.Now().Format("20060102150405")

-	bundlePath, err := agentpkg.PullAgentGatherArchive(rendezvousIP, agentGatherOpts.sshKeys, directory, gatherID)
+	bundlePath, err := agentpkg.PullAgentGatherArchive(rendezvousIP, sshKeys, directory, gatherID)

Also applies to: 98-98

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cmd/openshift-install/agent/gather.go` around lines 77 - 94, The temp
bootstrap SSH key path is being stored in the package-level
agentGatherOpts.sshKeys even though the file is removed when gatherSSHKeys
returns, so later runs can inherit a stale path. Update gatherSSHKeys to build
and use a local sshKeys slice for this invocation, append the temp file name
there, and pass that local list onward instead of mutating the shared
agentGatherOpts state.


gatherID := time.Now().Format("20060102150405")

bundlePath, err := agentpkg.PullAgentGatherArchive(rendezvousIP, agentGatherOpts.sshKeys, directory, gatherID)
if err != nil {
return "", fmt.Errorf("failed to gather data from rendezvous host: %w", err)
}

return bundlePath, nil
Comment on lines +40 to +103

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify tests cover the new gather command/helper wiring without assuming file layout.
rg -n --glob '*_test.go' 'NewGatherCmd|newAgentGatherCmd|runAgentGatherCmd|PullAgentGatherArchive'

Repository: openshift/installer

Length of output: 157


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Map the relevant command package and locate related tests.
git ls-files 'cmd/openshift-install/agent/*' 'cmd/openshift-install/*_test.go' | sort

echo '--- outline gather.go ---'
ast-grep outline cmd/openshift-install/agent/gather.go --view expanded || true

echo '--- search for agent gather tests and related helpers ---'
rg -n --glob 'cmd/openshift-install/**/*_test.go' \
  'gather|Rendezvous|BootstrapSSHKeyPair|PullAgentGatherArchive|newAgentGatherCmd|runAgentGatherCmd|agentGatherOpts'

echo '--- search for command setup tests elsewhere ---'
rg -n --glob '**/*_test.go' \
  'SetupFileHook|PullAgentGatherArchive|FindRendezvousIPFromAssetStore|BootstrapSSHKeyPair'

Repository: openshift/installer

Length of output: 757


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Enumerate unit-test files in cmd/openshift-install and look for command-path coverage.
git ls-files 'cmd/openshift-install/**/*_test.go' | sort

echo '--- command-related test coverage ---'
rg -n --glob 'cmd/openshift-install/**/*_test.go' \
  'New.*Cmd|new.*Cmd|run.*Cmd|gather|waitfor|agent' \
  cmd/openshift-install

Repository: openshift/installer

Length of output: 472


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the existing cmd/openshift-install tests to see whether they are unit tests
# and whether they exercise the new gather command path.
ast-grep outline cmd/openshift-install/integration_test.go --view expanded || true
echo '---'
ast-grep outline cmd/openshift-install/internal_integration_test.go --view expanded || true

echo '--- file headers ---'
sed -n '1,140p' cmd/openshift-install/integration_test.go
echo '---'
sed -n '1,180p' cmd/openshift-install/internal_integration_test.go

Repository: openshift/installer

Length of output: 6415


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Check the test file kinds and whether they import testing-only integration deps.
for f in cmd/openshift-install/integration_test.go cmd/openshift-install/internal_integration_test.go; do
  echo "--- $f ---"
  sed -n '1,120p' "$f"
done

Repository: openshift/installer

Length of output: 4164


Add unit tests for the agent gather command path cmd/openshift-install/agent/gather.go is only covered by integration tests today; add focused unit coverage for rendezvous lookup, bootstrap-key fallback, temp-key cleanup, and PullAgentGatherArchive wiring.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cmd/openshift-install/agent/gather.go` around lines 40 - 103, Add focused
unit tests around newAgentGatherCmd and runAgentGatherCmd to cover the agent
gather flow without relying on integration tests. Mock assetstore.NewStore,
agentpkg.FindRendezvousIPFromAssetStore, store.Fetch, os.CreateTemp, and
agentpkg.PullAgentGatherArchive to verify rendezvous lookup, bootstrap SSH key
fallback, temporary key cleanup, and that agentGatherOpts.sshKeys is wired into
the archive pull call. Keep the tests centered on runAgentGatherCmd and the
command Run path so the behavior is covered even if line numbers shift.

Source: Coding guidelines

}
8 changes: 4 additions & 4 deletions cmd/openshift-install/agent/waitfor.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ func newWaitForBootstrapCompleteCmd() *cobra.Command {
logrus.Fatal(err)
}

rendezvousIP, sshKey, err := agentpkg.FindRendezvousIPAndSSHKeyFromAssetStore(assetStore)
rendezvousIP, err := agentpkg.FindRendezvousIPFromAssetStore(assetStore)
if err != nil {
logrus.Fatal(err)
}

ctx := context.Background()
cluster, err := agentpkg.NewCluster(ctx, assetStore, rendezvousIP, kubeconfigPath, sshKey, workflow.AgentWorkflowTypeInstall)
cluster, err := agentpkg.NewCluster(ctx, assetStore, rendezvousIP, kubeconfigPath, workflow.AgentWorkflowTypeInstall)
if err != nil {
logrus.Exit(command.ExitCodeBootstrapFailed)
}
Expand Down Expand Up @@ -107,13 +107,13 @@ func newWaitForInstallCompleteCmd() *cobra.Command {
logrus.Fatal(err)
}

rendezvousIP, sshKey, err := agentpkg.FindRendezvousIPAndSSHKeyFromAssetStore(assetStore)
rendezvousIP, err := agentpkg.FindRendezvousIPFromAssetStore(assetStore)
if err != nil {
logrus.Fatal(err)
}

ctx := context.Background()
cluster, err := agentpkg.NewCluster(ctx, assetStore, rendezvousIP, kubeconfigPath, sshKey, workflow.AgentWorkflowTypeInstall)
cluster, err := agentpkg.NewCluster(ctx, assetStore, rendezvousIP, kubeconfigPath, workflow.AgentWorkflowTypeInstall)
if err != nil {
logrus.Exit(command.ExitCodeBootstrapFailed)
}
Expand Down
17 changes: 11 additions & 6 deletions data/data/agent/files/usr/local/bin/agent-gather
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ function gather_bootstrap_status() {
( >&2 echo -n ".")
if [ -f /usr/local/bin/installer-gather.sh ]; then
local bs_gather="${ARTIFACTS_DIR}/bootstrap-gather.tar.gz"
TAR_FILE="${bs_gather}" /usr/local/bin/installer-gather.sh --id "$(date '+%Y%m%d%H%M%S')" >/dev/null
TAR_FILE="${bs_gather}" /usr/local/bin/installer-gather.sh --id "${GATHER_ID}" >/dev/null
( >&2 echo -n ".")
[ -f "${bs_gather}" ] && gunzip "${bs_gather}"
fi
Expand All @@ -134,19 +134,24 @@ function Help()
{
echo "Gathers the necessary data for troubleshooting OpenShift's agent based installation"
echo
echo "Syntax: agent-gather [-h|-v]"
echo "Syntax: agent-gather [-h|-i ID|-v|-O]"
echo "options:"
echo "-h Print this help"
echo "-O Output the compressed content to stdout"
echo "-h Print this help"
echo "-i Set the gather ID (determines output filename)"
echo "-O Output the compressed content to stdout"
echo "-v Set verbose mode"
echo
}

while getopts ":hvO" option; do
GATHER_ID="$(date '+%Y%m%d%H%M%S')"

while getopts ":hvOi:" option; do
case $option in
h)
Help
exit;;
i)
GATHER_ID="$OPTARG";;
v)
set -xv;;
O)
Expand Down Expand Up @@ -179,7 +184,7 @@ gather_bootstrap_status
find "$ARTIFACTS_DIR" -type d -exec chmod a+rwx "{}" \;
find "$ARTIFACTS_DIR" -type f -exec chmod a+rw "{}" \;

OUTPUT_FILE="./agent-gather-$(date +%Y%m%d-%H%M%S%Z).tar.xz"
OUTPUT_FILE="./agent-gather-${GATHER_ID}.tar.xz"
( >&2 echo "Compressing gathered data to $OUTPUT_FILE" )

if [[ "$STDOUT" == "1" ]]; then
Expand Down
4 changes: 2 additions & 2 deletions pkg/agent/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ type clusterInstallStatusHistory struct {
}

// NewCluster initializes a Cluster object
func NewCluster(ctx context.Context, assetStore asset.Store, rendezvousIP, kubeconfigPath, sshKey string, workflowType workflow.AgentWorkflowType) (*Cluster, error) {
func NewCluster(ctx context.Context, assetStore asset.Store, rendezvousIP, kubeconfigPath string, workflowType workflow.AgentWorkflowType) (*Cluster, error) {
czero := &Cluster{}
capi := &clientSet{}

Expand All @@ -81,7 +81,7 @@ func NewCluster(ctx context.Context, assetStore asset.Store, rendezvousIP, kubec
return nil, fmt.Errorf("AgentWorkflowType value not supported: %s", workflowType)
}

restclient := NewNodeZeroRestClient(ctx, rendezvousIP, sshKey, watcherAuthToken)
restclient := NewNodeZeroRestClient(ctx, rendezvousIP, watcherAuthToken)

kubeclient, err := NewClusterKubeAPIClient(ctx, kubeconfigPath)
if err != nil {
Expand Down
47 changes: 47 additions & 0 deletions pkg/agent/gather.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package agent

import (
"fmt"
"net"
"path"
"path/filepath"
"strconv"

"github.com/sirupsen/logrus"

gatherssh "github.com/openshift/installer/pkg/gather/ssh"
)

// PullAgentGatherArchive SSHs to the rendezvous host and runs the
// agent-gather script, pulling the resulting tar.xz archive to the
// local directory.
func PullAgentGatherArchive(rendezvousIP string, sshKeys []string, directory, gatherID string) (string, error) {
logrus.Info("Pulling agent-gather data from the rendezvous host")

address := net.JoinHostPort(rendezvousIP, strconv.Itoa(22))
client, err := gatherssh.NewClient("core", address, sshKeys)
if err != nil {
return "", fmt.Errorf("failed to create SSH client for rendezvous host %s: %w", rendezvousIP, err)
}

// Run agent-gather with -i so it writes to a predictable path
cmd := fmt.Sprintf("sudo /usr/local/bin/agent-gather -i %s", gatherID)
if err := gatherssh.Run(client, cmd); err != nil {
return "", fmt.Errorf("failed to run agent-gather on rendezvous host %s: %w", rendezvousIP, err)
}

archiveName := fmt.Sprintf("agent-gather-%s.tar.xz", gatherID)
remoteFile := path.Join("/home/core", archiveName)
localFile := filepath.Join(directory, archiveName)
if err := gatherssh.PullFileTo(client, remoteFile, localFile); err != nil {
return "", fmt.Errorf("failed to pull agent-gather archive: %w", err)
}

absPath, err := filepath.Abs(localFile)
if err != nil {
return "", fmt.Errorf("failed to get absolute path: %w", err)
}

logrus.Info("Successfully pulled agent-gather data")
return absPath, nil
}
Comment on lines +18 to +47

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
ast-grep outline pkg/gather/ssh
rg -n -A5 'func NewClient|func Run|func PullFileTo' pkg/gather/ssh

Repository: openshift/installer

Length of output: 1335


🏁 Script executed:

#!/bin/bash
sed -n '1,220p' pkg/gather/ssh/ssh.go

Repository: openshift/installer

Length of output: 4360


Add a timeout to the SSH gather path. ssh.Dial, sess.Run, and the SFTP download here have no deadline, so a stalled rendezvous host or network issue can block the CLI indefinitely.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/agent/gather.go` around lines 18 - 47, The SSH gather flow in
PullAgentGatherArchive can block indefinitely because the client connection,
command execution, and file transfer have no deadline. Add a timeout to the
rendezvous host path by threading a context or explicit timeout into
gatherssh.NewClient, gatherssh.Run, and gatherssh.PullFileTo, and ensure the
timeout is enforced for the ssh.Dial/session/SFTP operations. Keep the change
localized to PullAgentGatherArchive and the gatherssh helpers it calls so all
three stages fail fast on stalled hosts or networks.

Source: Path instructions

36 changes: 9 additions & 27 deletions pkg/agent/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"github.com/openshift/installer/pkg/asset/agent/gencrypto"
"github.com/openshift/installer/pkg/asset/agent/image"
"github.com/openshift/installer/pkg/asset/agent/manifests"
"github.com/openshift/installer/pkg/asset/installconfig"
"github.com/openshift/installer/pkg/types/agent"
)

Expand All @@ -29,18 +28,12 @@ type NodeZeroRestClient struct {
ctx context.Context
config client.Config
NodeZeroIP string
NodeSSHKey []string
}

// NewNodeZeroRestClient Initialize a new rest client to interact with the Agent Rest API on node zero.
func NewNodeZeroRestClient(ctx context.Context, rendezvousIP, sshKey, watcherAuthToken string) *NodeZeroRestClient {
func NewNodeZeroRestClient(ctx context.Context, rendezvousIP, watcherAuthToken string) *NodeZeroRestClient {
restClient := &NodeZeroRestClient{}

// Get SSH Keys which can be used to determine if Rest API failures are due to network connectivity issues
if sshKey != "" {
restClient.NodeSSHKey = append(restClient.NodeSSHKey, sshKey)
}

config := client.Config{}
config.URL = &url.URL{
Scheme: "http",
Expand All @@ -60,16 +53,14 @@ func NewNodeZeroRestClient(ctx context.Context, rendezvousIP, sshKey, watcherAut
return restClient
}

// FindRendezvousIPAndSSHKeyFromAssetStore returns the rendezvousIP and public ssh key.
func FindRendezvousIPAndSSHKeyFromAssetStore(assetStore asset.Store) (string, string, error) {
// FindRendezvousIPFromAssetStore returns the rendezvous IP of the agent cluster.
func FindRendezvousIPFromAssetStore(assetStore asset.Store) (string, error) {
agentConfigAsset := &agentconfig.AgentConfig{}
agentManifestsAsset := &manifests.AgentManifests{}
installConfigAsset := &installconfig.InstallConfig{}
agentHostsAsset := &agentconfig.AgentHosts{}

agentConfig, agentConfigError := assetStore.Load(agentConfigAsset)
agentManifests, manifestError := assetStore.Load(agentManifestsAsset)
installConfig, installConfigError := assetStore.Load(installConfigAsset)
agentHosts, agentHostsError := assetStore.Load(agentHostsAsset)

if agentConfigError != nil {
Expand All @@ -78,14 +69,11 @@ func FindRendezvousIPAndSSHKeyFromAssetStore(assetStore asset.Store) (string, st
if manifestError != nil {
logrus.Debug(errors.Wrapf(manifestError, "failed to load %s", agentManifestsAsset.Name()))
}
if installConfigError != nil {
logrus.Debug(errors.Wrapf(installConfigError, "failed to load %s", installConfigAsset.Name()))
}
if agentHostsError != nil {
logrus.Debug(errors.Wrapf(agentConfigError, "failed to load %s", agentHostsAsset.Name()))
logrus.Debug(errors.Wrapf(agentHostsError, "failed to load %s", agentHostsAsset.Name()))
}
if agentConfigError != nil || manifestError != nil || installConfigError != nil || agentHostsError != nil {
return "", "", errors.New("failed to load AgentConfig, NMStateConfig, InstallConfig, or AgentHosts")
if agentConfigError != nil || manifestError != nil || agentHostsError != nil {
return "", errors.New("failed to load AgentConfig, NMStateConfig, or AgentHosts")
}

var rendezvousIP string
Expand All @@ -99,19 +87,13 @@ func FindRendezvousIPAndSSHKeyFromAssetStore(assetStore asset.Store) (string, st
} else if agentConfig != nil && agentManifests == nil {
rendezvousIP, rendezvousIPError = image.RetrieveRendezvousIP(agentConfig.(*agentconfig.AgentConfig).Config, agentHosts.(*agentconfig.AgentHosts).Hosts, emptyNMStateConfigs)
} else {
return "", "", errors.New("both AgentConfig and NMStateConfig are empty")
return "", errors.New("both AgentConfig and NMStateConfig are empty")
}
if rendezvousIPError != nil {
return "", "", rendezvousIPError
}

var sshKey string
// Get SSH Keys which can be used to determine if Rest API failures are due to network connectivity issues
if installConfig != nil {
sshKey = installConfig.(*installconfig.InstallConfig).Config.SSHKey
return "", rendezvousIPError
}

return rendezvousIP, sshKey, nil
return rendezvousIP, nil
}

// FindAuthTokenFromAssetStore returns the auth token from asset store.
Expand Down
5 changes: 4 additions & 1 deletion pkg/asset/agent/image/ignition.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ func (a *Ignition) Dependencies() []asset.Asset {
&tls.KubeAPIServerLocalhostSignerCertKey{},
&tls.KubeAPIServerServiceNetworkSignerCertKey{},
&tls.AdminKubeConfigSignerCertKey{},
&tls.BootstrapSSHKeyPair{},
&password.KubeadminPassword{},
&agentconfig.AgentConfig{},
&agentconfig.AgentHosts{},
Expand Down Expand Up @@ -136,7 +137,8 @@ func (a *Ignition) Generate(ctx context.Context, dependencies asset.Parents) err
}

pwd := &password.KubeadminPassword{}
dependencies.Get(pwd)
bootstrapSSHKeyPair := &tls.BootstrapSSHKeyPair{}
dependencies.Get(pwd, bootstrapSSHKeyPair)
pwdHash := string(pwd.PasswordHash)

infraEnv := agentManifests.InfraEnv
Expand All @@ -151,6 +153,7 @@ func (a *Ignition) Generate(ctx context.Context, dependencies asset.Parents) err
Name: "core",
SSHAuthorizedKeys: []igntypes.SSHAuthorizedKey{
igntypes.SSHAuthorizedKey(infraEnv.Spec.SSHAuthorizedKey),
igntypes.SSHAuthorizedKey(string(bootstrapSSHKeyPair.Public())),
Comment thread
coderabbitai[bot] marked this conversation as resolved.
},
PasswordHash: &pwdHash,
},
Expand Down
6 changes: 6 additions & 0 deletions pkg/asset/agent/image/ignition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,11 @@ logdir /var/log/chrony`,
assertExpectedFiles(t, ignitionAsset.Config, tc.expectedFiles, tc.expectedFileContent)

assertServiceEnabled(t, ignitionAsset.Config, tc.serviceEnabledMap)

assert.Len(t, ignitionAsset.Config.Passwd.Users, 1)
assert.Equal(t, "core", ignitionAsset.Config.Passwd.Users[0].Name)
assert.Contains(t, ignitionAsset.Config.Passwd.Users[0].SSHAuthorizedKeys, igntypes.SSHAuthorizedKey("my-ssh-key"))
assert.Contains(t, ignitionAsset.Config.Passwd.Users[0].SSHAuthorizedKeys, igntypes.SSHAuthorizedKey("test-bootstrap-ssh-key\n"))
}
})
}
Expand Down Expand Up @@ -801,6 +806,7 @@ func buildIgnitionAssetDefaultDependencies(t *testing.T) []asset.Asset {
&tls.KubeAPIServerServiceNetworkSignerCertKey{},
&tls.AdminKubeConfigSignerCertKey{},
&tls.AdminKubeConfigClientCertKey{},
&tls.BootstrapSSHKeyPair{Pub: []byte("test-bootstrap-ssh-key\n")},
&gencrypto.AuthConfig{},
&common.InfraEnvID{},
&agentcommon.OptionalInstallConfig{},
Expand Down
Loading