Skip to content

Commit

Permalink
Remove deployment of old switchdev implementation
Browse files Browse the repository at this point in the history
This commit removes services and scripts related
to old switchdev implementations

Signed-off-by: Yury Kulazhenkov <[email protected]>
  • Loading branch information
ykulazhenkov committed Feb 27, 2024
1 parent ef46574 commit 3037cee
Show file tree
Hide file tree
Showing 16 changed files with 182 additions and 767 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

12 changes: 0 additions & 12 deletions bindata/manifests/switchdev-config/machineconfigpool.yaml

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

34 changes: 5 additions & 29 deletions bindata/scripts/clean-k8s-services.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,12 @@ fi

chroot_path="/host"

function clean_services() {
# Remove switchdev service files
rm -f $chroot_path/etc/systemd/system/switchdev-configuration-after-nm.service
rm -f $chroot_path/etc/systemd/system/switchdev-configuration-before-nm.service
rm -f $chroot_path/usr/local/bin/switchdev-configuration-after-nm.sh
rm -f $chroot_path/usr/local/bin/switchdev-configuration-before-nm.sh
rm -f $chroot_path/etc/switchdev.conf
rm -f $chroot_path/etc/udev/switchdev-vf-link-name.sh
# The following files are no longer created by config daemon
# Remove them in case of leftovers from earlier SR-IOV network operator
rm -f $chroot_path/usr/local/bin/configure-switchdev.sh
rm -f $chroot_path/etc/systemd/system/switchdev-configuration.service

# clean NetworkManager and ovs-vswitchd services
network_manager_service=$chroot_path/usr/lib/systemd/system/NetworkManager.service
ovs_service=$chroot_path/usr/lib/systemd/system/ovs-vswitchd.service
ovs_service=$chroot_path/usr/lib/systemd/system/ovs-vswitchd.service

if [ -f $network_manager_service ]; then
sed -i.bak '/switchdev-configuration.service/d' $network_manager_service
fi

if [ -f $ovs_service ]; then
if [ -f $ovs_service ]; then
if grep -q hw-offload $ovs_service; then
sed -i.bak '/hw-offload/d' $ovs_service
chroot $chroot_path /bin/bash -c systemctl daemon-reload >/dev/null 2>&1 || true
fi
}

clean_services
# Reload host services
chroot $chroot_path /bin/bash -c systemctl daemon-reload >/dev/null 2>&1 || true

# Restart system services
chroot $chroot_path /bin/bash -c systemctl restart NetworkManager.service >/dev/null 2>&1 || true
chroot $chroot_path /bin/bash -c systemctl restart ovs-vswitchd.service >/dev/null 2>&1 || true
fi
36 changes: 0 additions & 36 deletions pkg/helper/mock/mock_helper.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 1 addition & 47 deletions pkg/host/internal/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (s *service) EnableService(service *types.Service) error {
return err
}

// CompareServices compare 2 service and return true if serviceA has all the fields of serviceB
// CompareServices returns true if serviceA needs update(doesn't contain all fields from service B)
func (s *service) CompareServices(serviceA, serviceB *types.Service) (bool, error) {
optsA, err := unit.Deserialize(strings.NewReader(serviceA.Content))
if err != nil {
Expand All @@ -127,37 +127,6 @@ OUTER:
return false, nil
}

// RemoveFromService removes given fields from service
func (s *service) RemoveFromService(service *types.Service, options ...*unit.UnitOption) (*types.Service, error) {
opts, err := unit.Deserialize(strings.NewReader(service.Content))
if err != nil {
return nil, err
}

var newServiceOptions []*unit.UnitOption
OUTER:
for _, opt := range opts {
for _, optRemove := range options {
if opt.Match(optRemove) {
continue OUTER
}
}

newServiceOptions = append(newServiceOptions, opt)
}

data, err := io.ReadAll(unit.Serialize(newServiceOptions))
if err != nil {
return nil, err
}

return &types.Service{
Name: service.Name,
Path: service.Path,
Content: string(data),
}, nil
}

// ReadServiceInjectionManifestFile reads service injection file
func (s *service) ReadServiceInjectionManifestFile(path string) (*types.Service, error) {
data, err := os.ReadFile(path)
Expand Down Expand Up @@ -196,21 +165,6 @@ func (s *service) ReadServiceManifestFile(path string) (*types.Service, error) {
}, nil
}

// ReadScriptManifestFile reads script file
func (s *service) ReadScriptManifestFile(path string) (*types.ScriptManifestFile, error) {
data, err := os.ReadFile(path)
if err != nil {
return nil, err
}

var scriptFile *types.ScriptManifestFile
if err := yaml.Unmarshal(data, &scriptFile); err != nil {
return nil, err
}

return scriptFile, nil
}

func (s *service) UpdateSystemService(serviceObj *types.Service) error {
systemService, err := s.ReadService(serviceObj.Path)
if err != nil {
Expand Down
Loading

0 comments on commit 3037cee

Please sign in to comment.