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

Libvirt test create network and storage #1306

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

bookinabox
Copy link
Contributor

Relies on: #1244

Creates temporary network and storage if the provided libvirt_network and/or libvirt_storage are not networks/storage pools that are currently enabled.

Destroys network and storage on DeleteVPC (which is triggered when provisioning and teardown are both enabled)

@bookinabox
Copy link
Contributor Author

I am thinking of changing how the storage works. The pool type is a directory pool, so I created a directory in /tmp. While the pool itself is destroyed, the directory is not.

@bookinabox bookinabox force-pushed the libvirt-test-create-network-and-storage branch from 4e9a153 to f82f30e Compare August 4, 2023 17:34
@bookinabox
Copy link
Contributor Author

bookinabox commented Aug 4, 2023

I do not know of a way to cleanly delete the directory of a transient storage pool. I'm thinking I can either:

  1. change to a persistent storage pool, which I then define, start, use, destroy, delete, undefine.
  2. parse the storage xml description and use os commands to delete the directory.
  3. Delete the volumes instead and just leave the directory be.
    I'm leaning towards the last option, but I'm sure there are aspects I am not taking into account.

@bookinabox bookinabox force-pushed the libvirt-test-create-network-and-storage branch from f82f30e to 3811ede Compare August 4, 2023 21:46
@bookinabox
Copy link
Contributor Author

bookinabox commented Aug 4, 2023

Changed it to delete the volumes and just ignore the empty folder in /tmp, but if there are any opinions on if the other ways are better, I would be happy to change it.

The reason I don't want to change it to a persistent storage pool is because I'm using its transient status as a way to track whether I should delete it. Otherwise I would need to store some other flag in the libvirt provisioner. Parsing seemed like a slightly more ugly solution to me, but that is not really based on anything.

@bookinabox bookinabox changed the title Libvirt test create network and storage. wip Libvirt test create network and storage Aug 4, 2023
@bookinabox bookinabox force-pushed the libvirt-test-create-network-and-storage branch from 3811ede to 73829ba Compare August 4, 2023 23:42
@bookinabox
Copy link
Contributor Author

Changed the xml to libvirtxml.

@bookinabox bookinabox force-pushed the libvirt-test-create-network-and-storage branch from 73829ba to 52ed1c9 Compare August 8, 2023 21:45
@@ -135,11 +134,99 @@ func (l *LibvirtProvisioner) CreateVPC(ctx context.Context, cfg *envconf.Config)
)

if _, err := l.conn.LookupNetworkByName(l.network); err != nil {
return fmt.Errorf("Network '%s' not found. It should be created beforehand", l.network)
// Check if network is defined, but not enabled
defined_nets, err := l.conn.ListDefinedNetworks()
Copy link
Member

Choose a reason for hiding this comment

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

Please use camel-case with Go: s/defined_nets/definedNets/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done!

}

if sPool, err = l.conn.LookupStoragePoolByName(l.storage); err != nil {
return fmt.Errorf("Storage pool '%s' not found. It should be created beforehand", l.storage)

defined_storage, err := l.conn.ListDefinedStoragePools()
Copy link
Member

Choose a reason for hiding this comment

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

Likewise

Derek Lee added 2 commits August 14, 2023 09:13
Creates a temporary network when the specified network is undefined.

The resulting network will be transient. Its ip will be automatically
chosen.

Names corresponding to defined but disabled networks will not be created
to avoid unintended side-effects.

Temporary networks will be destroyed if TEST_TEARDOWN and TEST_PROVISION
are set to "yes".

Signed-off-by: Derek Lee <[email protected]>
Creates a directory storage pool in /tmp if the storage name given is
not enabled and undefined.

Delete volumes on exit from temporary storage.

Fixes: confidential-containers#1165

Signed-off-by: Derek Lee <[email protected]>
@wainersm
Copy link
Member

@bookinabox hi! I'm getting an error:

[wmoschet@wainer-laptop cloud-api-adaptor]$ ./run_libvirt_e2e.sh 
go test -v -tags=libvirt -timeout 40m -count=1 ./test/e2e
time="2023-08-14T12:32:59-03:00" level=info msg="Do setup"
time="2023-08-14T12:32:59-03:00" level=info msg="Cluster provisioning"
time="2023-08-14T12:32:59-03:00" level=info msg="Network peer-pods-net is not defined. Creating a new temporary network"
time="2023-08-14T12:32:59-03:00" level=info msg="Using 192.168.123.1 as the network ip for peer-pods-net"
time="2023-08-14T12:32:59-03:00" level=info msg="Storage peer-pods-storage is not defined. Creating a new temporary storage pool"
time="2023-08-14T12:32:59-03:00" level=info msg="Created temporary Pool peer-pods-storage"
You need to define api_ip in your parameters file
F0814 12:32:59.595380  315187 env.go:369] Setup failure: exit status 1
FAIL    github.com/confidential-containers/cloud-api-adaptor/test/e2e   0.451s
FAIL
make: *** [Makefile:91: test-e2e] Error 1

@bookinabox
Copy link
Contributor Author

bookinabox commented Aug 14, 2023

@bookinabox hi! I'm getting an error:

[wmoschet@wainer-laptop cloud-api-adaptor]$ ./run_libvirt_e2e.sh 
go test -v -tags=libvirt -timeout 40m -count=1 ./test/e2e
time="2023-08-14T12:32:59-03:00" level=info msg="Do setup"
time="2023-08-14T12:32:59-03:00" level=info msg="Cluster provisioning"
time="2023-08-14T12:32:59-03:00" level=info msg="Network peer-pods-net is not defined. Creating a new temporary network"
time="2023-08-14T12:32:59-03:00" level=info msg="Using 192.168.123.1 as the network ip for peer-pods-net"
time="2023-08-14T12:32:59-03:00" level=info msg="Storage peer-pods-storage is not defined. Creating a new temporary storage pool"
time="2023-08-14T12:32:59-03:00" level=info msg="Created temporary Pool peer-pods-storage"
You need to define api_ip in your parameters file
F0814 12:32:59.595380  315187 env.go:369] Setup failure: exit status 1
FAIL    github.com/confidential-containers/cloud-api-adaptor/test/e2e   0.451s
FAIL
make: *** [Makefile:91: test-e2e] Error 1

@wainersm It relies on #1244 to get the ip. Should I rebase and merge these into one PR then?

We talked a bit in slack, and it looks like it is a kcli version difference. I can either set createCluster to explicitly set the api_ip or we can try to set a kcli version specification?

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.

2 participants