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

Code from example simple_setup fails to compile #99

Open
GMZwinge opened this issue Aug 8, 2024 · 4 comments
Open

Code from example simple_setup fails to compile #99

GMZwinge opened this issue Aug 8, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@GMZwinge
Copy link
Contributor

GMZwinge commented Aug 8, 2024

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet Bolt: 3.27.4
  • Module version: Latest

How to reproduce (e.g Puppet code you use)

Run bolt plan run test_voxpupuli_puppet_k8s::myplan --target <host> --user <user> --password <password> type=<type> in this repo, where <type> can be either controller or worker.

Once I get this working, I will provide a PR to fix the example.

What are you seeing

With type=controller, the error is:

  Apply failed to compile for <host>: Class[Profile::K8s::Controller]: parameter 'container_manager' expects a match for K8s::Container_runtimes = Enum['containerd', 'crio'], got Undef (file: /test_voxpupuli_puppet_k8s/manifests/my_manifest.pp, line: 6, column: 5)  

With type=worker, the error is:

  Apply failed to compile for <host>: Class[Profile::K8s::Worker]:
    parameter 'control_plane_url' expects a match for Stdlib::HTTPUrl = Pattern[/(?i:\Ahttps?:\/\/.*\z)/], got Undef
    parameter 'k8s_version' expects a String value, got Undef (file: /test_voxpupuli_puppet_k8s/manifests/my_manifest.pp, line: 8, column: 5)    

What behaviour did you expect instead

There is no failure.

Output log

With type=controller, the output is:

Starting: plan test_voxpupuli_puppet_k8s::myplan
Start test_voxpupuli_puppet_k8s::myplan.
Starting: install puppet and gather facts on <host>
Finished: install puppet and gather facts with 0 failures in 7.42 sec
Starting: apply catalog on <host>
Failed on <host>:
  Apply failed to compile for <host>: Class[Profile::K8s::Controller]: parameter 'container_manager' expects a match for K8s::Container_runtimes = Enum['containerd', 'crio'], got Undef (file: /test_voxpupuli_puppet_k8s/manifests/my_manifest.pp, line: 6, column: 5)  
Finished: apply catalog with 1 failure in 5.02 sec
Finished: plan test_voxpupuli_puppet_k8s::myplan in 12.44 sec
Failed on <host>:
  Apply failed to compile for <host>: Class[Profile::K8s::Controller]: parameter 'container_manager' expects a match for K8s::Container_runtimes = Enum['containerd', 'crio'], got Undef (file: /test_voxpupuli_puppet_k8s/manifests/my_manifest.pp, line: 6, column: 5)  
Failed on 1 target: <host>
Ran on 1 target

With type=worker, the output is:

Starting: plan test_voxpupuli_puppet_k8s::myplan
Start test_voxpupuli_puppet_k8s::myplan.
Starting: install puppet and gather facts on <host>
Finished: install puppet and gather facts with 0 failures in 7.63 sec
Starting: apply catalog on <host>
Failed on <host>:
  Apply failed to compile for <host>: Class[Profile::K8s::Controller]: parameter 'container_manager' expects a match for K8s::Container_runtimes = Enum['containerd', 'crio'], got Undef (file: /test_voxpupuli_puppet_k8s/manifests/my_manifest.pp, line: 6, column: 5)  
Finished: apply catalog with 1 failure in 4.8 sec
Finished: plan test_voxpupuli_puppet_k8s::myplan in 12.44 sec
Failed on <host>:
  Apply failed to compile for <host>: Class[Profile::K8s::Controller]: parameter 'container_manager' expects a match for K8s::Container_runtimes = Enum['containerd', 'crio'], got Undef (file: /test_voxpupuli_puppet_k8s/manifests/my_manifest.pp, line: 6, column: 5)  
Failed on 1 target: <host>
Ran on 1 target

Any additional information you'd like to impart

@ananace ananace added the bug Something isn't working label Aug 10, 2024
@GMZwinge
Copy link
Contributor Author

I can workaround the issue by adding the container runtime as a data and look it up for both controller and worker. See this commit. Is there a better way?

@GMZwinge
Copy link
Contributor Author

After applying a similar workaround for other common data and turning off puppetdb discovery, it now gives error like this when applying to the controller:

Apply failed to compile for kubernetes: Class[K8s::Server::Resources::Bootstrap]: parameter 'secret' expects a value of type Undef or Sensitive[K8s::Bootstrap_token], got String (file: /test_voxpupuli_puppet_k8s/.modules/k8s/manifests/server/resources.pp, line: 66, column: 5)

@GMZwinge
Copy link
Contributor Author

GMZwinge commented Sep 19, 2024

Using the example dealing with secrets in bootstrap token is sensitive, node_token is not, I got things to work in my test repo test-voxpupuli-puppet-k8s, but I had to correct a few more things in data\common.yaml (Used crio for container_manager, it did not seem to work with containerd), data\nodes\controller.yaml (advertise_address was device specific and the default in .modules\k8s\manifests\server\apiserver.pp worked) and data\nodes\worker.yaml (node_token missed a prefix and required a similar secret handling).

Not sure if those deprecation warning can be addressed to still work with older Puppet versions that this repo supports:

kubeworker: This function is deprecated, please use stdlib::ensure_packages instead. at ["/test_voxpupuli_puppet_k8s/.modules/k8s/manifests/init.pp", 192]:["/test_voxpupuli_puppet_k8s/manifests/my_manifest.pp", 8]
   (location: /test_voxpupuli_puppet_k8s/.modules/stdlib/lib/puppet/functions/deprecation.rb:35:in `deprecation')
kubeworker: This function is deprecated, please use stdlib::to_yaml instead. at ["/test_voxpupuli_puppet_k8s/.modules/k8s/manifests/install/crictl.pp", 53]:["/test_voxpupuli_puppet_k8s/.modules/k8s/manifests/node.pp", 58]
   (location: /test_voxpupuli_puppet_k8s/.modules/stdlib/lib/puppet/functions/deprecation.rb:35:in `deprecation')
kubeworker: This function is deprecated, please use stdlib::to_json instead. at ["/test_voxpupuli_puppet_k8s/.modules/k8s/manifests/node/simple_cni.pp", 33]:["/test_voxpupuli_puppet_k8s/.modules/k8s/manifests/node.pp", 67]
   (location: /test_voxpupuli_puppet_k8s/.modules/stdlib/lib/puppet/functions/deprecation.rb:35:in `deprecation')

@claudinoac
Copy link

claudinoac commented Oct 22, 2024

I tried to fix the same error as #51 but still get

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while
 evaluating a Function Call, Class[K8s::Server::Resources::Bootstrap]: parameter 'secret' expects a value 
of type Undef or Sensitive[K8s::Bootstrap_token = Pattern[/\A[a-z0-9]{16}\z/]], got Sensitive[String]

And yes, my token matches the regex above

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

3 participants