C3: mesh-build-node and mesh-build-image say a failure of the network as a transport fault (npm ci, buildah bud, the image seat's mirror) (ADR 0664 §1, issue 1748)
Claude-Session: https://claude.ai/code/session_01JG73KEq4zoDfM9WtYpcQgZ
This commit is contained in:
@@ -353,7 +353,7 @@ func (m *Module) installOwn(ctx context.Context, root, dir, rel string) (install
|
||||
"--no-audit", "--no-fund", "--prefix", scratch, "--userconfig", npmrc)
|
||||
os.Remove(npmrc)
|
||||
if why := ranFailed(r); why != "" {
|
||||
return false, "", fmt.Errorf("installing the packages of %s (%s): %s", rel, strings.Join(names, ", "), why)
|
||||
return false, "", buildstep.Transport(fmt.Errorf("installing the packages of %s (%s): %s", rel, strings.Join(names, ", "), why))
|
||||
}
|
||||
nm := filepath.Join(scratch, "node_modules")
|
||||
if err := removeSDKCopies(nm); err != nil {
|
||||
|
||||
@@ -93,7 +93,7 @@ func (m *Module) installDev(ctx context.Context, root, dir, rel string) error {
|
||||
env := append(m.baseEnv(), "npm_config_cache="+m.npmCache())
|
||||
r := m.Run(ctx, env, "npm", "ci", "--ignore-scripts", "--no-bin-links", "--no-audit", "--no-fund", "--prefix", dir, "--userconfig", npmrc)
|
||||
if why := ranFailed(r); why != "" {
|
||||
return fmt.Errorf("installing the dependencies of the package in %s: %s", rel, why)
|
||||
return buildstep.Transport(fmt.Errorf("installing the dependencies of the package in %s: %s", rel, why))
|
||||
}
|
||||
return writeShims(filepath.Join(dir, "node_modules"), shimDir(root, rel))
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ package main
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"git.novox.be/novox/mesh-catalog/modules/mesh-build-go/buildstep"
|
||||
"io/fs"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -99,8 +100,8 @@ func (t Toolchain) Ensure(ctx context.Context, version string) error {
|
||||
"npm", "ci", "--ignore-scripts", "--no-bin-links", "--no-audit", "--no-fund", "--prefix", dir, "--userconfig", npmrc)
|
||||
os.Remove(npmrc)
|
||||
if ran.Err != "" || ran.Status != 0 {
|
||||
return fmt.Errorf("npm ci --ignore-scripts for the toolchain %s failed (status %d %s): %s",
|
||||
version, ran.Status, ran.Err, tail(ran.Stderr))
|
||||
return buildstep.Transport(fmt.Errorf("npm ci --ignore-scripts for the toolchain %s failed (status %d %s): %s",
|
||||
version, ran.Status, ran.Err, tail(ran.Stderr)))
|
||||
}
|
||||
if err := os.WriteFile(filepath.Join(dir, installedMark), []byte(version+"\n"), 0o600); err != nil {
|
||||
return err
|
||||
|
||||
@@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
sdkstep "git.novox.be/novox/mesh-delivery/sdk/buildstep"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@@ -86,6 +87,18 @@ func TestAMissingToolchainDirectoryIsInstalledOnceFromTheLock(t *testing.T) {
|
||||
if err := tc.Ensure(context.Background(), version); err != nil || len(fake.calls) != 1 {
|
||||
t.Errorf("a present directory ran npm again: %d calls, %v", len(fake.calls), err)
|
||||
}
|
||||
// ADR 0664 §1 (issue 1748): an install the network cut is a transport fault, the bus gives the ask again; a package the
|
||||
// registry lacks is not.
|
||||
for _, c := range []struct {
|
||||
stderr string
|
||||
passing bool
|
||||
}{{"npm error code ECONNRESET\nnpm error network aborted", true}, {"npm error code EAI_AGAIN", true}, {"npm error code E404\nnpm error 404 Not Found", false}} {
|
||||
bad := &fakeNpm{ran: forgekey.Ran{Status: 1, Stderr: c.stderr}}
|
||||
err := toolchainIn(t, bad).Ensure(context.Background(), Recipe{Steps: "2", Lock: "y"}.Version())
|
||||
if err == nil || sdkstep.IsPassing(err) != c.passing {
|
||||
t.Errorf("%q: %v, passing %v, want %v", c.stderr, err, err != nil && sdkstep.IsPassing(err), c.passing)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 1488/AC4: the install is told the mesh's registry for @novox with the account's credential, and only through a
|
||||
|
||||
Reference in New Issue
Block a user