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

Add OVA provider and inventory #419

Merged
merged 2 commits into from
Jul 23, 2023
Merged

Add OVA provider and inventory #419

merged 2 commits into from
Jul 23, 2023

Conversation

bkhizgiy
Copy link
Member

@bkhizgiy bkhizgiy commented Jul 3, 2023

Adding new OVA type provider, once the provider is added a new OVA-server deployment will be applied, the controller will query the new server pod and build the provider inventory based on the info that will be provided by it.

Copy link
Member

@nyoxi nyoxi left a comment

Choose a reason for hiding this comment

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

Preliminary comments.

Makefile Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
Makefile Outdated
@@ -279,7 +288,8 @@ push-all-images: push-api-image \
push-operator-index-image \
push-populator-controller-image \
push-ovirt-populator-image \
push-openstack-populator-image
push-openstack-populator-image\
push-ova-parses-image

.PHONY: check_container_runtmime
Copy link
Member

Choose a reason for hiding this comment

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

Not related to the patch but I see we have a typo in the word "runtime" here.

if err != nil {
fmt.Println("Error extracting OVF from OVA:", err)
continue
}
Copy link
Member

Choose a reason for hiding this comment

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

I suggest using defer os.RemoveAll(tmpDir) here instead calling it separately below. Either way you may want to log the error from os.RemoveAll.

Copy link
Member

@ahadas ahadas Jul 10, 2023

Choose a reason for hiding this comment

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

yeah and we should also check if we really need to extract the file to a temporary directory, it should be possible to read the content of the OVF directly from the OVA (found this)

Copy link
Member

Choose a reason for hiding this comment

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

Using a library is probably preferable if it can be used easily. But you can also tell tar to dump the file to stdout with -O/--to-stdout. But you also need to call tar multiple times -- first to list the files and then get the output. (Just saying.)

Copy link
Member

Choose a reason for hiding this comment

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

But you also need to call tar multiple times -- first to list the files and then get the output. (Just saying.)

according to the OVF specification, the OVF descriptor should always be the first entry ("The ordering restriction ensures that it is possible to extract the OVF descriptor from a compressed OVF package without scanning the entire archive. ")

Copy link
Member

Choose a reason for hiding this comment

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

In theory yes. In reality there are plenty of hand crafted OVAs not following the specs. Some of which are not even TAR files (are e.g. ZIP files). And it's fine to discard those as not supported. But you don't want such files to cause you troubles.

Specifically in this context, if you just run tar xOf somethig.ova --wildcards '*.ovf' and the archive contains multiple OVF files you will end up with their content concatenated together which will confuse the XML parser and produce bogus errors. That's what I meant.

cmd/ova-parser/ova-parser.go Outdated Show resolved Hide resolved
cmd/ova-parser/ova-parser.go Outdated Show resolved Hide resolved
cmd/ova-parser/ova-parser.go Outdated Show resolved Hide resolved
@@ -0,0 +1,10 @@
FROM registry.access.redhat.com/ubi8/go-toolset:1.18.9-8 as builder
Copy link
Member

Choose a reason for hiding this comment

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

It would be cleaner if we created a separate directory for the Container files naming them e.g. ova-parser.Containerfile and leave the hack directory only for support scripts.

pkg/controller/provider/controller.go Outdated Show resolved Hide resolved
Copy link
Member

@ahadas ahadas left a comment

Choose a reason for hiding this comment

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

looks like a good starting point

Makefile Outdated Show resolved Hide resolved
http.HandleFunc("/networks", networkHandler)
http.HandleFunc("/watch", watchdHandler)

http.ListenAndServe(":8080", nil)
Copy link
Member

Choose a reason for hiding this comment

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

how about separating out the other parts to a different file and renaming this one to ova-data-server.go?

if err != nil {
fmt.Println("Error extracting OVF from OVA:", err)
continue
}
Copy link
Member

@ahadas ahadas Jul 10, 2023

Choose a reason for hiding this comment

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

yeah and we should also check if we really need to extract the file to a temporary directory, it should be possible to read the content of the OVF directly from the OVA (found this)

cmd/ova-parser/ova-parser.go Outdated Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

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

we used Container files for populators that were hard to build with bazel, I guess that was the reference for this, right? it should be easy to build this with bazel instead

pkg/controller/provider/controller.go Outdated Show resolved Hide resolved
pkg/controller/provider/model/ova/doc.go Show resolved Hide resolved
@bkhizgiy bkhizgiy requested a review from mnecas as a code owner July 16, 2023 20:15

// Tree.
func (h TreeHandler) Tree(ctx *gin.Context) {
// status := h.Prepare(ctx)
Copy link
Member Author

Choose a reason for hiding this comment

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

need to be modified for the UI.

@bkhizgiy bkhizgiy changed the title WIP: adding initial support for OVA migration Add OVA provider and inventory Jul 16, 2023
Copy link
Member

@ahadas ahadas left a comment

Choose a reason for hiding this comment

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

partial review

pkg/controller/map/storage/handler/ova/handler.go Outdated Show resolved Hide resolved
pkg/controller/map/storage/handler/ova/handler.go Outdated Show resolved Hide resolved
pkg/controller/provider/container/ova/client.go Outdated Show resolved Hide resolved
pkg/controller/provider/container/ova/watch.go Outdated Show resolved Hide resolved
pkg/controller/provider/controller.go Outdated Show resolved Hide resolved
pkg/controller/provider/controller.go Outdated Show resolved Hide resolved
pkg/controller/provider/controller.go Outdated Show resolved Hide resolved
pkg/controller/provider/controller.go Outdated Show resolved Hide resolved
pkg/controller/provider/controller.go Outdated Show resolved Hide resolved
pkg/controller/provider/controller.go Outdated Show resolved Hide resolved
pkg/controller/provider/model/ova/model.go Outdated Show resolved Hide resolved
pkg/controller/provider/model/ova/model.go Outdated Show resolved Hide resolved
pkg/controller/provider/validation.go Show resolved Hide resolved
pkg/controller/provider/container/ova/client.go Outdated Show resolved Hide resolved
pkg/controller/provider/controller.go Outdated Show resolved Hide resolved
pkg/controller/provider/controller.go Outdated Show resolved Hide resolved
pkg/controller/provider/controller.go Outdated Show resolved Hide resolved
pkg/controller/provider/controller.go Outdated Show resolved Hide resolved
pkg/controller/provider/validation.go Outdated Show resolved Hide resolved
Copy link
Member

@ahadas ahadas left a comment

Choose a reason for hiding this comment

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

complete review

pkg/controller/provider/validation.go Outdated Show resolved Hide resolved
pkg/controller/provider/controller.go Outdated Show resolved Hide resolved
pkg/controller/provider/controller.go Outdated Show resolved Hide resolved
pkg/controller/provider/controller.go Show resolved Hide resolved
pkg/controller/provider/model/ova/model.go Outdated Show resolved Hide resolved
Copy link
Member

@ahadas ahadas left a comment

Choose a reason for hiding this comment

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

looks good, just two minor comments
@bkhizgiy was it verified with #439 ?

pkg/controller/provider/controller.go Outdated Show resolved Hide resolved
pkg/controller/provider/controller.go Outdated Show resolved Hide resolved
@ahadas ahadas requested review from nyoxi and bennyz July 19, 2023 14:10
Copy link
Member

@ahadas ahadas left a comment

Choose a reason for hiding this comment

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

adding comments from sonarcloud

pkg/controller/provider/container/ova/model.go Outdated Show resolved Hide resolved
pkg/controller/provider/web/ova/workload.go Outdated Show resolved Hide resolved
bkhizgiy and others added 2 commits July 23, 2023 16:23
1. Remove unused empty function WorkloadHandler#List
2. Reduce Cognitive Complexity of ProviderHandler#ListContent

Signed-off-by: Arik Hadas <[email protected]>
@sonarcloud
Copy link

sonarcloud bot commented Jul 23, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 3 Code Smells

No Coverage information No Coverage information
4.5% 4.5% Duplication

@ahadas ahadas merged commit 3f2bcd5 into kubev2v:main Jul 23, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants