-
Notifications
You must be signed in to change notification settings - Fork 114
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
Support changing Eswitch mode of SR-IOV NICs for kubernetes deployment #39
Conversation
5071499
to
7bc1804
Compare
7bc1804
to
0b32f7c
Compare
0b32f7c
to
9bb80db
Compare
60a0192
to
9a50ee9
Compare
9a50ee9
to
0480bd1
Compare
5fa8518
to
b863730
Compare
pkg/service/utils.go
Outdated
} | ||
|
||
// ServiceAppend appends missing fields of serviceB into serviceA | ||
func ServiceAppend(serviceA, serviceB *Service) (*Service, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can change to ServiceAppend(serviceA *Service, contentToAppend)((*Service, error)
Why do you need the serviceB?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also maybe change to AppendToService to be same as RemoveFromService
pkg/service/utils.go
Outdated
return false, nil | ||
} | ||
|
||
// CompareServices compare 2 service and return true if serviceA has all the fields of serviceB |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update comment
pkg/service/utils.go
Outdated
} | ||
} | ||
|
||
if !found { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so after reading about the break label I think what you did first with the outer was better to break from both loops.
pkg/service/service_manager.go
Outdated
return cmd.Run() | ||
} | ||
|
||
func (sm *serviceManager) isServiceLoaded(servicePath string) (bool, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean by loaded?
Do you mean if the Service is activate? start? and why checking the file is good enough ?
pkg/service/service_manager.go
Outdated
} | ||
|
||
// DisableService disables service with systemctl disable and removes service file | ||
func (sm *serviceManager) DisableService(service *Service) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you using all the serviceManager apis? if not just keep the ones that you are currently use.
pkg/plugins/k8s/k8s_plugin.go
Outdated
|
||
if updateTarget.networkManager { | ||
nmService, err := serviceManager.ReadService(networkManagerService.Path) | ||
if err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
were is the ovs service?
66035f1
to
d6aebc4
Compare
pkg/plugins/k8s/k8s_plugin.go
Outdated
var ( | ||
Plugin K8sPlugin | ||
|
||
serviceManager service.ServiceManager |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alignment
pkg/plugins/k8s/k8s_plugin.go
Outdated
} | ||
|
||
const ( | ||
mcoManifestPath = "bindata/manifests/machine-config/" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let rename the folder to be bindata/manifests/switchdev-config/
and MCO andK8s both of them will use it.
pkg/plugins/k8s/k8s_plugin.go
Outdated
} | ||
} | ||
|
||
type McoServiceInjection struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove all the Mco prefix from all the struct as they are not releated to MCO
lifecycle: | ||
preStop: | ||
exec: | ||
command: ["/bin/sh","-c","rm -f /host/etc/systemd/system/switchdev-configuration.service"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not good enough. We should undo all the other changes
pkg/plugins/k8s/k8s_plugin.go
Outdated
} | ||
|
||
func updateService(serviceObj *service.Service) error { | ||
systemService, err := serviceManager.ReadService(serviceObj.Path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you will move the compare here you won't need to check if that service need update.
Just do it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updateService
is called from Apply
when there is change needed, the compare is running from OnNodeChange
which check if there is change needed to be applied
0880741
to
357bdb2
Compare
|
||
clean_services | ||
# Reload host services | ||
chroot $chroot_path /bin/bash -c systemctl daemon-reload > /dev/null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't you restart the ovs and NM services?
pkg/plugins/k8s/k8s_plugin.go
Outdated
updateList = append(updateList, "SwitchdevService") | ||
} | ||
if u.switchdevScript { | ||
updateList = append(updateList, "SwitchdevService") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be "switchdevScript"
pkg/plugins/k8s/k8s_plugin.go
Outdated
|
||
p.updateTarget.reset() | ||
// Check services | ||
err = p.isServicesNeedUpdate() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isServicesNeedUpdate should return bool not err
pkg/plugins/k8s/k8s_plugin.go
Outdated
return nil | ||
} | ||
|
||
func (p *K8sPlugin) readSystemServiceManifestFile(path string) (*service.Service, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should move to be in the function ServiceManager file like the compare services
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is reading from bindata/manifests/machine-config
and parsing the yaml file, I don't think this is related to ServiceManager
WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not? because it end with yaml? I think in the future when we will add services if any it will be in the same approach. Don't you think?
357bdb2
to
740b9bd
Compare
5cbf7bd
to
6a59056
Compare
pkg/plugins/k8s/k8s_plugin.go
Outdated
return nil | ||
} | ||
|
||
func (p *K8sPlugin) readManifestFiles() error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it better to read and inject for each service so network manager and ovs should have there own method.
so you have one method of NM and one for ovs which does the read and inject
pkg/plugins/k8s/k8s_plugin.go
Outdated
return []*service.Service{p.networkManagerService, p.openVSwitchService} | ||
} | ||
|
||
func (p *K8sPlugin) isSystemServiceNeedUpdate(serviceObj *service.Service) (bool, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let split the logic.
You should have isSystemServiceExist() to validate at start
and then isSystemServiceNeedUpdate can return just bool
6a59056
to
ee62864
Compare
} | ||
if p.updateTarget.needUpdate() { | ||
glog.Infof("k8s-plugin OnNodeStateChange(): needDrain to update %q", p.updateTarget) | ||
needDrain = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't you need reboot?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding the services doesn't require reboot
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but what about the VF rep udev rename? it won't be triggered ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is possible to add an additional condition to the udev renaming to do reboot, but the PR of renaming is not merged yet
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I don't follow why it better to do it in the udev PR and not here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume would be better because the udev is not merged yet, and when udev is merged we need to do another PR to support it for k8s_plugin
pkg/plugins/k8s/k8s_plugin.go
Outdated
return err | ||
} | ||
if !exist { | ||
continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if it not exist it a problem we should log error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if it not exist it means the NetworkManager or ovs is not installed on the host so a warning would serve better unless you consider them a pre-request, WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ovs is must not sure about the NM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So it would be better to split the logic to check if the service needs an update because there are mandatory and optional services
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let assume all of are mandatory ovs and NM
} | ||
if p.updateTarget.needUpdate() { | ||
glog.Infof("k8s-plugin OnNodeStateChange(): needDrain to update %q", p.updateTarget) | ||
needDrain = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I don't follow why it better to do it in the udev PR and not here?
pkg/utils/switchdev.go
Outdated
} | ||
update = true | ||
glog.V(2).Infof("WriteSwitchdevConfFile(): write %s to switchdev.conf", newContent) | ||
err = ioutil.WriteFile(switchDevConfPath, []byte(newContent), 0666) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this what the permission in the MCO commit. I think it better to change it to 644.
@zshi-redhat what do you thing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we only need this file be readable for users. mco/k8s plugins write the file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
b78287a
to
5c07954
Compare
/LGTM - Can you document the feature to advertise it? I am not sure where, features in readme? - Maybe we need a switchdev doc. |
@Mmduh-483 would you mind write a section in doc/ovs-hw-offload.md for using switchdev device on k8s? Thanks! |
5c07954
to
250c487
Compare
@moshe010 @zshi-redhat @martinkennelly added docs under |
host net-device. The VF representor plays the same role as TAP devices | ||
in Para-Virtual (PV) setup. A packet sent through the VF representor on the host | ||
arrives to the VF, and a packet sent through the VF is received by its representor. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should have prerequisites section:
- ovs installed
- Network Manager installed
250c487
to
e50e02f
Compare
e50e02f
to
2afad89
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@martinkennelly can you please take a look again. documentation was added
@zshi-redhat Can we merge this ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I read the code correctly, the k8s plugin will always try to update the systemd services even when switchdev is not configured. Did I miss anything?
lifecycle: | ||
preStop: | ||
exec: | ||
command: ["/bindata/scripts/clean-k8s-services.sh"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to always run this script when the daemonset pod is terminated? At least, I don't think we need it for openshift.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update the script to exist if CLUSTER_TYPE==openshift
2afad89
to
faf47f5
Compare
Updated to update services and swithdev config if policy is switchdev |
71a4f56
to
5cbd2d5
Compare
@Mmduh-483 Could you add more information to the commit description? This patch does more than just changing Eswitch mode. Also, I suggest adding a 'TODO' in the code, saying we will address the |
Add pkg/service which contain utils to read MCO files for switchdev services and scripts, this package is needed because vanilla Kubernetes doesn't have support MCO which is part of openshift Signed-off-by: Mamduh Alassi <[email protected]>
…config Avoid confusion by machine-config which is related to Openshift MCO Signed-off-by: Mamduh Alassi <[email protected]>
Openshift is handling switchdev by mco_plugin which uses Openshift MCO to handle the services, this commit introduce k8s_plugin which handle the same logic for vanilla Kubernetes that is missing MCO Signed-off-by: Mamduh Alassi <[email protected]>
Signed-off-by: Mamduh Alassi <[email protected]>
Updated the PR with separated commits with detailed commit description for each commit and the PR description |
This PR introduces new changes to support changing E-switch mode for vanilla Kubernetes