Pintos looping when trying to run alarm-multiple - pintos

I'm just starting the Pintos project on a linux machine with a bochs simulator. When I try to run alarm-multiple it runs in a loop until it stops, and I'm not sure why:
~/pintos/src/threads/build$ pintos run alarm-multiple
warning: can't find squish-pty, so terminal input will fail
bochs -q
00000000000i[APIC?] local apic in initializing
========================================================================
Bochs x86 Emulator 2.2.6
Build from CVS snapshot on January 29, 2006
========================================================================
00000000000i[ ] reading configuration from bochsrc.txt
00000000000e[ ] user_shortcut: old-style syntax detected
00000000000i[ ] installing nogui module as the Bochs GUI
00000000000i[ ] using log file bochsout.txt
PiLo hda1
Loading................
PiLo hda1
Loading................
PiLo hda1
Loading................
PiLo hda1
Loading................
PiLo hda1
Loading................
PiLo hda1
Loading................
PiLo hda1
Loading................
PiLo hda1
Loading................
PiLo hda1
Loading................
PiLo hda1
Loading................
PiLo hda1
Loading................
^C========================================================================
Bochs is exiting with the following message:
[ ] SIGNAL 2 caught
========================================================================

Related

airflow user impersonation (run_as_user) not working

I am trying to use run_as_user feature in airflow for our DAG and we are facing some issues. Any help or recommendations?
DAG Code:from datetime import datetime, timedelta
from airflow import DAG
from airflow.operators.bash_operator import BashOperator
current_time = datetime.now() - timedelta(days=1)
default_args = {
'start_date': datetime.strptime(current_time.strftime('%Y-%m-%d %H:%M:%S'),'%Y-%m-%d %H:%M:%S'),
'run_as_user': 'airflowaduser',
'execution_timeout': timedelta(minutes=5)
}
dag = DAG('test_run-as_user', default_args=default_args,description='Run hive Query DAG', schedule_interval='0 * * * *',)
hive_ex = BashOperator(
task_id='hive-ex',
bash_command='whoami',
dag=dag
)
i have airflow added to sudoers and it can switch to airflowaduser without password from Linux shell.
airflow ALL=(ALL) NOPASSWD: ALL
Error details below while running the DAG:
*** Reading local file: /home/airflow/logs/test_run-as_user/hive-ex/2020-06-09T16:00:00+00:00/1.log
[2020-06-09 17:00:04,602] {taskinstance.py:620} INFO - Dependencies all met for <TaskInstance: test_run-as_user.hive-ex 2020-06-09T16:00:00+00:00 [queued]>
[2020-06-09 17:00:04,613] {taskinstance.py:620} INFO - Dependencies all met for <TaskInstance: test_run-as_user.hive-ex 2020-06-09T16:00:00+00:00 [queued]>
[2020-06-09 17:00:04,613] {taskinstance.py:838} INFO -
--------------------------------------------------------------------------------
[2020-06-09 17:00:04,613] {taskinstance.py:839} INFO - Starting attempt 1 of 1
[2020-06-09 17:00:04,613] {taskinstance.py:840} INFO -
--------------------------------------------------------------------------------
[2020-06-09 17:00:04,651] {taskinstance.py:859} INFO - Executing <Task(BashOperator): hive-ex> on 2020-06-09T16:00:00+00:00
[2020-06-09 17:00:04,651] {base_task_runner.py:133} INFO - Running: ['sudo', '-E', '-H', '-u', 'airflowaduser', 'airflow', 'run', 'test_run-as_user', 'hive-ex', '2020-06-09T16:00:00+00:00', '--job_id', '2314', '--pool', 'default_pool', '--raw', '-sd', 'DAGS_FOLDER/test_run-as_user/testscript.py', '--cfg_path', '/tmp/tmpbinlgw54']
[2020-06-09 17:00:04,664] {base_task_runner.py:115} INFO - Job 2314: Subtask hive-ex sudo: airflow: command not found
[2020-06-09 17:00:09,576] {logging_mixin.py:95} INFO - [[34m2020-06-09 17:00:09,575[0m] {[34mlocal_task_job.py:[0m105} INFO[0m - Task exited with return code 1[0m
And our airflow runs in virtual environment.
When running airflow in a virtual environment, only the user 'airflow' is configured to run airflow commands. If you want to run as another user, you need to set the home directory to be the same as for the airflow user (/home/airflow) and have it belong to the 0 group. See [https://airflow.apache.org/docs/docker-stack/entrypoint.html#allowing-arbitrary-user-to-run-the-container]
Additionally, the run_as_user feature calls sudo, which is only allowed to use the secure path. The location of the airflow commands is not part of the secure path, but it can be added in the sudoers file. You can use whereis airflow to check where the airflow directory is, in my container it was /home/airflow/.local/bin
To solve this I needed to add 4 lines to my Dockerfile:
RUN useradd -u [airflowaduser UID] -g 0 -d /home/airflow kettle && \
# create airflowaduser
usermod -u [airflow UID] -aG sudo airflow && \
# add airflow to sudo group
echo "airflow ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers && \
# allow airflow to run sudo without a password
sed -i 's#/.venv/bin#/home/airflow/.local/bin:/.venv/bin#' /etc/sudoers
# update secure path to include the airflow directory

PHPUnit fails on TravisCI, not sure how to debug

I'm still trying to teach myself Travis / CI so apologies if the answer is obvious.
I'm trying to determine why my Travis build for a project I've inherited is failing for PHP 7.1 but not 7.2.
Here is the .travis.yml config:
sudo: false
language: php
# Cache some data across builds for performance.
cache:
apt: true
directories:
- node_modules
- vendor
- $HOME/.composer/cache
notifications:
email:
on_success: never
on_failure: change
branches:
only:
- master
matrix:
include:
- php: 7.2
env: WP_Version=nightly
- php: 7.1
env: WP_VERSION=latest WP_TRAVISCI=phpcs
before_script:
- export PATH="$HOME/.composer/vendor/bin:$PATH"
- phpenv config-rm xdebug.ini
- |
if [[ ! -z "$WP_VERSION" ]] ; then
bash bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION
composer global require "phpunit/phpunit=5.7.*"
fi
- |
if [[ "$WP_TRAVISCI" == "phpcs" ]] ; then
composer global require wp-coding-standards/wpcs
phpcs --config-set installed_paths $HOME/.composer/vendor/wp-coding-standards/wpcs
fi
- mysql --version
- phpenv versions
- php --version
script:
- |
if [[ ! -z "$WP_VERSION" ]] ; then
phpunit --version
phpunit
WP_MULTISITE=1 phpunit
fi
- |
if [[ "$WP_TRAVISCI" == "phpcs" ]] ; then
phpcs --standard=phpcs.ruleset.xml $(find . -name '*.php')
fi
# If the plugin has any JavaScript or CSS that should be processed,
# add the below to their respective sections so that Grunt is installed
# and all default tasks are run.
#
# To the matrix:
#
# - php: 7.0
# env: WP_TRAVISCI=grunt
#
# To before_script:
#
# - npm --version
# - node --version
# - nvm install stable
# - npm install -g grunt-cli
# - npm install
# - npm prune
# - npm --version
# - node --version
#
# To script:
#
# - |
# if [[ "$WP_TRAVISCI" == "grunt" ]] ; then
# grunt --version
# grunt default
# fi
Here is the Travis log:
Setting environment variables from .travis.yml
$ export WP_VERSION=latest
$ export WP_TRAVISCI=phpcs
0.02s$ phpenv global 7.1 2>/dev/null
pearrc
Writing /home/travis/.pearrc
0.01s$ phpenv global 7.1
0.87s$ composer self-update
Updating to version 1.9.1 (stable channel).
Downloading (100%)
Use composer self-update --rollback to return to version 1.8.4
cache.1
Setting up build cache
$ php --version
PHP 7.1.27 (cli) (built: Mar 13 2019 07:54:47) ( ZTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.1.27, Copyright (c) 1999-2018, by Zend Technologies
with Xdebug v2.7.0, Copyright (c) 2002-2019, by Derick Rethans
$ composer --version
Composer version 1.9.1 2019-11-01 17:20:17
before_script.1
0.00s$ export PATH="$HOME/.composer/vendor/bin:$PATH"
before_script.2
0.02s$ phpenv config-rm xdebug.ini
before_script.3
14.36s$ if [[ ! -z "$WP_VERSION" ]] ; then
before_script.4
2.96s$ if [[ "$WP_TRAVISCI" == "phpcs" ]] ; then
before_script.5
0.02s$ mysql --version
before_script.6
0.05s$ phpenv versions
before_script.7
0.06s$ php --version
0.28s$ if [[ ! -z "$WP_VERSION" ]] ; then
phpunit --version
phpunit
WP_MULTISITE=1 phpunit
fi
PHPUnit 5.7.27 by Sebastian Bergmann and contributors.
PHP Warning: mysqli_real_connect(): (HY000/2002): No such file or directory in /tmp/wordpress/wp-includes/wp-db.php on line 1633
wp_die called
Message : <p><code>No such file or directory</code></p>
<h1>Error establishing a database connection</h1>
<p>This either means that the username and password information in your <code>wp-config.php</code> file is incorrect or we can’t contact the database server at <code>localhost</code>. This could mean your host’s database server is down.</p>
<ul>
<li>Are you sure you have the correct username and password?</li>
<li>Are you sure you have typed the correct hostname?</li>
<li>Are you sure the database server is running?</li>
</ul>
<p>If you’re unsure what these terms mean you should probably contact your host. If you still need help you can always visit the WordPress Support Forums.</p>
Title :
PHP Warning: mysqli_real_connect(): (HY000/2002): No such file or directory in /tmp/wordpress/wp-includes/wp-db.php on line 1633
wp_die called
Message : <p><code>No such file or directory</code></p>
<h1>Error establishing a database connection</h1>
<p>This either means that the username and password information in your <code>wp-config.php</code> file is incorrect or we can’t contact the database server at <code>localhost</code>. This could mean your host’s database server is down.</p>
<ul>
<li>Are you sure you have the correct username and password?</li>
<li>Are you sure you have typed the correct hostname?</li>
<li>Are you sure the database server is running?</li>
</ul>
<p>If you’re unsure what these terms mean you should probably contact your host. If you still need help you can always visit the WordPress Support Forums.</p>
Title :
The command "if [[ ! -z "$WP_VERSION" ]] ; then
phpunit --version
phpunit
WP_MULTISITE=1 phpunit
fi
" exited with 1.
0.70s$ if [[ "$WP_TRAVISCI" == "phpcs" ]] ; then
phpcs --standard=phpcs.ruleset.xml $(find . -name '*.php')
fi
The command "if [[ "$WP_TRAVISCI" == "phpcs" ]] ; then
phpcs --standard=phpcs.ruleset.xml $(find . -name '*.php')
fi
" exited with 0.
cache.2
store build cache
Done. Your build exited with 1.
I can see the error message is related to the database, but I'm not sure where to look to debug it.
The PHP7.2 job passes.

RPM-SPEC - Bash Script not installing packages specified in %post SPEC file

I wrote a bash script to install multiple packages and calling the bash script in %post. But its not executing the script. I am new to this area and I am not sure what I am missing.
If i manually execute the script its working fine but not through the rpm package.
InstallRPM.spec file:
Name: InstallRPM
Version: 1
Release: 1%{?dist}
Summary: Install RPM Packages
License: Script
URL: NA
Source0: InstallRPM-1.tar.gz
BuildArch: noarch
BuildRoot: %{_tmppath}/%{name}-buildroot
Requires: /bin/sh
%description
Install RPM files from the /tmp/ folder
%prep
%setup -q
%install
mkdir -p "$RPM_BUILD_ROOT"
cp -R * "$RPM_BUILD_ROOT"
%post
echo "Executing the script /tmp/InstallRPM.sh"
/tmp/InstallRPM.sh
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root,-)
/tmp/InstallRPM.sh
Shell Script:
#!/bin/bash
echo "Installing package using YUM"
package="vim zip"
echo "Install $package ..."
if [ "`cat /etc/centos-release | awk '{print $1}'`" == "CentOS" ]
then
{
for i in $package
do
{
#if [ "`/bin/rpm -qa $i | cut -d. -f1`" == "" ]
if [ "`/bin/rpm -qa $i`" == "" ]
then
{
echo "Clean Install"
/usr/bin/sudo /bin/yum install -y $i
}
else
{
echo "Upgrade"
/usr/bin/sudo /bin/yum update -y $i
}
fi
echo "****************"
}
done
}
fi
I ran the rpmbuild -ba InstallRPM.spec and it created a rpm file which I executed but nothing happened. Its getting hung in the below mentioned spot.
Downloading packages:
vim-enhanced-7.4.629-6.el7.x86_64.rpm | 1.1 MB 00:00:02
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
^C
You are using rpm the wrong way. Don't install dependencies in a %post script. I suggest you to read the rpm packaging guide first.
You should use Requires in your spec file, like this:
Requires: vim
Requires: zip

point knitr to bash 4 on mac

I have updated my bash to bash version 4.4.0 on mac osx. However, as explained in this question, I cannot update the bash version under bin/bash but just install a parallel shell under /usr/local/bin/bash
how can I point knitr to this shell? engine.path seems to get ignored:
```{r, engine='bash', engine.path='/usr/local/bin/bash'}
which bash
```
gives
/bin/bash
update
# Kevin: yes you are right, echo $BASH gives /usr/local/bin/bash
BUT:
from knitr
```{bash, engine.path='/usr/local/bin/bash'}
which bash
echo $BASH
bash --version
```
gives
/bin/bash
/usr/local/bin/bash
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin15)
Copyright (C) 2007 Free Software Foundation, Inc.
while the same from the command line gives
edit 2
after re-reading the answer of #Kevin, this works
```{r, engine = "bash", engine.path = "/usr/local/bin/bash"}
export PATH="/usr/local/bin:$PATH"
bash --version
```
GNU bash, version 4.4.0(1)-release (x86_64-apple-darwin15.6.0)
What does echo $BASH print? It's possible that your PATH has /usr/bin before /usr/local/bin, or even /usr/local/bin is not on the PATH.
For example, I see:
indicating that engine.path is indeed being respected.

running sbt command from ansible shell

I am trying to run a sbt command using ansible's shell command as follows from the main.yml in a role's task directory:
- shell: ./sbt clean reload compile
I have also tried the following:
- shell: /usr/sbin/sbt clean reload compile
Neither command works. The output from which sbt is
/usr/bin/sbt
The error message I get from ansible is:
fatal: [testserver]: FAILED! => {"changed": true, "cmd": "/usr/bin/sbt clean reload compile", "delta": "0:00:00.062588", "end": "2016-10-04 21:36:26.883947", "failed": true, "rc": 127, "start": "2016-10-04 21:36:26.821359", "stderr": "/bin/sh: 1: /usr/bin/sbt: not found", "stdout": "", "stdout_lines": [], "warnings": []}
I had to use local_action before using the shell command (the command was running on the remote machine, not the local one previously):
- local_action: shell /usr/bin/sbt clean reload compile

Resources