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

Add missing dependencies to allow repo initialization on first puppet run. #178

Merged
merged 7 commits into from
Jan 17, 2018

Conversation

nuclearsandwich
Copy link
Contributor

@nuclearsandwich nuclearsandwich commented Jan 12, 2018

Puppet, at least version 3.8.5, does not evaluate environment variable strings for variable expansion, which was leading to a PYTHONPATH variable of /home/jenkins-agent/reprepro-updater/src:$PYTHONPATH with a literal $PYTHONPATH.

This interfered with the default path and caused #174

I made a test deployment with this patch (and a few others). @gavanderhoorn if you have time to verify that this addresses #174 for you it would be appreciated.

Puppet, at least version 3.8.5, does not evaluate environment variable
strings for variable expansion, which was leading to a PYTHONPATH
variable of
`/home/jenkins-agent/reprepro-updater/src:$PYTHONPATH` with a literal
$PYTHONPATH.

I think this is interfering with the default path and causing #174
@nuclearsandwich nuclearsandwich self-assigned this Jan 12, 2018
@@ -210,7 +210,7 @@
exec {'init_main_repo':
path => '/bin:/usr/bin',
command => "/home/${agent_username}/reprepro-updater/scripts/setup_repo.py ubuntu_main -c",
environment => ["PYTHONPATH=/home/${agent_username}/reprepro-updater/src:\$PYTHONPATH"],
environment => ["PYTHONPATH=/home/${agent_username}/reprepro-updater/src"],
user => $agent_username,
group => $agent_username,
unless => "/home/${agent_username}/reprepro-updater/scripts/setup_repo.py ubuntu_testing -q",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a typo in line 216, it should be:

       unless      => "/home/${agent_username}/reprepro-updater/scripts/setup_repo.py ubuntu_main -q",

Note ubuntu_main vs ubuntu_testing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the catch!

@jonazpiazu
Copy link
Contributor

The changes in the branch did not fix the problem in my case.

Sorry that I do not really know puppet, so I am not sure how to debug. I tried this naive approach:

    exec {'init_building_repo':
      path        => '/bin:/usr/bin',
      command     => "echo 1: \$PYTHONPATH >> /tmp/output.log",
      environment => ["PYTHONPATH=/home/${agent_username}/reprepro-updater/src"],
      user  => $agent_username,
      group  => $agent_username,
      unless     => "echo 2: \$PYTHONPATH >> /tmp/output.log; /home/${agent_username}/reprepro-updat
      logoutput   => on_failure,
      require     => [
        Vcsrepo["/home/${agent_username}/reprepro-updater"],
        File["/home/${agent_username}/.buildfarm/reprepro-updater.ini"],
      ]
    }

And that generated this output:

# cat /tmp/output.log 
2: /home/jenkins-agent/reprepro-updater/src
1: /home/jenkins-agent/reprepro-updater/src

So PYTHONPATH looks just fine, I am not sure why the error still happens.

@gavanderhoorn
Copy link
Contributor

Seeing the comment by @jonazpiazu I haven't tested this yet @nuclearsandwich.

I do seem to remember that after sudo su - jenkins-agent I could not run the various scripts under reprepro-updater either after deployment finished (ie: the puppet run).

@nuclearsandwich
Copy link
Contributor Author

Thanks for the feedback @jonazpiazu and @gavanderhoorn. I tore down and started on a fresh machine and it fails the first time but succeeds the second. I learned from @tfoote that puppet sometimes needs to be run twice (and observed this previously when provisioning master) but I don't remember it being necessary for repo hosts.

I think the change here is still warranted as there's not much use in having a literal $PYTHONPATH in the variable and leaving it in doesn't do what one might expect.

I'm going to dig through puppet to see if something is finishing the setup of python and should be required before the repository initializations.

While investigating #174
some typos were found in the repository initialization logic that were
best resolved by a little puppet refactoring.

Additionally, the exec and unless commands are now run with `python`
rather than invoking the script directly as $0.
To be honest, I do not know how these commands were executing without a
crunchbang line. It's possible that this just hasn't worked as expected
for some time.

The decision to use python rather than python3 was made by examining how
reprepro-updater is invoked by ros_buildfarm jobs.
@gavanderhoorn
Copy link
Contributor

I'm by no means a puppet expert, but in my experience most problems are due to missing dependency declarations (or whatever puppet calls those). That is probably also the cause of #171 (I worked around that in #70 (comment)).

Running puppet twice is at best a work-around. It would be nice if we could deploy master, agent(s) and slave successfully, without needing that.

but I don't remember it being necessary for repo hosts.

Exactly. I wasn't expecting this either.

@nuclearsandwich
Copy link
Contributor Author

Running puppet twice is at best a work-around. It would be nice if we could deploy master, agent(s) and slave successfully, without needing that.

Yep, I'm digging in to figure out what the missing link in the chain is here. Thanks for the input and patience.

I was under the impression that this module was builtin but I guess I
was wrong.
Adding the repo_files variable to the previous File resource list was
not sufficient.
@nuclearsandwich nuclearsandwich changed the title Remove unevaluated $PYTHONPATH from environment variable suffix. Add missing dependencies to allow repo initialization on first puppet run. Jan 12, 2018
@nuclearsandwich
Copy link
Contributor Author

Okay, I think the latest changes should do it. I'm building new test branches and deploying to a new host to be sure.

@tfoote
Copy link
Member

tfoote commented Jan 12, 2018

Before you do that you might want to remove the Class['python'], I think that's redundant with the module requirements.

@nuclearsandwich
Copy link
Contributor Author

Before you do that you might want to remove the Class['python'], I think that's redundant with the module requirements.

Good catch. Because the require directive (rather than include) is used to bring in the profile::jenkins::agent class everything in there should be set up before anything within the profile::ros::repo class.

This is redundant at the moment as Python is required by
profile::jenkins::agent. If the relationship between these classes ever
changes this may need to be re-added.
@nuclearsandwich
Copy link
Contributor Author

nuclearsandwich commented Jan 13, 2018

This will close #174 and together with #179 should yield a clean deployment for repo hosts.

@gavanderhoorn
Copy link
Contributor

Just ran a repo deploy on a clean VM after merging this and #179 and so far it seems puppet has run to completion without any complaints.

This is just a test VM, so the repo host isn't being used for anything, but so far looks good.

Nice one @nuclearsandwich 👍.

Copy link
Contributor

@gavanderhoorn gavanderhoorn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to work. LGTM.

@inigomartinez
Copy link

I'm sorry to say that these fixes don't seem to work here. I have tried it several times by going back to a fresh imagen and executing reconfigure.bash master, and the result is always the same:

2018-01-15 12:55:40 +0100 /Stage[main]/Jenkins::Repo::Debian/Apt::Source[jenkins]/Apt::Setting[list-jenkins]/File[/etc/apt/sources.list.d/jenkins.list]/ensure
 (notice): created
2018-01-15 12:55:40 +0100 /Stage[main]/Jenkins::Repo::Debian/Apt::Source[jenkins]/Apt::Setting[list-jenkins]/File[/etc/apt/sources.list.d/jenkins.list] (info)
: Scheduling refresh of Class[Apt::Update]
2018-01-15 12:55:44 +0100 Puppet (err): Could not update: Execution of '/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold --force-yes install jenkins=
2.73.3' returned 100: Reading package lists...
Building dependency tree...
Reading state information...
E: Version '2.73.3' for 'jenkins' was not found
2018-01-15 12:55:44 +0100 /Stage[main]/Jenkins::Package/Package[jenkins]/ensure (err): change from purged to 2.73.3 failed: Could not update: Execution of '/u
sr/bin/apt-get -q -y -o DPkg::Options::=--force-confold --force-yes install jenkins=2.73.3' returned 100: Reading package lists...
Building dependency tree...
Reading state information...
E: Version '2.73.3' for 'jenkins' was not found
2018-01-15 12:55:44 +0100 /Group[jenkins] (notice): Dependency Package[jenkins] has failures: true
2018-01-15 12:55:44 +0100 /Group[jenkins] (warning): Skipping because of failed dependencies
2018-01-15 12:55:44 +0100 /User[jenkins] (notice): Dependency Package[jenkins] has failures: true
2018-01-15 12:55:44 +0100 /User[jenkins] (warning): Skipping because of failed dependencies
2018-01-15 12:55:44 +0100 /Stage[main]/Jenkins::Config/File[/var/lib/jenkins] (notice): Dependency Package[jenkins] has failures: true
2018-01-15 12:55:44 +0100 /Stage[main]/Jenkins::Config/File[/var/lib/jenkins] (warning): Skipping because of failed dependencies
2018-01-15 12:55:44 +0100 /Stage[main]/Jenkins::Config/File[/var/lib/jenkins/plugins] (notice): Dependency Package[jenkins] has failures: true
2018-01-15 12:55:44 +0100 /Stage[main]/Jenkins::Config/File[/var/lib/jenkins/plugins] (warning): Skipping because of failed dependencies
2018-01-15 12:55:44 +0100 /Stage[main]/Profile::Jenkins::Master/File[/var/lib/jenkins/credentials.xml] (notice): Dependency Package[jenkins] has failures: tru
e
2018-01-15 12:55:44 +0100 /Stage[main]/Profile::Jenkins::Master/File[/var/lib/jenkins/credentials.xml] (warning): Skipping because of failed dependencies

I tried this by setting BUILDFARM_DEPLOYMENT_BRANCH in buildfarm_depolyment_config to fix-repo-pythonpath.

@gavanderhoorn
Copy link
Contributor

@inigomartinez: I'm not sure, but I believe this PR targets the repo deployment only. So master not working is expected at this point.

@nuclearsandwich
Copy link
Contributor Author

I'm not sure, but I believe this PR targets the repo deployment only. So master not working is expected at this point.

This is correct. There are outstanding issues with master deployments (though if you run ./reconfigure master enough times it should get up and running 🙃) which I hope to address in more work later this week.

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.

5 participants