Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
Local Path Provisioner
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mirror
Local Path Provisioner
Commits
faf52578
Commit
faf52578
authored
2 months ago
by
sceneryback
Committed by
Derek Su
2 months ago
Browse files
Options
Downloads
Patches
Plain Diff
use existing kubeClient when saving helper logs
Signed-off-by:
sceneryback
<
afterbreeze@hotmail.com
>
parent
2158fed6
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
provisioner.go
+3
-13
3 additions, 13 deletions
provisioner.go
with
3 additions
and
13 deletions
provisioner.go
+
3
−
13
View file @
faf52578
...
...
@@ -22,7 +22,6 @@ import (
k8serror
"k8s.io/apimachinery/pkg/api/errors"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
clientset
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
pvController
"sigs.k8s.io/sig-storage-lib-external-provisioner/v10/controller"
)
...
...
@@ -689,7 +688,7 @@ func (p *LocalPathProvisioner) createHelperPod(action ActionType, cmd []string,
defer
func
()
{
// log helper pod logs to the controller
if
err
:=
saveHelperPodLogs
(
pod
);
err
!=
nil
{
if
err
:=
p
.
saveHelperPodLogs
(
pod
);
err
!=
nil
{
logrus
.
Error
(
err
.
Error
())
}
e
:=
p
.
kubeClient
.
CoreV1
()
.
Pods
(
p
.
namespace
)
.
Delete
(
context
.
TODO
(),
helperPod
.
Name
,
metav1
.
DeleteOptions
{})
...
...
@@ -859,7 +858,7 @@ func createPersistentVolumeSource(volumeType string, path string) (pvs v1.Persis
// saveHelperPodLogs takes what is in stdout/stderr from the helper
// pod and logs it to the provisioner's logs. Returns an error if we
// can't retrieve the helper pod logs.
func
saveHelperPodLogs
(
pod
*
v1
.
Pod
)
(
err
error
)
{
func
(
p
*
LocalPathProvisioner
)
saveHelperPodLogs
(
pod
*
v1
.
Pod
)
(
err
error
)
{
defer
func
()
{
err
=
errors
.
Wrapf
(
err
,
"failed to save %s logs"
,
pod
.
Name
)
}()
...
...
@@ -868,16 +867,7 @@ func saveHelperPodLogs(pod *v1.Pod) (err error) {
podLogOpts
:=
v1
.
PodLogOptions
{
Container
:
"helper-pod"
,
}
config
,
err
:=
rest
.
InClusterConfig
()
if
err
!=
nil
{
return
fmt
.
Errorf
(
"unable to retrieve in cluster config: %s"
,
err
.
Error
())
}
// creates the clientset
clientset
,
err
:=
clientset
.
NewForConfig
(
config
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"unable to get access to k8s: %s"
,
err
.
Error
())
}
req
:=
clientset
.
CoreV1
()
.
Pods
(
pod
.
Namespace
)
.
GetLogs
(
pod
.
Name
,
&
podLogOpts
)
req
:=
p
.
kubeClient
.
CoreV1
()
.
Pods
(
pod
.
Namespace
)
.
GetLogs
(
pod
.
Name
,
&
podLogOpts
)
podLogs
,
err
:=
req
.
Stream
(
context
.
TODO
())
if
err
!=
nil
{
return
fmt
.
Errorf
(
"error in opening stream: %s"
,
err
.
Error
())
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment