indexer: say every end of a package-published heard
A package-published of mesh-delivery-pipeline 0.1.6 left the catalog's versions empty and the indexer's journal silent: the hearer said nothing when it heard one, waited for the module's other artifacts, took it as another branch's, found the version released already or released it. Each of those ends is now said, naming the artifact, the version, the branch and source, the artifacts still awaited and the fingerprint of the entry compared. Builds: design 47 G §349, §371, A-420
This commit is contained in:
@@ -107,13 +107,24 @@ func (ix *Indexer) HearPackagePublished(ctx context.Context, p meshbuilds.Packag
|
||||
if _, ok := versionParts(p.Version); !ok {
|
||||
return fmt.Errorf("the package-published of %s names the version %q, which is no MAJOR.MINOR.PATCH", p.Artifact, p.Version)
|
||||
}
|
||||
ix.logf("versions: heard the package-published of %s at %s (digest %s, branch %q, source %d)", p.Artifact, p.Version, p.Digest, p.Branch, p.Source)
|
||||
if ix.Registry != nil {
|
||||
if r, found, err := ix.Registry.Registration(ctx, p.Module); err == nil && found && len(r.Branches) > 0 && r.Branches[0] != p.Branch {
|
||||
r, found, err := ix.Registry.Registration(ctx, p.Module)
|
||||
switch {
|
||||
case err != nil:
|
||||
ix.logf("versions: the registration of %s cannot be read, so %s at %s is taken as the first watched branch's: %v", p.Module, p.Artifact, p.Version, err)
|
||||
case !found:
|
||||
ix.logf("versions: %s has no registration, so %s at %s is taken as the first watched branch's", p.Module, p.Artifact, p.Version)
|
||||
case len(r.Branches) > 0 && r.Branches[0] != p.Branch:
|
||||
ix.logf("versions: %s at %s is of the branch %q, not the first watched branch %q: it releases no version, its edges are kept in build-edges", p.Artifact, p.Version, p.Branch, r.Branches[0])
|
||||
return ix.hearBranchBuild(ctx, p) // releases no version; its edges are kept in build-edges (A-83)
|
||||
}
|
||||
}
|
||||
if _, _, found, err := ix.Versions.Get(ctx, meshcatalog.VersionsByModuleVersionKey(p.Module, p.Version)); err != nil || found {
|
||||
return err // released already: heard again
|
||||
if _, _, found, err := ix.Versions.Get(ctx, meshcatalog.VersionsByModuleVersionKey(p.Module, p.Version)); err != nil {
|
||||
return err
|
||||
} else if found {
|
||||
ix.logf("versions: %s %s is released already, so the package-published of %s is heard again and changes nothing", p.Module, p.Version, p.Artifact)
|
||||
return nil
|
||||
}
|
||||
entry, err := ix.entryOf(ctx, p.Module)
|
||||
if err != nil {
|
||||
@@ -148,11 +159,16 @@ func (ix *Indexer) HearPackagePublished(ctx context.Context, p meshbuilds.Packag
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var missing []string
|
||||
for _, ref := range want {
|
||||
if _, ok := have.Artifacts[ref]; !ok {
|
||||
return nil
|
||||
missing = append(missing, ref)
|
||||
}
|
||||
}
|
||||
if len(missing) > 0 {
|
||||
ix.logf("versions: %s %s waits for the package-published of %s, which the newest trunk entry of it names (fingerprint %s); heard so far: %d", p.Module, p.Version, strings.Join(missing, ", "), entry.Fp, len(have.Artifacts))
|
||||
return nil
|
||||
}
|
||||
return ix.releaseVersion(ctx, p, key, entry, have)
|
||||
}
|
||||
|
||||
@@ -203,11 +219,17 @@ func (ix *Indexer) releaseVersion(ctx context.Context, p meshbuilds.PackagePubli
|
||||
if err := ix.Versions.Create(ctx, key, data); err != nil && !errors.Is(err, ErrConflict) {
|
||||
return err
|
||||
}
|
||||
if late {
|
||||
ix.logf("versions: %s %s is released late: %s is released already, so it is recorded and no version-released is said", p.Module, p.Version, kept[0].Version)
|
||||
} else if ix.SayVersionReleased == nil {
|
||||
ix.logf("versions: %s %s is released, and no version-released is said here", p.Module, p.Version)
|
||||
}
|
||||
if !late && ix.SayVersionReleased != nil {
|
||||
ev := meshcatalog.VersionReleasedEvent{V: int64(keys.Version), Module: v.Module, Version: v.Version, Artifacts: v.Artifacts, Source: v.Source, At: &at}
|
||||
if err := ix.SayVersionReleased(ctx, ev, meshcatalog.EventVersionReleased+"-"+key); err != nil {
|
||||
return fmt.Errorf("version-released of %s %s is not said: %w", p.Module, p.Version, err)
|
||||
}
|
||||
ix.logf("versions: %s %s is released and version-released is said (%d artifacts, source %d)", p.Module, p.Version, len(v.Artifacts), v.Source)
|
||||
}
|
||||
if err := ix.trimVersions(ctx, p.Module); err != nil {
|
||||
ix.logf("versions: %s's oldest versions are not deleted: %v", p.Module, err)
|
||||
|
||||
Reference in New Issue
Block a user