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

support for driver specific pid files #1171

Merged
merged 1 commit into from
Nov 18, 2022
Merged

Conversation

balajiv113
Copy link
Member

This PR resolves this discussion
#1147 (comment)

@balajiv113
Copy link
Member Author

Info,
Have add DriverPIDName to info() API of hostagent.

This made a lot of sense as hostagent is the one starting and managing the driver. And store is not required to know about it. Even though it can.

@AkihiroSuda AkihiroSuda added this to the v0.14 milestone Nov 17, 2022
@@ -12,6 +12,8 @@ type Driver interface {

CreateDisk() error

GetPIDName() string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
GetPIDName() string
Name() string

The pid file name can be just Name() + ".pid"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah nice !! This looks more clean.

Done the changes

pkg/qemu/qemu.go Outdated
@@ -31,6 +31,7 @@ type Config struct {
Name string
InstanceDir string
LimaYAML *limayaml.LimaYAML
Driver *LimaQemuDriver
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this change the whole Config struct becomes redundant because all other fields are just copies from the Driver struct.

Would it make sense to get rid of Config and just pass around Driver instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, will adapt this change as well.

I was in a confusion of whether to do / not as we will update all those config stuff :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not properly thought this through; it just occurred to me that there was no additional information in Config beyond what is already in Driver. In general I would try to avoid keeping the same data in multiple places because then it can get out of sync, and hard to debug...

Maybe wait for feedback from @AkihiroSuda before making this change?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this Driver addition is just for getting the driver name, can we just get the driver name from the yaml?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could, but what is the reason for having a separate Config struct? The base Driver is just pointers to instance data and YAML:

type BaseDriver struct {
	Instance *store.Instance
	Yaml     *limayaml.LimaYAML
}

@@ -1,5 +1,6 @@
package api

type Info struct {
SSHLocalPort int `json:"sshLocalPort,omitempty"`
SSHLocalPort int `json:"sshLocalPort,omitempty"`
DriverName string `json:"driverName,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Can we eliminate this from the Info? Just like CPU nums, arch, memory, etc.
  • If we really can't remove this, this should be named like vmType or vmDriverName, as we also have a bunch of other "drivers" such as mount driver, network driver, etc.
  • We can also consider marshaling the entire YAML as a JSON here if we are going to copy other YAML properties too here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • As drivers are already relying on store, the moment we rely on driver it will have this cyclic import problem. We can look into resolving it as well.
  • If am not able to resolve the above issue i will look into moving other properties to rely on this info endpoint itself by YAML to JSON conversion in info endopoint, so that store will simply depend on hostagent info and not assume anything directly from configuration

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AkihiroSuda
One way i could think of solving it is, our pid names can always be equal to vmType. This way, in instance.Inspect() we can simply rely on vmType to get according pid.

But we could also argue that with this assumption we don't even need Name() in driver interface :)

Let me know if this is fine. In that case, i will maybe get rid of Name itself fully from driver and go with vmType itself.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

go with vmType itself

👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done the changes

Signed-off-by: Balaji Vijayakumar <kuttibalaji.v6@gmail.com>
Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@AkihiroSuda AkihiroSuda merged commit cd504a4 into lima-vm:master Nov 18, 2022
@balajiv113 balajiv113 deleted the pid branch November 23, 2023 05:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants