unikraft / pykraft

Python library for configuring and building unikernels
Other
177 stars 42 forks source link

Getting started issue #37

Closed faerbersteve closed 3 years ago

faerbersteve commented 3 years ago

Describe the bug I have issues when creating the helloworld app. When following the two last steps of the readme (of the helloworld repo) I receive the following issue. I added the -t in the kraft up command as it was missing.

user@ubuntu:~/my-first-unikernel$ kraft --verbose up -p kvm -m x86_64 -t helloworld sw
[DEBUG   ] Synchronizing cache with filesystem...
[DEBUG   ] Checking cache for staleness...
[DEBUG   ] Retrieving http://github.com/unikraft/lib-* from cache...
[DEBUG   ] Retrieving http://github.com/unikraft/plat-* from cache...
[DEBUG   ] Retrieving http://github.com/unikraft/unikraft.git from cache...
[DEBUG   ] Retrieving http://github.com/unikraft/app-* from cache...
[DEBUG   ] Using configuration files: /home/andreas/.unikraft/apps/helloworld/kraft.yaml
[CRITICAL] kraft_app_init() got an unexpected keyword argument 'template_app_version'
[CRITICAL] Traceback (most recent call last):
  File "/home/andreas/.local/lib/python3.8/site-packages/kraft/cmd/up.py", line 202, in cmd_up
    kraft_app_init(
  File "/home/andreas/.local/lib/python3.8/site-packages/click-8.0.0a1-py3.8.egg/click/decorators.py", line 18, in new_func
    return f(get_current_context(), *args, **kwargs)
TypeError: kraft_app_init() got an unexpected keyword argument 'template_app_version'

To Reproduce Steps to reproduce the behavior:

mkdir my-first-unikernel && cd my-first-unikernel
kraft --verbose up -p kvm -m x86_64 -t helloworld sw

Expected behavior Runs without issue

Desktop (please complete the following information):

faerbersteve commented 3 years ago

I tried this also in a ubuntu 20.10 environment. The issue occurs there too.

Is there any workaround for this issue? I tried to add -v and --version but the error still happens

nderjung commented 3 years ago

This a confirmed bug, I will look into it :)

marcrittinghaus commented 3 years ago

I have a similar issue when running kraft for the helloworld app on Ubuntu 20.04.02 (Python 3.8.5)

user@ubuntu:~/my-first-unikernel$ kraft --verbose up -p kvm -m x86_64 -t helloworld sw

[DEBUG   ] Synchronizing cache with filesystem...
[DEBUG   ] Checking cache for staleness...
[DEBUG   ] Retrieving http://github.com/unikraft/plat-* from cache...
[DEBUG   ] Retrieving http://github.com/unikraft/lib-* from cache...
[DEBUG   ] Retrieving http://github.com/unikraft/app-* from cache...
[DEBUG   ] Retrieving http://github.com/unikraft/unikraft.git from cache...
[DEBUG   ] Using configuration files: /home/user/.unikraft/apps/helloworld/kraft.yaml
[CRITICAL] 'str' object has no attribute 'items'
[CRITICAL] Traceback (most recent call last):
  File "/home/user/.local/lib/python3.8/site-packages/kraft/cmd/up.py", line 183, in cmd_up
    kraft_list_pull(
  File "/home/user/.local/lib/python3.8/site-packages/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/user/.local/lib/python3.8/site-packages/kraft/cmd/list/pull.py", line 150, in kraft_list_pull
    kraft_list_pull(
  File "/home/user/.local/lib/python3.8/site-packages/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/user/.local/lib/python3.8/site-packages/kraft/cmd/list/pull.py", line 89, in kraft_list_pull
    app = Application.from_workdir(
  File "/home/user/.local/lib/python3.8/site-packages/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/user/.local/lib/python3.8/site-packages/kraft/app/app.py", line 136, in from_workdir
    config = load_config(find_config(workdir, None, ctx.obj.env))
  File "/home/user/.local/lib/python3.8/site-packages/kraft/config/config.py", line 533, in load_config
    processed_files = [
  File "/home/user/.local/lib/python3.8/site-packages/kraft/config/config.py", line 534, in <listcomp>
    process_kraftfile(config_file, config_details.environment)
  File "/home/user/.local/lib/python3.8/site-packages/kraft/config/config.py", line 360, in process_kraftfile
    processed_config['unikraft'] = interpolate_environment_variables(
  File "/home/user/.local/lib/python3.8/site-packages/kraft/config/interpolation.py", line 187, in interpolate_environment_variables
    for name, config_dict in config.items()
AttributeError: 'str' object has no attribute 'items'

The same error can be observed with the other kraft commands such as kraft configure when working with a manually cloned version of the app-helloworld repository.

The problem is that kraft.yaml specifies the unikraft option as version string (in accordance with specification_v0.X.json). However, kraft seems to expect the option to be a dictionary.

I made it working by explicitly stating the version field in the configuration file.

specification: '0.4'

unikraft: 
   version: '0.5'

Alternatively, you can change the getter for the unikraft property in config.py, although that may be considered a dirty hack:

diff --git a/kraft/config/config.py b/kraft/config/config.py
index af51fe5..c73592c 100644
--- a/kraft/config/config.py
+++ b/kraft/config/config.py
@@ -306,7 +306,10 @@ class KraftFile(namedtuple(
         return self.config.get('name', '')

     def get_unikraft(self):
-        return self.config.get('unikraft', {})
+        uk = self.config.get('unikraft', {})
+        if not isinstance(uk, dict):
+            return dict(version=uk)
+        return uk

     def get_arguments(self):
         return self.config.get('arguments', None)
nderjung commented 3 years ago

Hi!

I ran into the same issue and just fixed this this morning :)

Please checkout latest stagning

nderjung commented 3 years ago

Closing this issue because I think it's been completely resolved now in staging with recent changes. :)