mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 07:20:13 +00:00
Merge pull request #5954 from pmorie/secret-log
Add positive logging for secret volume plugin
This commit is contained in:
commit
b77b529e16
@ -114,10 +114,18 @@ func (sv *secretVolume) SetUpAt(dir string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("Couldn't get secret %v/%v", sv.podRef.Namespace, sv.secretName)
|
glog.Errorf("Couldn't get secret %v/%v", sv.podRef.Namespace, sv.secretName)
|
||||||
return err
|
return err
|
||||||
|
} else {
|
||||||
|
totalBytes := totalSecretBytes(secret)
|
||||||
|
glog.V(3).Infof("Received secret %v/%v containing (%v) pieces of data, %v total bytes",
|
||||||
|
sv.podRef.Namespace,
|
||||||
|
sv.secretName,
|
||||||
|
len(secret.Data),
|
||||||
|
totalBytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
for name, data := range secret.Data {
|
for name, data := range secret.Data {
|
||||||
hostFilePath := path.Join(dir, name)
|
hostFilePath := path.Join(dir, name)
|
||||||
|
glog.V(3).Infof("Writing secret data %v/%v/%v (%v bytes) to host file %v", sv.podRef.Namespace, sv.secretName, len(data), hostFilePath)
|
||||||
err := ioutil.WriteFile(hostFilePath, data, 0777)
|
err := ioutil.WriteFile(hostFilePath, data, 0777)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("Error writing secret data to host path: %v, %v", hostFilePath, err)
|
glog.Errorf("Error writing secret data to host path: %v, %v", hostFilePath, err)
|
||||||
@ -128,6 +136,15 @@ func (sv *secretVolume) SetUpAt(dir string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func totalSecretBytes(secret *api.Secret) int {
|
||||||
|
totalSize := 0
|
||||||
|
for _, bytes := range secret.Data {
|
||||||
|
totalSize += len(bytes)
|
||||||
|
}
|
||||||
|
|
||||||
|
return totalSize
|
||||||
|
}
|
||||||
|
|
||||||
func (sv *secretVolume) GetPath() string {
|
func (sv *secretVolume) GetPath() string {
|
||||||
return sv.plugin.host.GetPodVolumeDir(sv.podRef.UID, util.EscapeQualifiedNameForDisk(secretPluginName), sv.volName)
|
return sv.plugin.host.GetPodVolumeDir(sv.podRef.UID, util.EscapeQualifiedNameForDisk(secretPluginName), sv.volName)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user