-
Notifications
You must be signed in to change notification settings - Fork 1.5k
AGENT-502: Enable agent tui #6898
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| [Unit] | ||
| Description=Get interactive user configuration at boot | ||
| After=network-pre.target NetworkManager.service pre-network-manager-config.service selinux.service | ||
| Before=network.target network.service agent.service NetworkManager-wait-online.service | ||
| Before=network.target network.service agent.service node-zero.service NetworkManager-wait-online.service | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm surprised
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is I thought for a minute that we should use |
||
|
|
||
| [Service] | ||
| Type=oneshot | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ | |
| Description=Agent-based installer hostname update service | ||
| Wants=network-online.target | ||
| After=local-fs.target | ||
| Before=node-zero.service | ||
| Before=agent-interactive-console.service | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn't hurt to list both here. |
||
|
|
||
| [Service] | ||
| ExecStart=/usr/local/bin/set-hostname.sh | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,14 +53,12 @@ func (a *AgentImage) Generate(dependencies asset.Parents) error { | |
| return err | ||
| } | ||
|
|
||
| additionalFiles := []string{} | ||
| agentTuiFile, err := a.fetchAgentTuiBinary(agentManifests.ClusterImageSet.Spec.ReleaseImage, agentManifests.GetPullSecretData(), registriesConf.MirrorConfig) | ||
| agentTuiFiles, err := a.fetchAgentTuiFiles(agentManifests.ClusterImageSet.Spec.ReleaseImage, agentManifests.GetPullSecretData(), registriesConf.MirrorConfig) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| additionalFiles = append(additionalFiles, agentTuiFile) | ||
|
|
||
| err = a.prepareAgentISO(baseImage.File.Filename, ignitionByte, additionalFiles) | ||
| err = a.prepareAgentISO(baseImage.File.Filename, ignitionByte, agentTuiFiles) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
@@ -71,25 +69,28 @@ func (a *AgentImage) Generate(dependencies asset.Parents) error { | |
| return nil | ||
| } | ||
|
|
||
| func (a *AgentImage) fetchAgentTuiBinary(releaseImage string, pullSecret string, mirrorConfig []mirror.RegistriesConfig) (string, error) { | ||
| r := NewRelease(&executer.CommonExecuter{}, | ||
| func (a *AgentImage) fetchAgentTuiFiles(releaseImage string, pullSecret string, mirrorConfig []mirror.RegistriesConfig) ([]string, error) { | ||
| release := NewRelease(&executer.CommonExecuter{}, | ||
| Config{MaxTries: OcDefaultTries, RetryDelay: OcDefaultRetryDelay}, | ||
| releaseImage, pullSecret, mirrorConfig) | ||
|
|
||
| // TODO: This is just a temporary placeholder to test the entire workflow. | ||
| // As soon as https://github.com/openshift/assisted-installer-agent/pull/482 will land, then | ||
| // the following line should be fixed to extract the agent-tui binary | ||
| filename, err := r.ExtractFile("agent-installer-node-agent", "/usr/bin/agent") | ||
| if err != nil { | ||
| return "", err | ||
| } | ||
| // Make sure it could be executed | ||
| err = os.Chmod(filename, 0o555) | ||
| if err != nil { | ||
| return "", err | ||
| agentTuiFilenames := []string{"/usr/bin/agent-tui", "/usr/lib64/libnmstate.so.1.3.3"} | ||
| files := []string{} | ||
|
|
||
| for _, srcFile := range agentTuiFilenames { | ||
| f, err := release.ExtractFile("agent-installer-node-agent", srcFile) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| // Make sure it could be executed | ||
| err = os.Chmod(f, 0o555) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| files = append(files, f) | ||
| } | ||
|
|
||
| return filename, nil | ||
| return files, nil | ||
| } | ||
|
|
||
| func (a *AgentImage) prepareAgentISO(iso string, ignition []byte, additionalFiles []string) error { | ||
|
|
@@ -181,7 +182,10 @@ func (a *AgentImage) appendAgentFilesToInitrd(additionalFiles []string) error { | |
| // Add a dracut hook to copy the files. The $NEWROOT environment variable is exported by | ||
| // dracut during the startup and it refers the mountpoint for the root filesystem. | ||
| dracutHookScript := `#!/bin/sh | ||
| cp -R /agent-files/* $NEWROOT/usr/local/bin/` | ||
| cp -R /agent-files/* $NEWROOT/usr/local/bin/ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In a perfect world,
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In general I agree, in the sense that this is just a first rough mechanism to copy over stuff from the initramfs to the disk to have an initial integration, and it could be definitely improved as our requirements increase. We could follouwup in a subsequent pr |
||
| # Fix the selinux label | ||
| for i in $(find /agent-files/ -printf "%P\n"); do chcon system_u:object_r:bin_t:s0 $NEWROOT/usr/local/bin/$i; done` | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if I've missed something, but in my tests
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's in CoreOS, but maybe not in the initramfs 🙁 |
||
|
|
||
| err = ca.StoreBytes("/usr/lib/dracut/hooks/pre-pivot/99-agent-copy-files.sh", []byte(dracutHookScript), 0o755) | ||
| if err != nil { | ||
| return err | ||
|
|
||
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.
This is worth at least a comment.