@@ -61,7 +61,7 @@ import (
61
61
"syscall"
62
62
"unsafe"
63
63
64
- "github.com/sirupsen/logrus "
64
+ "code.cloudfoundry.org/lager "
65
65
)
66
66
67
67
// Quota limit params - currently we only control blocks hard limit
@@ -73,6 +73,7 @@ type Quota struct {
73
73
// Control - Context to be used by storage driver (e.g. overlay)
74
74
// who wants to apply project quotas to container dirs
75
75
type Control struct {
76
+ logger lager.Logger
76
77
backingFsBlockDev string
77
78
nextProjectID uint32
78
79
quotas map [string ]uint32
@@ -100,7 +101,8 @@ type Control struct {
100
101
// on it. If that works, continue to scan existing containers to map allocated
101
102
// project ids.
102
103
//
103
- func NewControl (basePath string ) (* Control , error ) {
104
+ func NewControl (logger lager.Logger , basePath string ) (* Control , error ) {
105
+ logger = logger .Session ("projectquota" )
104
106
//
105
107
// Get project id of parent dir as minimal id to be used by driver
106
108
//
@@ -130,6 +132,7 @@ func NewControl(basePath string) (*Control, error) {
130
132
}
131
133
132
134
q := Control {
135
+ logger : logger ,
133
136
backingFsBlockDev : backingFsBlockDev ,
134
137
nextProjectID : minProjectID + 1 ,
135
138
quotas : make (map [string ]uint32 ),
@@ -143,7 +146,7 @@ func NewControl(basePath string) (*Control, error) {
143
146
return nil , err
144
147
}
145
148
146
- logrus . Debugf ( "NewControl(%s): nextProjectID = %d " , basePath , q .nextProjectID )
149
+ q . logger . Debug ( "quota-control-created " , lager. Data { " basePath" : basePath , "projectID" : q .nextProjectID } )
147
150
return & q , nil
148
151
}
149
152
@@ -169,7 +172,7 @@ func (q *Control) SetQuota(nextProjectID uint32, targetPath string, quota Quota)
169
172
//
170
173
// set the quota limit for the container's project id
171
174
//
172
- logrus . Debugf ( "SetQuota(%s, %d): projectID=%d" , targetPath , quota .Size , projectID )
175
+ q . logger . Debug ( "set-quota" , lager. Data { "targetPath" : targetPath , " quota" : quota .Size , " projectID" : projectID } )
173
176
return setProjectQuota (q .backingFsBlockDev , projectID , quota )
174
177
}
175
178
@@ -228,7 +231,7 @@ func (q *Control) GetQuota(targetPath string, quota *Quota) error {
228
231
}
229
232
230
233
// GetProjectID - get the project id of path on xfs
231
- func GetProjectID (targetPath string ) (uint32 , error ) {
234
+ func GetProjectID (targetPath string ) (projId uint32 , err error ) {
232
235
dir , err := openDir (targetPath )
233
236
if err != nil {
234
237
return 0 , err
0 commit comments