From 864b8e3296f5734fae44bef41474d26c6f55ed7e Mon Sep 17 00:00:00 2001 From: Annie Pompa Date: Thu, 2 Nov 2023 15:17:41 +0000 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 c8d55809d38e..3c2b049a46a7 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 1ec0094f1ba9..7cd77e6d81a9 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 69006d9afa9c..3a48be56456f 100644 --- a/pkg/cmd/roachtest/tests/sequelize.go +++ b/pkg/cmd/roachtest/tests/sequelize.go @@ -90,32 +90,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 8d487b7a68a3..01bf66c0acb5 100644 --- a/pkg/cmd/roachtest/tests/typeorm.go +++ b/pkg/cmd/roachtest/tests/typeorm.go @@ -87,32 +87,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(