Skip to content

Commit a1a6633

Browse files
plamenmpetrovamohoste
authored andcommitted
Altered buildVMConfiguration tests
Signed-off-by: Plamen Petrov <[email protected]>
1 parent 6279f94 commit a1a6633

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

firecracker-control/local.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,4 +688,3 @@ func (s *local) Offload(ctx context.Context, req *proto.OffloadRequest) (*empty.
688688

689689
return resp, nil
690690
}
691-

runtime/service.go

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@ type service struct {
163163
fifosMu sync.Mutex
164164

165165
// httpControlClient is to send pause/resume/snapshot commands to the microVM
166-
httpControlClient *http.Client
167-
firecrackerPid int
166+
httpControlClient *http.Client
167+
firecrackerPid int
168168
taskDrivePathOnHost string
169169
}
170170

@@ -503,7 +503,7 @@ func (s *service) CreateVM(requestCtx context.Context, request *proto.CreateVMRe
503503
s.logger.WithError(err).Error("failed to publish start VM event")
504504
}
505505

506-
// Commented out because its execution cancels the shim, and
506+
// Commented out because its execution cancels the shim, and
507507
// it would get executed on Offload if we leave it, killing the shim,
508508
// and making snapshots impossible.
509509
//go s.monitorVMExit()
@@ -635,12 +635,14 @@ func (s *service) createVM(requestCtx context.Context, request *proto.CreateVMRe
635635

636636
s.createHTTPControlClient()
637637

638-
if pid, err := s.machine.PID(); err != nil {
638+
pid, err := s.machine.PID()
639+
if err != nil {
639640
s.logger.WithError(err).Error("Failed to get PID of firecracker process")
640641
return err
641-
} else {
642-
s.firecrackerPid = pid
643642
}
643+
644+
s.firecrackerPid = pid
645+
644646
s.logger.Info("successfully started the VM")
645647

646648
return nil
@@ -1713,6 +1715,8 @@ func (s *service) cleanup() error {
17131715
}
17141716

17151717
// monitorVMExit watches the VM and cleanup resources when it terminates.
1718+
// Comment out because unused
1719+
/*
17161720
func (s *service) monitorVMExit() {
17171721
// Block until the VM exits
17181722
if err := s.machine.Wait(s.shimCtx); err != nil && err != context.Canceled {
@@ -1723,6 +1727,7 @@ func (s *service) monitorVMExit() {
17231727
s.logger.WithError(err).Error("failed to clean up the VM")
17241728
}
17251729
}
1730+
*/
17261731

17271732
func (s *service) createHTTPControlClient() {
17281733
u := &httpunix.Transport{
@@ -1837,20 +1842,20 @@ func formCreateSnapReq(snapshotPath, memPath string) (*http.Request, error) {
18371842
return req, nil
18381843
}
18391844

1840-
func formPatchDriveReq(drive_id, path_on_host string) (*http.Request, error) {
1845+
func formPatchDriveReq(driveID, pathOnHost string) (*http.Request, error) {
18411846
var req *http.Request
18421847

18431848
data := map[string]string{
1844-
"drive_id": drive_id,
1845-
"path_on_host": path_on_host,
1849+
"drive_id": driveID,
1850+
"path_on_host": pathOnHost,
18461851
}
18471852
json, err := json.Marshal(data)
18481853
if err != nil {
18491854
logrus.WithError(err).Error("Failed to marshal json data")
18501855
return nil, err
18511856
}
18521857

1853-
req, err = http.NewRequest("PATCH", fmt.Sprintf("http+unix://firecracker/drives/%s", drive_id), bytes.NewBuffer(json))
1858+
req, err = http.NewRequest("PATCH", fmt.Sprintf("http+unix://firecracker/drives/%s", driveID), bytes.NewBuffer(json))
18541859
if err != nil {
18551860
logrus.WithError(err).Error("Failed to create new HTTP request in formPauseReq")
18561861
return nil, err
@@ -1869,14 +1874,13 @@ func (s *service) startFirecrackerProcess() error {
18691874
return err
18701875
}
18711876

1872-
18731877
// TODO: Remove hardcoding and make a parameter
18741878
logFilePath := fmt.Sprintf("/tmp/log_%s_after.logs", s.vmID)
18751879
if err := os.RemoveAll(logFilePath); err != nil {
18761880
s.logger.WithError(err).Errorf("Failed to delete %s", logFilePath)
18771881
return err
18781882
}
1879-
if _, err := os.OpenFile(logFilePath, os.O_RDONLY|os.O_CREATE, 0666); err != nil {
1883+
if _, err := os.OpenFile(logFilePath, os.O_RDONLY|os.O_CREATE, 0600); err != nil {
18801884
s.logger.WithError(err).Errorf("Failed to create %s", logFilePath)
18811885
return err
18821886
}

0 commit comments

Comments
 (0)