state: Generalise error handling when splitting logs collection #7588

Merged
merged 1 commit into from Jul 3, 2017

Conversation

Projects
None yet
4 participants
Contributor

mjs commented Jul 3, 2017

Description of change

The error checks in SplitLogCollections didn't work on MongoDB 2.4 as
older MongoDB versions only return an error string without the error
code.

mgo's IsDup helper is now used for insert error handling and "ns not
found" is now checked by code or string.

Fixes https://bugs.launchpad.net/juju/+bug/1701999

QA steps

Related unit tests were failing on MongoDB 2.4 before and pass now.

Documentation changes

N.A.

Bug reference

https://bugs.launchpad.net/juju/+bug/1701999

state: Generalise error handling when splitting logs collection
The error checks in SplitLogCollections didn't work on MongoDB 2.4 as
older MongoDB versions only return an error string without the error
code.

mgo's IsDup helper is now used for insert error handling and "ns not
found" is now checked by code or string.

Fixes https://bugs.launchpad.net/juju/+bug/1701999

Good spotting.

@mjs mjs changed the base branch from develop to 2.2 Jul 3, 2017

Contributor

mjs commented Jul 3, 2017

$$merge$$

Contributor

jujubot commented Jul 3, 2017

Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju

@jujubot jujubot merged commit 8b26e24 into juju:2.2 Jul 3, 2017

1 check passed

github-check-merge-juju Ran tests against PR. Use !!.*!! to request another build. IE, !!build!!, !!retry!!
Details

@mjs mjs deleted the mjs:log-split-upgrade-err-handling branch Jul 3, 2017

+func isMgoNamespaceNotFound(err error) bool {
+ // Check for &mgo.QueryError{Code:26, Message:"ns not found"}
+ if qerr, ok := err.(*mgo.QueryError); ok {
+ if qerr.Code == 26 {
@jameinel

jameinel Jul 3, 2017

Owner

Off-hand, shouldn't we have a a name for the error code instead of just a number mgo.NamespaceNotFoundCode or somesuch?

@mjs

mjs Jul 3, 2017

Contributor

No such constant exists in the mgo package. Is that what you mean?

Owner

jameinel commented Jul 3, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment