Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove non-portable source commands #1567

Merged
merged 1 commit into from
Jan 4, 2024
Merged

Remove non-portable source commands #1567

merged 1 commit into from
Jan 4, 2024

Conversation

smortex
Copy link
Collaborator

@smortex smortex commented Jan 4, 2024

source(1) is a bashism and is equivalent to the portable .(1), but
as each command is run in a new shell, spawning a shell to source a file
and exit is at best noop.

Some SUT used by acceptance tests do not use bash(1) as the default
shell (e.g. Ubuntu 22.04 ARM), which cause CI failures because
source is not found (127 exit code):

  1) postgresql task sql task sets up a postgres db
     On host `104.154.182.99'
     Failure/Error: LitmusHelper.instance.run_shell('source /etc/profile.d/my-custom.lang.sh')
     RuntimeError:
       shell failed
       `source /etc/profile.d/my-custom.lang.sh`
       ======
       [{"target"=>"104.154.182.99", "action"=>"command", "object"=>"source /etc/profile.d/my-custom.lang.sh", "status"=>"failure", "value"=>{"stdout"=>"", "stderr"=>"sh: 1: source: not found\n", "merged_output"=>"sh: 1: source: not found\n", "exit_code"=>127, "_error"=>{"kind"=>"puppetlabs.tasks/command-error", "issue_code"=>"COMMAND_ERROR", "msg"=>"The command failed with exit code 127", "details"=>{"exit_code"=>127}}}}]

     # ./vendor/bundle/ruby/2.7.0/gems/puppet_litmus-1.3.0/lib/puppet_litmus/puppet_helpers.rb:206:in `run_shell'
     # ./spec/spec_helper_acceptance_local.rb:30:in `export_locales'
     # ./spec/acceptance/sql_task_spec.rb:17:in `block (3 levels) in <top (required)>'

  2) postgresql task sql task execute some sql
     On host `104.154.182.99'
     Failure/Error:
       result = run_bolt_task('postgresql::sql', 'sql' => 'SELECT count(table_name) FROM information_schema.tables;', 'host' => 'localhost',
                                                 'user' => 'root1', 'password' => 'password', 'database' => 'spec1')
     RuntimeError:
       task failed
       `postgresql::sql`
       ======
       [{"target"=>"104.154.182.99", "action"=>"task", "object"=>"postgresql::sql", "status"=>"failure", "value"=>{"status"=>"failure", "error"=>"psql: error: connection to server at \"localhost\" (127.0.0.1), port 5432 failed: FATAL:  password authentication failed for user \"root1\"\nconnection to server at \"localhost\" (127.0.0.1), port 5432 failed: FATAL:  password authentication failed for user \"root1\"\n", "_error"=>{"kind"=>"puppetlabs.tasks/task-error", "issue_code"=>"TASK_ERROR", "msg"=>"The task failed with exit code 1", "details"=>{"exit_code"=>1}}}}]

     # ./vendor/bundle/ruby/2.7.0/gems/puppet_litmus-1.3.0/lib/puppet_litmus/puppet_helpers.rb:299:in `run_bolt_task'
     # ./spec/acceptance/sql_task_spec.rb:23:in `block (3 levels) in <top (required)>'

Finished in 17 minutes 2 seconds (files took 3.36 seconds to load)
59 examples, 2 failures, 10 pending

Failed examples:

rspec ./spec/acceptance/sql_task_spec.rb:16 # postgresql task sql task sets up a postgres db
rspec ./spec/acceptance/sql_task_spec.rb:21 # postgresql task sql task execute some sql

Because we set variables in profile files, assume they are sourced
during shell startup and will be available to next spawned shells.

`source(1)` is a bashism and is equivalent to the portable `.(1)`, but
as each command is run in a new shell, spawning a shell to source a file
and exit is at best noop.

Some SUT used by acceptance tests do not use bash(1) as the default
shell (e.g. Ubuntu 22.04 ARM), which cause CI failures because
`source` is not found (127 exit code):

```
  1) postgresql task sql task sets up a postgres db
     On host `104.154.182.99'
     Failure/Error: LitmusHelper.instance.run_shell('source /etc/profile.d/my-custom.lang.sh')
     RuntimeError:
       shell failed
       `source /etc/profile.d/my-custom.lang.sh`
       ======
       [{"target"=>"104.154.182.99", "action"=>"command", "object"=>"source /etc/profile.d/my-custom.lang.sh", "status"=>"failure", "value"=>{"stdout"=>"", "stderr"=>"sh: 1: source: not found\n", "merged_output"=>"sh: 1: source: not found\n", "exit_code"=>127, "_error"=>{"kind"=>"puppetlabs.tasks/command-error", "issue_code"=>"COMMAND_ERROR", "msg"=>"The command failed with exit code 127", "details"=>{"exit_code"=>127}}}}]

     # ./vendor/bundle/ruby/2.7.0/gems/puppet_litmus-1.3.0/lib/puppet_litmus/puppet_helpers.rb:206:in `run_shell'
     # ./spec/spec_helper_acceptance_local.rb:30:in `export_locales'
     # ./spec/acceptance/sql_task_spec.rb:17:in `block (3 levels) in <top (required)>'

  2) postgresql task sql task execute some sql
     On host `104.154.182.99'
     Failure/Error:
       result = run_bolt_task('postgresql::sql', 'sql' => 'SELECT count(table_name) FROM information_schema.tables;', 'host' => 'localhost',
                                                 'user' => 'root1', 'password' => 'password', 'database' => 'spec1')
     RuntimeError:
       task failed
       `postgresql::sql`
       ======
       [{"target"=>"104.154.182.99", "action"=>"task", "object"=>"postgresql::sql", "status"=>"failure", "value"=>{"status"=>"failure", "error"=>"psql: error: connection to server at \"localhost\" (127.0.0.1), port 5432 failed: FATAL:  password authentication failed for user \"root1\"\nconnection to server at \"localhost\" (127.0.0.1), port 5432 failed: FATAL:  password authentication failed for user \"root1\"\n", "_error"=>{"kind"=>"puppetlabs.tasks/task-error", "issue_code"=>"TASK_ERROR", "msg"=>"The task failed with exit code 1", "details"=>{"exit_code"=>1}}}}]

     # ./vendor/bundle/ruby/2.7.0/gems/puppet_litmus-1.3.0/lib/puppet_litmus/puppet_helpers.rb:299:in `run_bolt_task'
     # ./spec/acceptance/sql_task_spec.rb:23:in `block (3 levels) in <top (required)>'

Finished in 17 minutes 2 seconds (files took 3.36 seconds to load)
59 examples, 2 failures, 10 pending

Failed examples:

rspec ./spec/acceptance/sql_task_spec.rb:16 # postgresql task sql task sets up a postgres db
rspec ./spec/acceptance/sql_task_spec.rb:21 # postgresql task sql task execute some sql
```

Because we set variables in profile files, assume they are sourced
during shell startup and will be available to next spawned shells.
@bastelfreak
Copy link
Collaborator

@smortex thanks for the work! Should we add maintenance label so it won't appear in the CHANGELOG?

@smortex
Copy link
Collaborator Author

smortex commented Jan 4, 2024

I am not sure about the EL-8 failures, but I see that "AlmaLinux-8, puppet7-nightly" and "Rocky-8, puppet8-nightly" passed this time instead of timeout as they use to 🤷. Any suggestion for having more detail about what is going on when these tests block would be welcome!

In the meantime I will merge this since it fix the Ubuntu 22.04 ARM tests.

@smortex smortex merged commit 0b610d1 into main Jan 4, 2024
41 of 45 checks passed
@smortex smortex deleted the fix-ubuntu-arm-ci branch January 4, 2024 23:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants