Skip to content

Commit

Permalink
Remove from StopSDN
Browse files Browse the repository at this point in the history
Related to lf-edge#855

Signed-off-by: Pavel Abramov <[email protected]>
  • Loading branch information
uncleDecart committed Oct 11, 2024
1 parent c22e8a7 commit eecc826
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion cmd/edenStop.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func newStopCmd(configName, verbosity *string) *cobra.Command {
registryRm, eServerRm,
cfg.Eve.Remote, cfg.Eve.Pid,
swtpmPidFile(cfg), cfg.Sdn.PidFile,
cfg.Eve.DevModel, vmName,
cfg.Eve.DevModel, vmName, cfg.Sdn.Disable,
)
},
}
Expand Down
20 changes: 10 additions & 10 deletions pkg/eden/eden.go
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ func MakeEveInRepo(desc utils.EVEDescription, dist string) (image, additional st
}

// CleanContext cleanup only context data
func CleanContext(eveDist, certsDist, imagesDist, evePID, eveUUID, sdnPID, vmName string, configSaved string, remote bool) (err error) {
func CleanContext(eveDist, certsDist, imagesDist, evePID, eveUUID, sdnPID, vmName string, configSaved string, remote, sdnDisable bool) (err error) {
edenDir, err := utils.DefaultEdenDir()
if err != nil {
return fmt.Errorf("CleanContext: %s", err)
Expand Down Expand Up @@ -828,7 +828,7 @@ func CleanContext(eveDist, certsDist, imagesDist, evePID, eveUUID, sdnPID, vmNam
log.Infof("swtpm is stopping")
}
}
StopSDN(devModel, sdnPID)
StopSDN(devModel, sdnPID, sdnDisable)
}
if _, err = os.Stat(eveDist); !os.IsNotExist(err) {
if err = os.RemoveAll(eveDist); err != nil {
Expand All @@ -855,7 +855,7 @@ func CleanContext(eveDist, certsDist, imagesDist, evePID, eveUUID, sdnPID, vmNam

// StopEden teardown Eden
func StopEden(adamRm, redisRm, registryRm, eserverRm, eveRemote bool,
evePidFile, swtpmPidFile, sdnPidFile, devModel, vmName string) {
evePidFile, swtpmPidFile, sdnPidFile, devModel, vmName string, sdnDisable bool) {
if err := StopAdam(adamRm); err != nil {
log.Infof("cannot stop adam: %s", err)
} else {
Expand All @@ -877,12 +877,12 @@ func StopEden(adamRm, redisRm, registryRm, eserverRm, eveRemote bool,
log.Infof("eserver stopped")
}
if !eveRemote {
StopEve(evePidFile, swtpmPidFile, sdnPidFile, devModel, vmName)
StopEve(evePidFile, swtpmPidFile, sdnPidFile, devModel, vmName, sdnDisable)
}
}

// StopEve stops EVE, vTPM and SDN.
func StopEve(evePidFile, swtpmPidFile, sdnPidFile, devModel, vmName string) {
func StopEve(evePidFile, swtpmPidFile, sdnPidFile, devModel, vmName string, sdnDisable bool) {
if devModel == defaults.DefaultVBoxModel {
if err := StopEVEVBox(vmName); err != nil {
log.Infof("cannot stop EVE: %s", err)
Expand Down Expand Up @@ -910,11 +910,11 @@ func StopEve(evePidFile, swtpmPidFile, sdnPidFile, devModel, vmName string) {
}
}
}
StopSDN(devModel, sdnPidFile)
StopSDN(devModel, sdnPidFile, sdnDisable)
}

func StopSDN(devModel, sdnPidFile string) {
if devModel != defaults.DefaultQemuModel || viper.GetBool("sdn.disable") {
func StopSDN(devModel, sdnPidFile string, sdnDisable bool) {
if devModel != defaults.DefaultQemuModel || sdnDisable {
// SDN is not running, nothing to do
return
}
Expand All @@ -937,11 +937,11 @@ func StopSDN(devModel, sdnPidFile string) {
// CleanEden teardown Eden and cleanup
func CleanEden(eveDist, adamDist, certsDist, imagesDist, eserverDist, redisDist,
registryDist, configDist, evePID, sdnPID, configSaved string, remote bool,
devModel, vmName string) (err error) {
devModel, vmName string, sdnDisable bool) (err error) {
command := "swtpm"
swtpmPidFile := filepath.Join(imagesDist, fmt.Sprintf("%s.pid", command))
StopEden(true, true, true, true, remote,
evePID, swtpmPidFile, sdnPID, devModel, vmName)
evePID, swtpmPidFile, sdnPID, devModel, vmName, sdnDisable)
if _, err = os.Stat(eveDist); !os.IsNotExist(err) {
if err = os.RemoveAll(eveDist); err != nil {
return fmt.Errorf("1 CleanEden: error in %s delete: %s", eveDist, err)
Expand Down
4 changes: 2 additions & 2 deletions pkg/openevec/eden.go
Original file line number Diff line number Diff line change
Expand Up @@ -513,13 +513,13 @@ func (openEVEC *OpenEVEC) EdenClean(configName, configDist, vmName string, curre
log.Infof("Adam is running and accessible on port %d", cfg.Adam.Port)
}
if err := eden.CleanContext(cfg.Eve.Dist, cfg.Eden.CertsDir, filepath.Dir(cfg.Eve.ImageFile), cfg.Eve.Pid, cfg.Eve.CertsUUID,
cfg.Sdn.PidFile, vmName, configSaved, cfg.Eve.Remote); err != nil {
cfg.Sdn.PidFile, vmName, configSaved, cfg.Eve.Remote, cfg.Sdn.Disable); err != nil {
return fmt.Errorf("cannot CleanContext: %w", err)
}
} else {
if err := eden.CleanEden(cfg.Eve.Dist, cfg.Adam.Dist, cfg.Eden.CertsDir, filepath.Dir(cfg.Eve.ImageFile),
cfg.Eden.Images.EServerImageDist, cfg.Redis.Dist, cfg.Registry.Dist, configDist, cfg.Eve.Pid,
cfg.Sdn.PidFile, configSaved, cfg.Eve.Remote, cfg.Eve.DevModel, vmName); err != nil {
cfg.Sdn.PidFile, configSaved, cfg.Eve.Remote, cfg.Eve.DevModel, vmName, cfg.Sdn.Disable); err != nil {
return fmt.Errorf("cannot CleanEden: %w", err)
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/openevec/eve.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ func (openEVEC *OpenEVEC) StopEve(vmName string) error {
}
}
}
eden.StopSDN(cfg.Eve.DevModel, cfg.Sdn.PidFile)
eden.StopSDN(cfg.Eve.DevModel, cfg.Sdn.PidFile, cfg.Sdn.Disable)
return nil
}

Expand Down

0 comments on commit eecc826

Please sign in to comment.