-
Notifications
You must be signed in to change notification settings - Fork 508
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
[vsphere] Add ability to specify local templates for vsphere #12894
Conversation
} | ||
|
||
func (c *Client) ListVMTemplates(ctx context.Context, path string) ([]*object.VirtualMachine, error) { | ||
c.logger.Debugf("ListVMTemplates() path=%q", path) |
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.
Let's keep this log message at a Trace level
This PR still needs some new tests, but it should be ready for review. |
a497b6e
to
440bf3c
Compare
provider/vsphere/vm_template.go
Outdated
seriesTemplatesFolder := v.seriesTemplateFolder(series) | ||
seriesTemplates, err := v.env.client.ListVMTemplates(ctx, path.Join(seriesTemplatesFolder, "*")) | ||
if err != nil { | ||
logger.Errorf("failed to fetch templates: %v", err) |
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 causes misleading error messages during bootstrap, when the folder for the bootstrapping controller hasn't been created yet and not simplestreams supplied
...
Launching controller instance(s) on boston-vsphere/Boston...
ERROR failed to fetch templates: path not found: juju-ci-root/Juju Controller (baf1f6a2-f6d7-44f1-8916-7165113f7f8f)/templates/focal/* not found
- juju-dc6839-0 (arch=amd64 mem=3.5G) f81b245c98d18fec1564e6b374c346f1ef14394c9e836ee77e1e58754242a4f9"
Installing Juju agent on bootstrap instance
...
During QA: Bootstrap used the simplestreams defined template, but |
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 one issue found during QA that needs to be resolved, as well as items listed below.
items, err := finder.VirtualMachineList(ctx, path) | ||
if err != nil { | ||
if _, ok := err.(*find.NotFoundError); ok { | ||
return nil, errors.NotFoundf("path not found: %s", path) |
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.
Remove "not found" from error message, redundant as errors.NotFoundf() prints it at the end. Perhaps use errors.Annotatef instead?
|
||
type ImportOVAParameters struct { | ||
StatusUpdateParams StatusUpdateParams | ||
// ReadOVA returns the location of, and an io.ReadCloser for, |
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.
nit: new line above for consistency.
Clock clock.Clock | ||
} | ||
|
||
type ImportOVAParameters struct { |
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.
Comment header for struct
provider/vsphere/vm_template.go
Outdated
return arch, nil | ||
} | ||
} | ||
return "", errors.NotFoundf("arch tag not found for VM") |
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.
"arch tag for VM" is clearer with ": not found" tacked to the end when the error is a string. otherwise error string is: "arch tag not found for VM: not found"
provider/vsphere/vm_template.go
Outdated
for _, item := range desiredArches { | ||
if item == arch { | ||
return true | ||
} | ||
} | ||
return false |
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.
return set.NewStrings(desiredArches...).Contains(arch)
provider/vsphere/vm_template.go
Outdated
} | ||
logger.Debugf("Series templates: %v", seriesTemplates) | ||
if len(seriesTemplates) == 0 { | ||
return nil, "", errors.NotFoundf("no valid templates 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.
"valid templates"
provider/vsphere/vm_template.go
Outdated
break | ||
} | ||
if vmTpl == nil { | ||
return nil, "", errors.NotFoundf("no valid templates 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.
"valid templates"
// vmTemplateManager implements a template registry that | ||
// can return a proper VMware template given a series and | ||
// image metadata. | ||
type vmTemplateManager struct { |
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.
Where are the unit tests for the vmTemplateManager?
This is probably due to the fact that during bootstrap, juju grabbed the upstream Make sure you also generate the agent metadata using: juju-metadata generate-agents --stream proposed This will look for packaged binaries in |
When generating simplestreams, use a relative path to the template instead of just the template name. The relative path is applied to the datacenter path when searching for the template.
0fdb113
to
0ec66de
Compare
Windows can now be supported with the adition of local templates. The template must conform to the following: * A supported version of Windows must be installed inside * vApp config settings must have the proper ovfenv (same ones as Ubuntu - instance-id, userdata, etc) * VMware tools must be installed * Cloudbase-Init must be installed, and the cloudbaseinit.metadata.services.ovfservice.OvfService set as the only value in the metadata_services config option in both cloudbase-init.conf and cloudbase-init-unattend.conf. * Sysprep the instance using: sysprep.exe /generalize /oobe /unattend:C:\Program Files\Cloudbase Solutions\Cloudbase-Init\Conf\unattend.xml /shutdown (copy that file in C:\Unattend.xml if you encouner errors) * before cloning as template, network adapter must be removed, and any ISO file attached to the CDROM must be detached.
37e263f
to
ccf4222
Compare
When using --build-agents, should need the juju metadata piece. Redid the QA, as expected: when deploying ubuntu with focal, no new template was created, when deploying ubuntu with bionic, a new template was created. |
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.
A few small items to resolve, then I will approve and merge.
provider/vsphere/export_test.go
Outdated
"github.com/juju/juju/environs" | ||
"github.com/juju/juju/environs/imagemetadata" | ||
"github.com/juju/juju/provider/vsphere/internal/vsphereclient" | ||
"github.com/vmware/govmomi/object" | ||
"github.com/vmware/govmomi/vim25/types" |
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.
should be 2 stanza of imports
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 now, all testing is good.
!!build!! |
|
#12963 Merge most recent 2.9 commits (up to commit d597250 for #12948) : #12892 Add CLA checker GH action #12937 Actions with errors queuing them can be listed #12940 Fix ssh to sidecar charm container #12941 Fix/lp 1925735 #12943 Ensure upgraded 2.8 models can start containers on machines #12947 Remove redundant AddressConfigMethod #12949 Remove redundant AddressConfigMethod #12950 Fix non-linux network config source #12894 Add ability to specify local templates for vsphere #12948 Select default charm url depending on controller version Conflicts were due to actions api changes from #12937 ``` # apiserver/facades/agent/uniter/uniter_test.go # apiserver/facades/client/action/action_test.go # apiserver/facades/client/action/legacy_test.go # apiserver/facades/client/action/operation.go # apiserver/params/internal.go # cmd/juju/application/deploy_test.go # go.mod # go.sum # scripts/win-installer/setup.iss # snap/snapcraft.yaml # state/action.go # state/action_test.go # state/allwatcher_internal_test.go # state/cleanup_test.go # state/interface.go # state/machine.go # state/machine_test.go # state/migration_export_test.go # state/migration_import_test.go # state/operation_test.go # state/state_test.go # state/unit.go # state/unit_test.go # state/watcher_test.go # version/version.go # worker/uniter/runner/context/context_test.go # worker/uniter/runner/context/contextfactory_test.go # worker/uniter/runner/factory_test.go # worker/uniter/util_test.go ``` ## QA steps See PRs
This PR adds ability to specify local templates via simplestreams using the
image-id
format. IQA steps
Steps are as follows:
Generate tools metadata
Generate image metadata
When generating simplestreams, use the relative path to the template in relation to the datacenter path (/datacenter-name/vm):
This will generate the following: https://paste.ubuntu.com/p/9zk5hX7wR6/
Given the above simplesrteams, the provider will look for the template in:
then deploy a new controller:
juju bootstrap --metadata-source $HOME/simplestreams --debug --verbose --show-log vsphere vsphere-controller
Bug reference
https://bugs.launchpad.net/juju/+bug/1867154