Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
c3eece60
Commit
c3eece60
authored
Nov 12, 2024
by
Derek Nola
Committed by
Brad Davidson
Nov 12, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix GenKubeConfigFile, move from "cat" command to "scp"
Remove CI fog warnings from RunCmdOnNode output Signed-off-by:
Derek Nola
<
derek.nola@suse.com
>
parent
62caa4a8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
6 deletions
+16
-6
testutils.go
tests/e2e/testutils.go
+16
-6
No files found.
tests/e2e/testutils.go
View file @
c3eece60
...
@@ -314,22 +314,29 @@ func FetchNodeExternalIP(nodename string) (string, error) {
...
@@ -314,22 +314,29 @@ func FetchNodeExternalIP(nodename string) (string, error) {
}
}
func
GenKubeConfigFile
(
serverName
string
)
(
string
,
error
)
{
func
GenKubeConfigFile
(
serverName
string
)
(
string
,
error
)
{
cmd
:=
fmt
.
Sprintf
(
"vagrant ssh %s -c
\"
sudo cat /etc/rancher/k3s/k3s.yaml
\"
"
,
serverName
)
kubeConfigFile
:=
fmt
.
Sprintf
(
"kubeconfig-%s"
,
serverName
)
kubeConfig
,
err
:=
RunCommand
(
cmd
)
cmd
:=
fmt
.
Sprintf
(
"vagrant scp %s:/etc/rancher/k3s/k3s.yaml ./%s"
,
serverName
,
kubeConfigFile
)
_
,
err
:=
RunCommand
(
cmd
)
if
err
!=
nil
{
return
""
,
err
}
kubeConfig
,
err
:=
os
.
ReadFile
(
kubeConfigFile
)
if
err
!=
nil
{
if
err
!=
nil
{
return
""
,
err
return
""
,
err
}
}
re
:=
regexp
.
MustCompile
(
`(?m)==> vagrant:.*\n`
)
re
:=
regexp
.
MustCompile
(
`(?m)==> vagrant:.*\n`
)
kubeConfig
=
re
.
ReplaceAllString
(
kubeConfig
,
""
)
modifiedKubeConfig
:=
re
.
ReplaceAllString
(
string
(
kubeConfig
)
,
""
)
nodeIP
,
err
:=
FetchNodeExternalIP
(
serverName
)
nodeIP
,
err
:=
FetchNodeExternalIP
(
serverName
)
if
err
!=
nil
{
if
err
!=
nil
{
return
""
,
err
return
""
,
err
}
}
kubeConfig
=
strings
.
Replace
(
kubeConfig
,
"127.0.0.1"
,
nodeIP
,
1
)
modifiedKubeConfig
=
strings
.
Replace
(
modifiedKubeConfig
,
"127.0.0.1"
,
nodeIP
,
1
)
kubeConfigFile
:=
fmt
.
Sprintf
(
"kubeconfig-%s"
,
serverName
)
if
err
:=
os
.
WriteFile
(
kubeConfigFile
,
[]
byte
(
modifiedKubeConfig
),
0644
);
err
!=
nil
{
if
err
:=
os
.
WriteFile
(
kubeConfigFile
,
[]
byte
(
kubeConfig
),
0644
);
err
!=
nil
{
return
""
,
err
return
""
,
err
}
}
if
err
:=
os
.
Setenv
(
"E2E_KUBECONFIG"
,
kubeConfigFile
);
err
!=
nil
{
if
err
:=
os
.
Setenv
(
"E2E_KUBECONFIG"
,
kubeConfigFile
);
err
!=
nil
{
return
""
,
err
return
""
,
err
}
}
...
@@ -495,6 +502,9 @@ func RunCmdOnNode(cmd string, nodename string) (string, error) {
...
@@ -495,6 +502,9 @@ func RunCmdOnNode(cmd string, nodename string) (string, error) {
}
}
runcmd
:=
"vagrant ssh "
+
nodename
+
" -c
\"
sudo "
+
injectEnv
+
cmd
+
"
\"
"
runcmd
:=
"vagrant ssh "
+
nodename
+
" -c
\"
sudo "
+
injectEnv
+
cmd
+
"
\"
"
out
,
err
:=
RunCommand
(
runcmd
)
out
,
err
:=
RunCommand
(
runcmd
)
// On GHA CI we see warnings about "[fog][WARNING] Unrecognized arguments: libvirt_ip_command"
// these are added to the command output and need to be removed
out
=
strings
.
ReplaceAll
(
out
,
"[fog][WARNING] Unrecognized arguments: libvirt_ip_command
\n
"
,
""
)
if
err
!=
nil
{
if
err
!=
nil
{
return
out
,
fmt
.
Errorf
(
"failed to run command: %s on node %s: %s, %v"
,
cmd
,
nodename
,
out
,
err
)
return
out
,
fmt
.
Errorf
(
"failed to run command: %s on node %s: %s, %v"
,
cmd
,
nodename
,
out
,
err
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment