-
Notifications
You must be signed in to change notification settings - Fork 68
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
Integrating Simulacra with Diagnostic Tool Output #1363
Integrating Simulacra with Diagnostic Tool Output #1363
Conversation
integration_test/gce/gce_testing.go
Outdated
func getImageFamilyName(image string) string { | ||
if isFullImageName(image) { | ||
components := strings.Split(image, "/") | ||
return components[len(components)-1] |
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 the last component of the array is the image family name? I thought that was the image name itself
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.
okay this was definitely poor naming on my part,
this function essentially does 2 things : it either gets the image name if prefix "/project" is in the string OR it gets family name if that prefix is not there.
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.
could I get an example of what image
looks like in a case where it starts with projects/
?
I have a feeling that you will need to specify options.ImageProject in cases like 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.
Yep! So this is what the image looks like most of the time coming from the metadata file : " projects/debian-cloud/global/images/debian-11-bullseye-v20230711"
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.
OK so yeah the "debian-cloud" part should get passed in as options.ImageProject. The "global" part should probably get passed in to --image-family-scope, though there's no VMOptions for that yet.
I think we should parse this string projects/debian-cloud/global/images/debian-11-bullseye-v20230711
in simulacra.go, adding some things to VMOptions in the process:
- a TODO to rename VMOptions.Platform -> ImageFamily (overdue)
- VMOptions.Image: an alternative to VMOptions.Platform
- VMOptons.ImageFamilyScope: doesn't seem very important, but it's probably technically correct to include it. It's kind of described here: https://screenshot.googleplex.com/BEPtcVek32VbZnr
Then we'd need to change some things at the start of attemptCreateInstance() to:
- check that one of VMOptions.Platform and VMOptions.Image are specified, not 0 or 2 of them
- put the nonempty one into VM.Platform (similar to today, vm.Platform would continue to hold either an image family or a specific image),
- change the code that computes imageOrImageFamilyFlag to look at the VMOptions fields instead of VM.Platform
- add some code to turn VMOptions.ImageFamilyScope into --image-family-scope.
In addition, I think you'd need some light modifications to simulacra.go:
- new fields in Config called Image and ImageProject, I guess ImageFamilyScope too
- some code around here to parse metadata.image into Image/ImageProject/ImageFamilyScope: https://screenshot.googleplex.com/7MVkQHDG6AUV6oK
sorry to ask for relatively big changes. I think it's important to make gce_testing.go as "dumb" as we can and avoid smuggling features into it if we can.
Happy to discuss and/or help out.
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 a great idea! I'm working on implementing these rn, thank you for describing it in such details
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.
Hey @martijnvans , I have made all the suggested changes with the exception of renaming Platform in VMOption to 'ImageFamily.'
Since other files use that field name, it would be a big change for this PR.
I have created a task https://buganizer.corp.google.com/issues/295174028 and assigned it to myself to make that change in a seperate PR.
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.
Thanks! I left a comment about a suggested 3-step approach.
integration_test/gce/gce_testing.go
Outdated
func getImageFamilyName(image string) string { | ||
if isFullImageName(image) { | ||
components := strings.Split(image, "/") | ||
return components[len(components)-1] |
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.
could I get an example of what image
looks like in a case where it starts with projects/
?
I have a feeling that you will need to specify options.ImageProject in cases like this...
integration_test/gce/gce_testing.go
Outdated
// attemptCreateInstance creates a VM instance and waits for it to be ready. | ||
// Returns a VM object or an error (never both). The caller is responsible for | ||
// deleting the VM if (and only if) the returned error is nil. | ||
func attemptCreateInstance(ctx context.Context, logger *log.Logger, options VMOptions) (vmToReturn *VM, errToReturn error) { | ||
vm := &VM{ | ||
Project: options.Project, | ||
Platform: options.Platform, | ||
Platform: getImageFamilyName(options.Platform), |
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 would prefer keeping this line as is (Platform: options.Platform), and doing something like this down below (line 1130ish):
if isFullImageName(options.Platform) {
components := strings.Split(options.Platform, "/")
imageOrImageFamilyFlag = "--image=" + components[len(components)-1]
// maybe parse out the image project too? if so, this chunk and lines 1124-1127 should move up above line 1107. Unless I'm misunderstanding and the image project isn't part of this string in the first place.
}
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 if we did this, it would become inconsistent throughout the rest of the function. The vm.Platform value would be like this : " projects/debian-cloud/global/images/debian-11-bullseye-v20230711". Then in line 1213/1227/1246, we would get a runtime error because they are expecting the vm.platform value to be just the image family name but instead it's that weird format from the metadata output. This is why i think we need to set vm.Platform to the image family name when we create the vm struct from the options input.
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.
true true. I thought about this a lot, see my other comment.
8f7eb4a
to
a7ce7dd
Compare
integration_test/gce/gce_testing.go
Outdated
func getImageFamilyName(image string) string { | ||
if isFullImageName(image) { | ||
components := strings.Split(image, "/") | ||
return components[len(components)-1] |
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.
OK so yeah the "debian-cloud" part should get passed in as options.ImageProject. The "global" part should probably get passed in to --image-family-scope, though there's no VMOptions for that yet.
I think we should parse this string projects/debian-cloud/global/images/debian-11-bullseye-v20230711
in simulacra.go, adding some things to VMOptions in the process:
- a TODO to rename VMOptions.Platform -> ImageFamily (overdue)
- VMOptions.Image: an alternative to VMOptions.Platform
- VMOptons.ImageFamilyScope: doesn't seem very important, but it's probably technically correct to include it. It's kind of described here: https://screenshot.googleplex.com/BEPtcVek32VbZnr
Then we'd need to change some things at the start of attemptCreateInstance() to:
- check that one of VMOptions.Platform and VMOptions.Image are specified, not 0 or 2 of them
- put the nonempty one into VM.Platform (similar to today, vm.Platform would continue to hold either an image family or a specific image),
- change the code that computes imageOrImageFamilyFlag to look at the VMOptions fields instead of VM.Platform
- add some code to turn VMOptions.ImageFamilyScope into --image-family-scope.
In addition, I think you'd need some light modifications to simulacra.go:
- new fields in Config called Image and ImageProject, I guess ImageFamilyScope too
- some code around here to parse metadata.image into Image/ImageProject/ImageFamilyScope: https://screenshot.googleplex.com/7MVkQHDG6AUV6oK
sorry to ask for relatively big changes. I think it's important to make gce_testing.go as "dumb" as we can and avoid smuggling features into it if we can.
Happy to discuss and/or help out.
integration_test/gce/gce_testing.go
Outdated
// attemptCreateInstance creates a VM instance and waits for it to be ready. | ||
// Returns a VM object or an error (never both). The caller is responsible for | ||
// deleting the VM if (and only if) the returned error is nil. | ||
func attemptCreateInstance(ctx context.Context, logger *log.Logger, options VMOptions) (vmToReturn *VM, errToReturn error) { | ||
vm := &VM{ | ||
Project: options.Project, | ||
Platform: options.Platform, | ||
Platform: getImageFamilyName(options.Platform), |
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.
true true. I thought about this a lot, see my other comment.
@@ -204,9 +217,61 @@ func getConfigFromYaml(configPath string) (*Config, error) { | |||
return &config, nil | |||
} | |||
|
|||
// Parse the metadata image name with format 'projects/debian-cloud/global/images/debian-11-bullseye-v20230711' |
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.
How certain are we that the image will always be in this format? Have we looked at any custom images to make sure they follow this format too?
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.
Discussed offline. What we ended up doing was if the image name in the metadata file does not have the prefix "/projects", then we ask the user (using command line input) for the image family.
Co-authored-by: Braydon Kains <[email protected]>
Co-authored-by: Braydon Kains <[email protected]>
Description
We don’t want the Ops Agent on-call team to manually have to create this configuration file. Currently, we have a diagnostic tool that our customers run whenever their Ops Agent is not behaving accordingly. The diagnostic tool collects various information about the customer's environment and outputs it into different files.
We can integrate the diagnostic tool with Simulacra so that the Simulacra configuration file can be automatically created from the information that the diagnostic tool generates. This would automate the process of manually creating Simulacra config files.
This PR adds support in Simulacra for reading diagnostic tool output and configuring itself from that output.
How has this been tested?
Used a diagnostic tool output and passed it to Simulacra. It created the VM correctly.
Checklist: