Merge pull request #5954 from pmorie/secret-log

Add positive logging for secret volume plugin
This commit is contained in:
Eric Tune 2015-03-26 10:56:16 -07:00
commit b77b529e16

View File

@ -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)
}