mirror of
https://github.com/empayre/fleet.git
synced 2024-11-06 08:55:24 +00:00
use writer for database reads on TokenUpdate (#11605)
Related to #11604
This commit is contained in:
parent
c1b7953f8c
commit
e635eb19fd
1
changes/11604-use-writer
Normal file
1
changes/11604-use-writer
Normal file
@ -0,0 +1 @@
|
||||
* Fixed a bug that prevented bootstrap packages and the `fleetd` agent from being installed when the server had a database replica configured.
|
@ -922,7 +922,8 @@ func unionSelectDevices(devices []godep.Device) (stmt string, args []interface{}
|
||||
|
||||
func (ds *Datastore) GetNanoMDMEnrollment(ctx context.Context, id string) (*fleet.NanoEnrollment, error) {
|
||||
var nanoEnroll fleet.NanoEnrollment
|
||||
err := sqlx.GetContext(ctx, ds.reader, &nanoEnroll, `SELECT id, device_id, type, enabled, token_update_tally
|
||||
// use writer as it is used just after creation in some cases
|
||||
err := sqlx.GetContext(ctx, ds.writer, &nanoEnroll, `SELECT id, device_id, type, enabled, token_update_tally
|
||||
FROM nano_enrollments WHERE id = ?`, id)
|
||||
if err != nil {
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
|
@ -2803,7 +2803,9 @@ func (ds *Datastore) GetHostMDM(ctx context.Context, hostID uint) (*fleet.HostMD
|
||||
|
||||
func (ds *Datastore) GetHostMDMCheckinInfo(ctx context.Context, hostUUID string) (*fleet.HostMDMCheckinInfo, error) {
|
||||
var hmdm fleet.HostMDMCheckinInfo
|
||||
err := sqlx.GetContext(ctx, ds.reader, &hmdm, `
|
||||
|
||||
// use writer as it is used just after creation in some cases
|
||||
err := sqlx.GetContext(ctx, ds.writer, &hmdm, `
|
||||
SELECT
|
||||
h.hardware_serial,
|
||||
COALESCE(hm.installed_from_dep, false) as installed_from_dep,
|
||||
@ -2820,9 +2822,9 @@ func (ds *Datastore) GetHostMDMCheckinInfo(ctx context.Context, hostUUID string)
|
||||
WHERE h.uuid = ? LIMIT 1`, hostUUID)
|
||||
if err != nil {
|
||||
if err == sql.ErrNoRows {
|
||||
return nil, ctxerr.Wrap(ctx, notFound("MDM").WithMessage(hostUUID))
|
||||
return nil, ctxerr.Wrap(ctx, notFound("Host").WithMessage(fmt.Sprintf("with UUID: %s", hostUUID)))
|
||||
}
|
||||
return nil, ctxerr.Wrapf(ctx, err, "getting data from host_mdm for host_uuid %s", hostUUID)
|
||||
return nil, ctxerr.Wrapf(ctx, err, "host mdm checkin info for host UUID %s", hostUUID)
|
||||
}
|
||||
return &hmdm, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user