Panic deserializing charm container uid/gid during model migration
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 2
- Forks
- 28
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 1
Description
Filed by @canonical/solutions-qa. Root cause identified with AI assistance.
Description
Model migration panics whenever the migrating model contains a charm with explicit uid/gid on a container. The migration-master worker crashes on every restart until the migration times out.
Evidence
Log (source controller, exec 731461):
"migration-master" manifold worker returned unexpected error:
panic resulted in: interface conversion: interface {} is int64, not *int64
Fires 122ms after minion units report QUIESCE, during prechecks() → ModelInfo() → description.Deserialize(). Repeats with exponential backoff for the full 15-minute timeout.
Trigger — mysql-k8s rev 426 container metadata (from MongoDB state dump):
containers:
mysql:
uid: 584788
gid: 584788
resource: mysql-image
Older mysql-k8s revisions without uid/gid do not trigger the panic.
Root cause
In charmmetadata.go, importCharmMetadataContainer asserts *int64 but schema.Int() returns int64:
var uid *int
if valid["uid"] != nil {
uid = int64ToIntPtr(valid["uid"].(*int64)) // panics: value is int64, not *int64
}
var gid *int
if valid["gid"] != nil {
uid = int64ToIntPtr(valid["gid"].(*int64)) // same panic; also assigns to uid not gid
}
There are two bugs: the wrong type assertion (.(*int64) → .(int64)), and a copy-paste error where gid is assigned to uid.
Suggested fix
var uid *int
if valid["uid"] != nil {
v := int(valid["uid"].(int64))
uid = &v
}
var gid *int
if valid["gid"] != nil {
v := int(valid["gid"].(int64))
gid = &v
}
Note: int64ToIntPtr becomes dead code after this change.
Juju version
3.6.25 (using description@v11.0.1; bug also present in v10.0.0)
Upstream tracking: canonical/charm-integration-testing#734
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in charmmetadata.go at importCharmMetadataContainer, and inspect schema.Int() and int64ToIntPtr before changing anything. Run the relevant package's existing Go tests; done means explicit container uid and gid deserialize without a panic and remain associated with their respective fields.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 76/100