WIP: recheck a take's filesystem, follow only the module's branch, count users in an access change, hold the identity until its data is taken (hq ADR 0325 review)
This commit is contained in:
@@ -970,6 +970,17 @@ func (i *Inventory) judgeSettings(ctx context.Context, nodeName, module string,
|
||||
if aerr != nil {
|
||||
return aerr
|
||||
}
|
||||
if !has {
|
||||
follows, ferr := i.followsABranch(ctx, module)
|
||||
if ferr != nil {
|
||||
return ferr
|
||||
}
|
||||
if !follows {
|
||||
return fmt.Errorf("refused: %s on %s cannot compose with the layer %q — %w; and %s follows no branch "+
|
||||
"(it was registered by hand), so no build of it can be judged ahead of what is registered", module,
|
||||
where, from, err, module)
|
||||
}
|
||||
}
|
||||
if !has || catalogue.JudgeSettings(ahead, layers, adopted) != nil || catalogue.ComposesWith(m, layers, adopted) != nil {
|
||||
return fmt.Errorf("refused: %s on %s cannot compose with the layer %q — %w; nor does the newest build of "+
|
||||
"%s on the branch it follows declare it", module, where, from, err, module)
|
||||
@@ -990,15 +1001,26 @@ func (i *Inventory) judgeSettings(ctx context.Context, nodeName, module string,
|
||||
return nil
|
||||
}
|
||||
|
||||
// followsABranch says a module's record names the branch it follows.
|
||||
func (i *Inventory) followsABranch(ctx context.Context, module string) (bool, error) {
|
||||
var ref string
|
||||
err := i.store.Pool().QueryRow(ctx, `select coalesce(ref, '') from module where name = $1`, module).Scan(&ref)
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return false, nil
|
||||
}
|
||||
return ref != "", err
|
||||
}
|
||||
|
||||
// NewestManifestOnBranch is the manifest of a module's newest successful build on the branch its record follows
|
||||
// (novox/hq issue 575): what the delivery under way brings, before it registers — or the registered one's own, when
|
||||
// nothing newer was built. False when no build of the module with a manifest is kept.
|
||||
// nothing newer was built. Only a build of that very branch: never one of another branch or of none. False when no
|
||||
// such build is kept, and for a module whose record follows no branch (registered by hand).
|
||||
func (i *Inventory) NewestManifestOnBranch(ctx context.Context, module string) (catalogue.Manifest, bool, error) {
|
||||
var raw []byte
|
||||
err := i.store.Pool().QueryRow(ctx,
|
||||
`select b.manifest from build b join module m on m.name = b.module
|
||||
where b.module = $1 and b.failed = '' and b.manifest is not null and b.manifest::text <> 'null'
|
||||
and (coalesce(m.ref, '') = '' or b.ref = '' or b.ref = m.ref)
|
||||
and coalesce(m.ref, '') <> '' and b.ref = m.ref
|
||||
order by b.at desc limit 1`, module).Scan(&raw)
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return catalogue.Manifest{}, false, nil
|
||||
|
||||
Reference in New Issue
Block a user