-
Notifications
You must be signed in to change notification settings - Fork 47
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
feat: read architecture specific common templates file #1156
feat: read architecture specific common templates file #1156
Conversation
9b4849c
to
50f7390
Compare
internal/template-bundle/bundle.go
Outdated
archDependentFileName := filepath.Join(templateBundleDir, commonTemplatesFilePrefix+runtime.GOARCH+"-"+common_templates.Version+commonTemplatesFileSuffix) | ||
archIndependentFileName := filepath.Join(templateBundleDir, commonTemplatesFilePrefix+common_templates.Version+commonTemplatesFileSuffix) |
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.
The string concatenation is a little confusing here. Can you use fmt.Sprintf()
? The format string could be:
common-templates-%s-%s.yaml`
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.
Done
internal/template-bundle/bundle.go
Outdated
func RetrieveCommonTemplatesBundleFile(templateBundleDir string) (string, error) { | ||
archDependentFileName := filepath.Join(templateBundleDir, commonTemplatesFilePrefix+runtime.GOARCH+"-"+common_templates.Version+commonTemplatesFileSuffix) | ||
archIndependentFileName := filepath.Join(templateBundleDir, commonTemplatesFilePrefix+common_templates.Version+commonTemplatesFileSuffix) | ||
commonTemplatesExistingFiles := filterExistingTemplateFiles([]string{archDependentFileName, archIndependentFileName}) |
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.
Can you simplify this by not using a filter function? IMHO directly checking if the 2 files exists is more readable.
if _, err := os.Stat(archDependentFileName); err == nil {
return archDependentFileName, nil
}
if _, err := os.Stat(archIndependentFileName); err == nil {
return archIndependentFileName, nil
}
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.
Done
_, filename, _, ok := runtime.Caller(0) | ||
Expect(ok).To(BeTrue()) | ||
fileAbsolutePath, err := filepath.Abs(filename) | ||
Expect(err).NotTo(HaveOccurred()) | ||
testDir = filepath.Dir(fileAbsolutePath) |
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.
Instead of reading files from the repo, can you create them in a temp directory when the test starts?
Ginkgo can create the directory for you:
tmpDir := GinkgoT().TempDir()
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.
Nice idea, thanks for pointing that 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.
Please don't commit these empty files into the repo.
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.
Done
2cc78b0
to
0532aea
Compare
/retest |
0532aea
to
10ab46a
Compare
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: akrejcir The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@nestoracunablanco |
Hello @dominikholler, Thank you for reaching out. Regarding your questions:
Looking ahead, here are some ideas to address the lack of multi-architecture worker node support (though they may not be fully feasible):
In my opinion, enabling multi-architecture worker nodes would require a design change that necessitates consensus. |
On Thu, 05 Dec 2024 02:02:48 -0800 Nestor Acuna Blanco ***@***.***> wrote:
Hello @dominikholler,
Thank you for reaching out. Regarding your questions:
1. _Are you aware that this change might limit the usage of templates in clusters with worker nodes of multiple architectures?_
- The assumption is not that the node running the same architecture as the SSP operator will have the same architecture as the nodes running the VMs. However, it is true that multi-architecture support is currently not available and would require significant design changes. With the existing design (which works well for amd64), the SSP operator attempts to import the data volumes even if they are not enabled for the host architecture (for example, Windows or OpenSUSE on s390x).
As mentioned more detailed below, the import of the DataImportCrons
respects the architecture if possible.
To enhance the user experience for s390x, these options are not
presented.
I do not understand. If the containerdisk imported by a DataImportCron
contains s390x, and the containerdisk is referring to the s390x
preference
(kubevirt/common-instancetypes#290), wouldn't the OpenShift UI create a working VM from the related golden base image?
Are you looking for a way to prevent importing DataImportCrons which
does not support the architecture of the node?
For amd64, this change is completely transparent. In the case of s390x, end users can clone a template and modify it according to their needs (in case they want to run amd64 workloads).
2. _Does this mean you prefer to adopt the volume (instance types/preferences) approach for clusters using worker nodes of mixed architectures?_
- I do not have a personal opinion on this matter. My primary focus is to enable the existing features for the s390x architecture.
I see.
Looking ahead, here are some ideas to address the lack of multi-architecture worker node support (though they may not be fully feasible):
- Load the templates based on the available architectures across all nodes.
Sounds interesting. What do you mean by "load" here, maybe showing
them in the UI?
- Import the data volumes selectively.
If all worker nodes have the same architecture, this should be already
done. You are welcome to chime in
on https://issues.redhat.com/browse/CNV-52175?focusedId=26209275&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-26209275
… In my opinion, enabling multi-architecture worker nodes would require a design change that necessitates consensus.
|
Yes, if the container disk includes s390x, that is not an issue. However, some Linux distributions do not support s390x, and Windows does not either. In my opinion, it could be inconvenient (or even a bug) for users if we present features they cannot utilize, such as starting Windows or openSUSE VMs that are incompatible with s390x.
For example, as long as the user is not presented with any "misleading" indicators, this can be addressed at the UI level, be filtered by the SSP operator, etc. etc. etc. |
@0xFelix , can you please take a look? |
archIndependentFile = tmpDir + fmt.Sprintf("/common-templates-%s.yaml", common_templates.Version) | ||
archDependentFile = tmpDir + fmt.Sprintf("/common-templates-%s-%s.yaml", runtime.GOARCH, common_templates.Version) |
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.
Use filepath.Join
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.
Done
|
||
It("should throw an error retrieving the bundle file", func() { | ||
_, err := RetrieveCommonTemplatesBundleFile(tmpDir) | ||
Expect(err.Error()).To(ContainSubstring("failed to find common-templates bundles, none of the files were found")) |
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.
Expect(err.Error()).To(ContainSubstring("failed to find common-templates bundles, none of the files were found")) | |
Expect(err).To(MatchError(ContainSubstring("failed to find common-templates bundles, none of the files were found"))) |
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.
Done
This change prepares for architecture-specific delivery. The logic will first attempt to locate the architecture-specific common templates bundle. If it is not found, it will then fall back to the generic bundle. Signed-off-by: Nestor Acuna Blanco <nestor.acuna@ibm.com>
10ab46a
to
ca7e46f
Compare
Quality Gate passedIssues Measures |
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.
/lgtm
This change prepares for architecture-specific delivery. The logic will first attempt to locate the architecture-specific common templates bundle. If it is not found, it will then fall back to the generic bundle.
What this PR does / why we need it: s390x enablement
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Release note: