Skip to content

Commit 052eeb0

Browse files
committed
chore: decode weka creds
1 parent f78ace6 commit 052eeb0

1 file changed

Lines changed: 22 additions & 12 deletions

File tree

join/join.go

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ func (j *JoinScriptGenerator) GetJoinScript(ctx context.Context) string {
4545
common.ShuffleSlice(ips)
4646

4747
bashScriptTemplate := `
48-
export WEKA_USERNAME="%s"
49-
export WEKA_PASSWORD="%s"
50-
export WEKA_RUN_CREDS="-e WEKA_USERNAME=$WEKA_USERNAME -e WEKA_PASSWORD=$WEKA_PASSWORD"
5148
IPS=(%s)
5249
HASHED_IP=$(%s)
5350
COMPUTE=%d
@@ -139,13 +136,14 @@ func (j *JoinScriptGenerator) GetJoinScript(ctx context.Context) string {
139136
compute := j.Params.InstanceParams.Compute
140137
mem := j.Params.InstanceParams.ComputeMemory
141138

139+
setWekaCreds := j.setWekaCredentials()
142140
isReady := j.getIsReadyScript()
143141
addDrives := j.getAddDrivesScript()
144142

145143
bashScriptTemplate = j.ScriptBase + dedent.Dedent(bashScriptTemplate)
146-
bashScriptTemplate += isReady + addDrives
144+
bashScriptTemplate += setWekaCreds + isReady + addDrives
147145
bashScript := fmt.Sprintf(
148-
bashScriptTemplate, j.Params.WekaUsername, j.Params.WekaPassword, strings.Join(ips, " "), j.FailureDomainCmd,
146+
bashScriptTemplate, strings.Join(ips, " "), j.FailureDomainCmd,
149147
compute, frontend, drive, mem, j.Params.InstallDpdk, gateways, j.Params.ProxyUrl, reportFunc,
150148
joinFinalizationFunc, getCoreIdsFunc, getNetStrForDpdkFunc, j.DeviceNameCmd, bash_functions.GetWekaPartitionScript(),
151149
)
@@ -162,10 +160,6 @@ func (j *JoinScriptGenerator) GetExistingContainersJoinScript(ctx context.Contex
162160

163161
bashScriptTemplate := `
164162
set -ex
165-
166-
export WEKA_USERNAME="%s"
167-
export WEKA_PASSWORD="%s"
168-
export WEKA_RUN_CREDS="-e WEKA_USERNAME=$WEKA_USERNAME -e WEKA_PASSWORD=$WEKA_PASSWORD"
169163
host_ips="%s"
170164
171165
# report function definition
@@ -203,18 +197,32 @@ func (j *JoinScriptGenerator) GetExistingContainersJoinScript(ctx context.Contex
203197
fi
204198
`
205199

200+
setWekaCreds := j.setWekaCredentials()
206201
isReady := j.getIsReadyScript()
207202
addDrives := j.getAddDrivesScript()
208203

209204
bashScriptTemplate = j.ScriptBase + dedent.Dedent(bashScriptTemplate)
210-
bashScriptTemplate += isReady + addDrives
205+
bashScriptTemplate += setWekaCreds + isReady + addDrives
211206
bashScript := fmt.Sprintf(
212-
bashScriptTemplate, j.Params.WekaUsername, j.Params.WekaPassword, strings.Join(ips, " "), reportFunc,
207+
bashScriptTemplate, strings.Join(ips, " "), reportFunc,
213208
joinFinalizationFunc, statusFunc,
214209
)
215210
return dedent.Dedent(bashScript)
216211
}
217212

213+
func (j *JoinScriptGenerator) setWekaCredentials() string {
214+
s := `
215+
set +x
216+
export WEKA_USERNAME=$(echo "%s" | base64 --decode)
217+
export WEKA_PASSWORD=$(echo "%s" | base64 --decode)
218+
export WEKA_RUN_CREDS="-e WEKA_USERNAME=$WEKA_USERNAME -e WEKA_PASSWORD=$WEKA_PASSWORD"
219+
set -x
220+
`
221+
222+
s = dedent.Dedent(s)
223+
return fmt.Sprintf(s, j.Params.WekaUsername, j.Params.WekaPassword)
224+
}
225+
218226
func (j *JoinScriptGenerator) getIsReadyScript() string {
219227
s := `
220228
while ! weka debug manhole -s 0 operational_status | grep '"is_ready": true' ; do
@@ -230,12 +238,14 @@ func (j *JoinScriptGenerator) getAddDrivesScript() string {
230238
s := `
231239
compute_name=$(%s)
232240
233-
host_id=$(weka local run --container compute0 $WEKA_RUN_CREDS manhole getServerInfo | grep hostIdValue: | awk '{print $2}')
234241
mkdir -p /opt/weka/tmp
235242
236243
# write down find_drives script (another string input for this template)
237244
cat >/opt/weka/tmp/find_drives.py <<EOL%sEOL
245+
set +x
246+
host_id=$(weka local run --container compute0 $WEKA_RUN_CREDS manhole getServerInfo | grep hostIdValue: | awk '{print $2}')
238247
devices=$(weka local run --container compute0 $WEKA_RUN_CREDS bash -ce 'wapi machine-query-info --info-types=DISKS -J | python3 /opt/weka/tmp/find_drives.py')
248+
set -x
239249
for device in $devices; do
240250
weka local exec --container drives0 /weka/tools/weka_sign_drive $device
241251
done

0 commit comments

Comments
 (0)