Skip to content

Commit ae2fc69

Browse files
o/snapstate: set userID from snapst and from opts as fallback for component installation (#17047)
1 parent 97032c9 commit ae2fc69

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

overlord/snapstate/component.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,11 @@ func componentSetupsForInstall(ctx context.Context, st *state.State, names []str
188188
return nil, err
189189
}
190190

191-
// TODO:COMPS: figure out which user to use here
192-
user, err := userFromUserID(st, opts.UserID)
191+
userID, err := userIDForSnap(st, &snapst, opts.UserID)
192+
if err != nil {
193+
return nil, err
194+
}
195+
user, err := userFromUserID(st, userID)
193196
if err != nil {
194197
return nil, err
195198
}

overlord/snapstate/component_install_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,6 +1085,14 @@ func (s *snapmgrTestSuite) testInstallComponents(c *C, opts testInstallComponent
10851085
}
10861086
c.Assert(snapsupSetupProfiles.UserID, Equals, expectedUserID)
10871087

1088+
s.fakeBackend.ops.MustFindOp(c, "storesvc-snap-action")
1089+
for _, op := range s.fakeBackend.ops {
1090+
if op.op == "storesvc-snap-action" || op.op == "storesvc-snap-action:action" {
1091+
c.Assert(op.userID, Equals, expectedUserID,
1092+
Commentf("expected userID %d in op %q but got %d", expectedUserID, op.op, op.userID))
1093+
}
1094+
}
1095+
10881096
prepareKmodComps := setupTs.Tasks()[1]
10891097
c.Assert(prepareKmodComps.Kind(), Equals, "prepare-kernel-modules-components")
10901098

0 commit comments

Comments
 (0)