From e3bac448be28a8aa1d95ef38326a1fa8097be603 Mon Sep 17 00:00:00 2001 From: Annie Pompa Date: Thu, 2 Nov 2023 11:17:41 -0400 Subject: [PATCH] roachtest: fix js install command (gpg) We are seeing a `gpg: cannot open '/dev/tty': No such device or address` error from the new installation method we followed. Resolution seems to be https://github.com/nodejs/docker-node/issues/922. In case we are running into an issue with machines being reused, we first check to see if we can install nodejs and npm before we add a nodesource key and deb repository (to prevent gpg: dearmoring failed: File exists) issues. (Copied from a reply to the bug report in the issue linked above) > For any script use you should anyway use --batch which disables the use of the tty as a side-effect. Fixes: #113673 Fixes: #113662 Fixes: #113659 Release note: None --- pkg/cmd/roachtest/tests/knex.go | 49 ++++++++++++--------- pkg/cmd/roachtest/tests/nodejs_postgres.go | 49 ++++++++++++--------- pkg/cmd/roachtest/tests/sequelize.go | 51 ++++++++++++---------- pkg/cmd/roachtest/tests/typeorm.go | 47 +++++++++++--------- 4 files changed, 114 insertions(+), 82 deletions(-) diff --git a/pkg/cmd/roachtest/tests/knex.go b/pkg/cmd/roachtest/tests/knex.go index 891eb01d00d9..037c1ef9f3a0 100644 --- a/pkg/cmd/roachtest/tests/knex.go +++ b/pkg/cmd/roachtest/tests/knex.go @@ -59,30 +59,39 @@ func registerKnex(r registry.Registry) { ) require.NoError(t, err) - err = repeatRunE( - ctx, - t, - c, - node, - "add nodesource key and deb repository", - ` + // In case we are running into a state where machines are being reused, we first check to see if we + // can use npm to reduce the potential of trying to add another nodesource key + // (preventing gpg: dearmoring failed: File exists) errors. + err = c.RunE( + ctx, node, `sudo npm i -g npm`, + ) + + if err != nil { + err = repeatRunE( + ctx, + t, + c, + node, + "add nodesource key and deb repository", + ` sudo apt-get update && \ sudo apt-get install -y ca-certificates curl gnupg && \ sudo mkdir -p /etc/apt/keyrings && \ -curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \ +curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --batch --dearmor -o /etc/apt/keyrings/nodesource.gpg && \ echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list`, - ) - require.NoError(t, err) - - err = repeatRunE( - ctx, t, c, node, "install nodejs and npm", `sudo apt-get update && sudo apt-get -qq install nodejs`, - ) - require.NoError(t, err) - - err = repeatRunE( - ctx, t, c, node, "update npm", `sudo npm i -g npm`, - ) - require.NoError(t, err) + ) + require.NoError(t, err) + + err = repeatRunE( + ctx, t, c, node, "install nodejs and npm", `sudo apt-get update && sudo apt-get -qq install nodejs`, + ) + require.NoError(t, err) + + err = repeatRunE( + ctx, t, c, node, "update npm", `sudo npm i -g npm`, + ) + require.NoError(t, err) + } err = repeatRunE( ctx, t, c, node, "install mocha", `sudo npm i -g mocha`, diff --git a/pkg/cmd/roachtest/tests/nodejs_postgres.go b/pkg/cmd/roachtest/tests/nodejs_postgres.go index df50fc35e233..419b804f8c1c 100644 --- a/pkg/cmd/roachtest/tests/nodejs_postgres.go +++ b/pkg/cmd/roachtest/tests/nodejs_postgres.go @@ -67,30 +67,39 @@ func registerNodeJSPostgres(r registry.Registry) { err = alterZoneConfigAndClusterSettings(ctx, t, version, c, node[0]) require.NoError(t, err) - err = repeatRunE( - ctx, - t, - c, - node, - "add nodesource key and deb repository", - ` + // In case we are running into a state where machines are being reused, we first check to see if we + // can use npm to reduce the potential of trying to add another nodesource key + // (preventing gpg: dearmoring failed: File exists) errors. + err = c.RunE( + ctx, node, `sudo npm i -g npm`, + ) + + if err != nil { + err = repeatRunE( + ctx, + t, + c, + node, + "add nodesource key and deb repository", + ` sudo apt-get update && \ sudo apt-get install -y ca-certificates curl gnupg && \ sudo mkdir -p /etc/apt/keyrings && \ -curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \ +curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --batch --dearmor -o /etc/apt/keyrings/nodesource.gpg && \ echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list`, - ) - require.NoError(t, err) - - err = repeatRunE( - ctx, t, c, node, "install nodejs and npm", `sudo apt-get update && sudo apt-get -qq install nodejs`, - ) - require.NoError(t, err) - - err = repeatRunE( - ctx, t, c, node, "update npm", `sudo npm i -g npm`, - ) - require.NoError(t, err) + ) + require.NoError(t, err) + + err = repeatRunE( + ctx, t, c, node, "install nodejs and npm", `sudo apt-get update && sudo apt-get -qq install nodejs`, + ) + require.NoError(t, err) + + err = repeatRunE( + ctx, t, c, node, "update npm", `sudo npm i -g npm`, + ) + require.NoError(t, err) + } err = repeatRunE( ctx, t, c, node, "install yarn", `sudo npm i -g yarn`, diff --git a/pkg/cmd/roachtest/tests/sequelize.go b/pkg/cmd/roachtest/tests/sequelize.go index 8b65d1786a16..6647fb6d902b 100644 --- a/pkg/cmd/roachtest/tests/sequelize.go +++ b/pkg/cmd/roachtest/tests/sequelize.go @@ -93,32 +93,39 @@ func registerSequelize(r registry.Registry) { t.Fatal(err) } - if err := repeatRunE( - ctx, - t, - c, - node, - "add nodesource key and deb repository", - ` + // In case we are running into a state where machines are being reused, we first check to see if we + // can use npm to reduce the potential of trying to add another nodesource key + // (preventing gpg: dearmoring failed: File exists) errors. + if err := c.RunE( + ctx, node, `sudo npm i -g npm`, + ); err != nil { + if err := repeatRunE( + ctx, + t, + c, + node, + "add nodesource key and deb repository", + ` sudo apt-get update && \ sudo apt-get install -y ca-certificates curl gnupg && \ sudo mkdir -p /etc/apt/keyrings && \ -curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \ +curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --batch --dearmor -o /etc/apt/keyrings/nodesource.gpg && \ echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list`, - ); err != nil { - t.Fatal(err) - } - - if err := repeatRunE( - ctx, t, c, node, "install nodejs and npm", `sudo apt-get update && sudo apt-get -qq install nodejs`, - ); err != nil { - t.Fatal(err) - } - - if err := repeatRunE( - ctx, t, c, node, "update npm", `sudo npm i -g npm`, - ); err != nil { - t.Fatal(err) + ); err != nil { + t.Fatal(err) + } + + if err := repeatRunE( + ctx, t, c, node, "install nodejs and npm", `sudo apt-get update && sudo apt-get -qq install nodejs`, + ); err != nil { + t.Fatal(err) + } + + if err := repeatRunE( + ctx, t, c, node, "update npm", `sudo npm i -g npm`, + ); err != nil { + t.Fatal(err) + } } if err := repeatRunE( diff --git a/pkg/cmd/roachtest/tests/typeorm.go b/pkg/cmd/roachtest/tests/typeorm.go index 7f2f7c812fc3..c68bd7abc34d 100644 --- a/pkg/cmd/roachtest/tests/typeorm.go +++ b/pkg/cmd/roachtest/tests/typeorm.go @@ -89,32 +89,39 @@ func registerTypeORM(r registry.Registry) { t.Fatal(err) } - if err := repeatRunE( - ctx, - t, - c, - node, - "add nodesource key and deb repository", - ` + // In case we are running into a state where machines are being reused, we first check to see if we + // can use npm to reduce the potential of trying to add another nodesource key + // (preventing gpg: dearmoring failed: File exists) errors. + if err := c.RunE( + ctx, node, `sudo npm i -g npm`, + ); err != nil { + if err := repeatRunE( + ctx, + t, + c, + node, + "add nodesource key and deb repository", + ` sudo apt-get update && \ sudo apt-get install -y ca-certificates curl gnupg && \ sudo mkdir -p /etc/apt/keyrings && \ -curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \ +curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --batch --dearmor -o /etc/apt/keyrings/nodesource.gpg && \ echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list`, - ); err != nil { - t.Fatal(err) - } + ); err != nil { + t.Fatal(err) + } - if err := repeatRunE( - ctx, t, c, node, "install nodejs and npm", `sudo apt-get update && sudo apt-get -qq install nodejs`, - ); err != nil { - t.Fatal(err) - } + if err := repeatRunE( + ctx, t, c, node, "install nodejs and npm", `sudo apt-get update && sudo apt-get -qq install nodejs`, + ); err != nil { + t.Fatal(err) + } - if err := repeatRunE( - ctx, t, c, node, "update npm", `sudo npm i -g npm`, - ); err != nil { - t.Fatal(err) + if err := repeatRunE( + ctx, t, c, node, "update npm", `sudo npm i -g npm`, + ); err != nil { + t.Fatal(err) + } } if err := repeatRunE(