mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 15:05:27 +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 {
|
||||
glog.Errorf("Couldn't get secret %v/%v", sv.podRef.Namespace, sv.secretName)
|
||||
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 {
|
||||
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)
|
||||
if err != nil {
|
||||
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
|
||||
}
|
||||
|
||||
func totalSecretBytes(secret *api.Secret) int {
|
||||
totalSize := 0
|
||||
for _, bytes := range secret.Data {
|
||||
totalSize += len(bytes)
|
||||
}
|
||||
|
||||
return totalSize
|
||||
}
|
||||
|
||||
func (sv *secretVolume) GetPath() string {
|
||||
return sv.plugin.host.GetPodVolumeDir(sv.podRef.UID, util.EscapeQualifiedNameForDisk(secretPluginName), sv.volName)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user