Skip to content

Commit bb913f4

Browse files
committed
Reduce load on Keystone by not loading service catalog on authentication; safely close Keystone connections.
1 parent 7d1b476 commit bb913f4

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

pkg/api/keystone/keystone_requests.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,15 +167,18 @@ func AuthenticateUnscoped(data *Auth_data) error {
167167
}
168168

169169
func authenticate(data *Auth_data, b []byte) error {
170-
request, err := http.NewRequest("POST", data.Server+"/v3/auth/tokens", bytes.NewBuffer(b))
170+
request, err := http.NewRequest("POST", data.Server+"/v3/auth/tokens?nocatalog", bytes.NewBuffer(b))
171171
if err != nil {
172172
return err
173173
}
174174

175175
resp, err := GetHttpClient().Do(request)
176176
if err != nil {
177177
return err
178-
} else if resp.StatusCode != 201 {
178+
}
179+
defer resp.Body.Close()
180+
181+
if resp.StatusCode != 201 {
179182
return errors.New("Keystone authentication failed: " + resp.Status)
180183
}
181184

@@ -211,7 +214,10 @@ func GetProjects(data *Projects_data) error {
211214
resp, err := GetHttpClient().Do(request)
212215
if err != nil {
213216
return err
214-
} else if resp.StatusCode != 200 {
217+
}
218+
defer resp.Body.Close()
219+
220+
if resp.StatusCode != 200 {
215221
return errors.New("Keystone project-list failed: " + resp.Status)
216222
}
217223

0 commit comments

Comments
 (0)