opencomputeproject / HWMgmt-DeviceMgr-DeviceManager

Device Manager collects device data and notifications from each device, and make the data available on a predetermined output bus for consumers.
Apache License 2.0
23 stars 12 forks source link

Deleting session returns error, after receiving status code 204 #17

Closed ehaligow closed 1 year ago

ehaligow commented 2 years ago

Deleting device session returns error, after receiving status code 204 from BMC Simulator. intel@ubuntu:functional_test$ ./dm logindevice 192.168.40.247:8888:admin:admin:1 Failed to delete login session id f4b31e66-add7-4fd7-a364-7b5e5de84d64, status code 204

According to code, receiving status codes other than 200 returns error.

JasonscHuang commented 2 years ago

I do not see that error. Could you provide more information? It is probably the login session was deleted by manual before you login that device but DM does not know it.

ehaligow commented 2 years ago

According to Redfish Specification (section 7.5.2 Modification success responses) for deleting operation (in this case deleting session), not only 200 status code should be accepted, but also 202 and 204. DeviceMgr receives from BMC Simulator status code 204, but DeviceMgr accepts only 200 (as in the following code from accountService.go):

func (s *Server) deleteDeviceSession(deviceIPAddress, authStr, userName string, userAuthData userAuth) (statusCode int, err error) {
    id, status, statusCode, err := s.getUserLoginID(deviceIPAddress, authStr, userName)
    if err == nil && status == true {
        _, statusCode, err = deleteHTTPDataByRfAPI(deviceIPAddress, RfSessionServiceSessions, userAuthData, id)
        if statusCode != http.StatusOK {
            logrus.Errorf(ErrDeleteLoginFailed.String(id, strconv.Itoa(statusCode)))
            return statusCode, errors.New(ErrDeleteLoginFailed.String(id, strconv.Itoa(statusCode)))
        }
    }
    return statusCode, err
}
JasonscHuang commented 2 years ago

@ehaligow Yes, you could add those conditions of the HTTP status code (202 and 204) to this function.