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

using pdk-docker getting Unable to open /.config/puppet/analytics.yml for writing (PDK::Config::LoadError) #35

Closed
sudodevnull opened this issue Dec 1, 2021 · 4 comments
Labels
bug Something isn't working

Comments

@sudodevnull
Copy link

sudodevnull commented Dec 1, 2021

Describe the Bug

We are trying to utilize the pdk-docker image to implement pdk test unit automated checks on our module branches.
When we run pdk test unit, we get the following error:
[Pipeline] sh

  • echo 'Inside stage'
    Inside stage
  • mv ShareFolder/CHANGELOG.md ShareFolder/Gemfile ShareFolder/Gemfile.lock ShareFolder/README.md ShareFolder/Rakefile ShareFolder/appveyor.yml ShareFolder/bin ShareFolder/hiera.yaml ShareFolder/manifests ShareFolder/metadata.json ShareFolder/spec .
  • export PDK_DISABLE_ANALYTICS=true
  • pdk test unit
    pdk (WARN): This module is compatible with an older version of PDK. Run pdk update to update it to your version of PDK.
    /opt/puppetlabs/pdk/private/ruby/2.5.9/lib/ruby/gems/2.5.0/gems/pdk-2.3.0/lib/pdk/config/namespace.rb:331:in rescue in save_data': Unable to open /.config/puppet/analytics.yml for writing (PDK::Config::LoadError) from /opt/puppetlabs/pdk/private/ruby/2.5.9/lib/ruby/gems/2.5.0/gems/pdk-2.3.0/lib/pdk/config/namespace.rb:324:in save_data'
    from /opt/puppetlabs/pdk/private/ruby/2.5.9/lib/ruby/gems/2.5.0/gems/pdk-2.3.0/lib/pdk/config/namespace.rb:106:in []' from /opt/puppetlabs/pdk/private/ruby/2.5.9/lib/ruby/gems/2.5.0/gems/pdk-2.3.0/lib/pdk/config.rb:291:in traverse_object'
    from /opt/puppetlabs/pdk/private/ruby/2.5.9/lib/ruby/gems/2.5.0/gems/pdk-2.3.0/lib/pdk/config.rb:297:in traverse_object' from /opt/puppetlabs/pdk/private/ruby/2.5.9/lib/ruby/gems/2.5.0/gems/pdk-2.3.0/lib/pdk/config.rb:156:in block in get_within_scopes'
    from /opt/puppetlabs/pdk/private/ruby/2.5.9/lib/ruby/gems/2.5.0/gems/pdk-2.3.0/lib/pdk/config.rb:155:in each' from /opt/puppetlabs/pdk/private/ruby/2.5.9/lib/ruby/gems/2.5.0/gems/pdk-2.3.0/lib/pdk/config.rb:155:in get_within_scopes'
    from /opt/puppetlabs/pdk/private/ruby/2.5.9/lib/ruby/gems/2.5.0/gems/pdk-2.3.0/lib/pdk.rb:68:in analytics' from /opt/puppetlabs/pdk/private/ruby/2.5.9/lib/ruby/gems/2.5.0/gems/pdk-2.3.0/lib/pdk/cli/util.rb:300:in analytics_screen_view'
    from /opt/puppetlabs/pdk/private/ruby/2.5.9/lib/ruby/gems/2.5.0/gems/pdk-2.3.0/lib/pdk/cli/test/unit.rb:36:in block (2 levels) in <module:CLI>' from /opt/puppetlabs/pdk/private/ruby/2.5.9/lib/ruby/gems/2.5.0/gems/cri-2.10.1/lib/cri/command.rb:329:in run_this'
    from /opt/puppetlabs/pdk/private/ruby/2.5.9/lib/ruby/gems/2.5.0/gems/cri-2.10.1/lib/cri/command.rb:269:in run' from /opt/puppetlabs/pdk/private/ruby/2.5.9/lib/ruby/gems/2.5.0/gems/cri-2.10.1/lib/cri/command.rb:287:in run'
    from /opt/puppetlabs/pdk/private/ruby/2.5.9/lib/ruby/gems/2.5.0/gems/cri-2.10.1/lib/cri/command.rb:287:in run' from /opt/puppetlabs/pdk/private/ruby/2.5.9/lib/ruby/gems/2.5.0/gems/pdk-2.3.0/lib/pdk/cli.rb:71:in run'
    from /opt/puppetlabs/pdk/private/ruby/2.5.9/lib/ruby/gems/2.5.0/gems/pdk-2.3.0/exe/pdk:6:in <top (required)>' from /opt/puppetlabs/pdk/private/ruby/2.5.9/bin/pdk:23:in load'
    from /opt/puppetlabs/pdk/private/ruby/2.5.9/bin/pdk:23:in `'
    [Pipeline] }
    [Pipeline] // container
    [Pipeline] }

Expected Behavior

We expect to get the output of a pass or failed pdk test unit

Steps to Reproduce

Steps to reproduce the behavior:
Here is our pipeline:

pipeline {
	agent { label 'deployer' }
	stages {
		stage('Run PDK Unit Tests') {
          agent {
            kubernetes {
              label 'pdk-deployer'
              cloud 'builder'
              yaml """
apiVersion: v1
kind: Pod
metadata:
labels:
  name: pdk-deployer
spec:
  securityContext:
    runAsUser: 1000
  containers:
  - name: pdk-deployer
    image: XXXXXXXXXXXX
    imagePullPolicy: Always
    env:
    - name: PDK_DISABLE_ANALYTICS
      value: true
    command:
    - cat
    tty: true
"""
            }
          }
		  options { skipDefaultCheckout() }
		  steps {
            script {
			  container('pdk-deployer') {
			  	checkout([$class: 'GitSCM', branches: [[name: 'CS-59']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'ShareFolder/']], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '', url: '']]])
				sh ''' echo "Inside stage"
					mv ShareFolder/* .
					export $PDK_DISABLE_ANALYTICS=true
					pdk test unit
				'''
			  }
            }
	      }
		  post {
			always {
				script {
						step([$class: 'StashNotifier'])
				}
			}
		  }
		}
	}
}

Environment

  • Version [e.g. 1.27.0]
  • Platform [e.g. Ubuntu 18.04]

Additional Context

When we initially got this error, we tried disabling analytics (as you can see in the above code) as per: https://puppet.com/docs/pdk/1.x/pdk_install.html

@sudodevnull sudodevnull added the bug Something isn't working label Dec 1, 2021
@danbarr
Copy link

danbarr commented Jan 10, 2022

I'm having the same problem when running the pdk container with --user=<any non-root UID> (like @sudodevnull's runAsUser: 1000) from a Bamboo task. We need to run the container with our Bamboo build user's UID, otherwise "pdk validate" writes several files/directories back as root:root, preventing Bamboo from cleaning up the working directory after the build.

@choman
Copy link

choman commented May 15, 2023

Would love to use this over installing pdk, but I have the same issue. Seems like it would be an easy fix

Update: I got some of this to work, need suggestions

  • in my project repo I created a tmp/config/puppet and a tmp/pdk/cache.
  • the tmp/pdk/cache I chmod'd 1777
  • add -v $(pwd)/tmp/config:/.config
  • add -v $(pwd)/tmp/pdk/cache:/.pdk/cache

@h0tw1r3
Copy link
Contributor

h0tw1r3 commented May 16, 2024

this should be fixed by #59

@jordanbreen28
Copy link
Contributor

closing inline with above comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants