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

TypeError on running "ovn-k8s-overlay master-init" #125

Closed
AakashKT opened this issue Jun 25, 2017 · 13 comments
Closed

TypeError on running "ovn-k8s-overlay master-init" #125

AakashKT opened this issue Jun 25, 2017 · 13 comments

Comments

@AakashKT
Copy link

Hi,
Followed the guide to set up kubernetes with ovs (https://github.com/openvswitch/ovn-kubernetes/blob/master/README.md)
In the section for "k8s master node initialisation", on running "ovn-k8s-overlay master-init", I get the following error :
Failed operation.
(a bytes-like object is required, not 'str')
at Traceback (most recent call last):
File "/usr/local/bin/ovn-k8s-overlay", line 802, in
main()
File "/usr/local/bin/ovn-k8s-overlay", line 797, in main
args.func(args)
File "/usr/local/bin/ovn-k8s-overlay", line 408, in master_init
fetch_ovn_nb()
File "/usr/local/bin/ovn-k8s-overlay", line 41, in fetch_ovn_nb
"external_ids:ovn-nb").strip('"')
TypeError: a bytes-like object is required, not 'str'

It would be great if someone could help me out :-) Thanks

@shettyg
Copy link
Collaborator

shettyg commented Jun 25, 2017

@AakashKT

As asked in the instructions, did you run:

ovs-vsctl set Open_vSwitch . external_ids:ovn-remote="tcp:$CENTRAL_IP:6642" \
  external_ids:ovn-nb="tcp:$CENTRAL_IP:6641" \
  external_ids:ovn-encap-ip=$LOCAL_IP \
  external_ids:ovn-encap-type="$ENCAP_TYPE"

If so, what does the following command give you:

ovs-vsctl get open_vswitch . external-ids:ovn-nb 

@AakashKT
Copy link
Author

@shettyg
Thanks for the reply
Yes, I have run the command you mentioned.
For this command :
ovs-vsctl get open_vswitch . external-ids:ovn-nb
the output is :
"tcp:35.185.55.145:6641"

@shettyg
Copy link
Collaborator

shettyg commented Jun 25, 2017

What is the platform? i.e Ubuntu 14.04 etc.
What is the Python version? I suppose this not a problem with "sudo"?

@AakashKT
Copy link
Author

Platform is Ubuntu 16.04
I have not installed anything over the system python (i.e. 2.7)
I am running the above command with "sudo", since if I don't, it gives Permission Denied error. Could that be the issue?

@shettyg
Copy link
Collaborator

shettyg commented Jun 25, 2017

Looks like python3 is being invoked instead of python2.7

Put this code in a file and run it in both python2.7 and python3 and run it with sudo
e.g: sudo python3 1.py
sudo python2.7 1.py

import subprocess

def call_popen(cmd):
    child = subprocess.Popen(cmd, stdout=subprocess.PIPE)
    output = child.communicate()
    if child.returncode:
        raise RuntimeError("Fatal error executing %s" % (cmd))
    if len(output) == 0 or output[0] is None:
        output = ""
    else:
        output = output[0].strip()
    return output


def call_prog(prog, args_list):
    cmd = [prog, "--timeout=5", "-vconsole:off"] + args_list
    return call_popen(cmd)


def ovs_vsctl(*args):
    return call_prog("ovs-vsctl", list(args))

def fetch_ovn_nb():
    OVN_NB = ovs_vsctl("--if-exists", "get", "Open_vSwitch", ".",
                       "external_ids:ovn-nb").strip('"')
    print(OVN_NB)

fetch_ovn_nb()

@AakashKT
Copy link
Author

@shettyg
I executed the above with both python2.7 and python3 with sudo as you asked.
You were right, python3 is being invoked, and its giving errors when I run the above code with python3. With python2.7 instead, its prints out the ovn-nb info.
What should I do to fix this? Also, a bit confused as to how python3 is being invoked

@shettyg
Copy link
Collaborator

shettyg commented Jun 25, 2017

What does the following say?

/usr/bin/python --version

@AakashKT
Copy link
Author

output :
Python 2.7.12

@AakashKT
Copy link
Author

AakashKT commented Jun 26, 2017

@shettyg
So i noticed something off, in the original code, the scripts such as ovn-k8s-overlay have shebang line
#!/usr/bin/python
but after installing (i.e after running pip install . ), the file /usr/bin/ovn-k8s-overlay has
#!/usr/bin/python3
Don't know why that is happening though

@shettyg
Copy link
Collaborator

shettyg commented Jun 26, 2017

@AakashKT
Thanks for tracking it down. Does 'pip2 install .' solve the problem? (After doing a pip uinstall ovn-kubernetes)

@AakashKT
Copy link
Author

@shettyg
Thanks for the help, that did solve the problem. I guess this was not an issue after all?
Again, thank you :-)

@shettyg
Copy link
Collaborator

shettyg commented Jun 26, 2017

I will spend some time to get it to work for python3 too.

@AakashKT
Copy link
Author

Oh okay, that would be great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants