Skip to content

Commit 2fd74d7

Browse files
andfasanorwsu
andcommitted
Apply suggestions from code review
Co-authored-by: Richard Su <[email protected]>
1 parent 5a3e543 commit 2fd74d7

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

docs/user/agent/add-nodes.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
1. Download the [node-joiner.sh](./node-joiner.sh) script in a working directory in
99
the user host (the "assets folder").
1010
2. Create a `nodes-config.yaml` in the assets folder. This configuration file must contain the
11-
list of all the nodes that the user wants to add to the target cluster. For each node it must be
12-
specified at least the name and the primary interface mac address, for example:
11+
list of all the nodes that the user wants to add to the target cluster. At minimum, the name and primary interface MAC address must be specified. For example:
1312
```
1413
hosts:
1514
- hostname: extra-worker-0
@@ -25,7 +24,7 @@ hosts:
2524
- name: eth0
2625
macAddress: 00:02:46:e3:9e:9c
2726
```
28-
3. Optionally, it's possible to specify - for each node - an `NMState` configuration block
27+
3. Optionally, it's possible to specify - for each node - an `NMState` configuration block denoted below as `networkConfig`
2928
(it will be applied during the first boot), for example:
3029
```
3130
hosts:

docs/user/agent/node-joiner.sh

100644100755
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ set -eu
44

55
# Config file
66
nodesConfigFile=${1:-"nodes-config.yaml"}
7-
if [ ! -f $nodesConfigFile ]; then
7+
if [ ! -f "$nodesConfigFile" ]; then
88
echo "Cannot find the config file $nodesConfigFile"
99
exit 1
1010
fi
1111

1212
# Generate a random namespace name
13-
namespace="openshift-node-joiner-$(cat /dev/urandom | tr -dc 'a-z' | head -c 10)"
13+
namespace="openshift-node-joiner-$(tr -dc '[:lower:]' < /dev/urandom | head -c 10)"
1414

1515
# Extract the installer image pullspec and release version.
1616
nodeJoinerPullspec=$(oc get is installer -n openshift -o=jsonpath='{.spec.tags[0].from.name}')
@@ -67,7 +67,7 @@ EOF
6767
echo "$staticResources" | oc apply -f -
6868

6969
# Generate a configMap to store the user configuration
70-
oc create configmap nodes-config --from-file=nodes-config.yaml=${nodesConfigFile} -n ${namespace} -o yaml --dry-run=client | oc apply -f -
70+
oc create configmap nodes-config --from-file=nodes-config.yaml="${nodesConfigFile}" -n "${namespace}" -o yaml --dry-run=client | oc apply -f -
7171

7272
# Runt the node-joiner pod to generate the ISO
7373
nodeJoinerPod=$(cat <<EOF
@@ -109,20 +109,20 @@ EOF
109109
echo "$nodeJoinerPod" | oc apply -f -
110110

111111
while true; do
112-
if oc exec node-joiner -n ${namespace} -- test -e /assets/exit_code >/dev/null 2>&1; then
112+
if oc exec node-joiner -n "${namespace}" -- test -e /assets/exit_code >/dev/null 2>&1; then
113113
break
114114
else
115115
echo "Waiting for node-joiner pod to complete..."
116116
sleep 10s
117117
fi
118118
done
119119

120-
res=$(oc exec node-joiner -n ${namespace} -- cat /assets/exit_code)
120+
res=$(oc exec node-joiner -n "${namespace}" -- cat /assets/exit_code)
121121
if [ "$res" = 0 ]; then
122122
echo "node-joiner successfully completed, extracting ISO image..."
123-
oc cp -n ${namespace} node-joiner:/assets/agent-addnodes.x86_64.iso agent-addnodes.x86_64.iso
123+
oc cp -n "${namespace}" node-joiner:/assets/agent-addnodes.x86_64.iso agent-addnodes.x86_64.iso
124124
else
125-
oc logs node-joiner -n ${namespace}
125+
oc logs node-joiner -n "${namespace}"
126126
echo "node-joiner failed"
127127
fi
128128

pkg/nodejoiner/addnodes.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package nodejoiner
22

33
import (
4+
"context"
45
"os"
56
"path/filepath"
67

@@ -28,7 +29,7 @@ func NewAddNodesCommand(directory string, kubeConfig string) error {
2829
}
2930

3031
fetcher := store.NewAssetsFetcher(directory)
31-
err = fetcher.FetchAndPersist([]asset.WritableAsset{
32+
err = fetcher.FetchAndPersist(context.Background(), []asset.WritableAsset{
3233
&workflow.AgentWorkflowAddNodes{},
3334
&image.AgentImage{},
3435
})

0 commit comments

Comments
 (0)