Commit Graph

146 Commits

Author SHA1 Message Date
Julia Kreger ba7d45a526 Update MD5 checksum references
Change-Id: Ibc73ba24aba7644bdfc131a23f2f4060bb053f4f
2023-05-08 12:14:17 -07:00
Zuul 45670dfbe8 Merge "test_provision: don't assert provision_node call order" 2023-02-10 09:09:48 +00:00
Steve Baker 43eec5a109 test_provision: don't assert provision_node call order
provision_node is called from thread pool workers so the call order is
not deterministic. This causes py38 job failures sometimes.

This change asserts that the expected calls are occuring, but not
their order.

Change-Id: Id9f870e35dc9c92f0456d85c087514fb53053b76
2023-02-10 10:15:57 +13:00
Harald Jensås 364fa23916 list_instances - cache allocations
When listing instances fetch all allocations to a cache,
fetch each nodes allocation from the cache. This is
significantly faster than calling get_allocation for each
node.

time metealsmith list # 250 nodes:
  real 0m54.970s vs real 1m45.048s without "cached".

Story: 2010571
Task: 47318
Change-Id: Ic4cef61e338fb57bea5de4f96eb3584386cc5152
2023-02-08 10:08:06 +01:00
Harald Jensås a71776b8a4 Get ports by 'binding:host_id' query filter
By retriving ports from neutron by 'binding:host_id', i.e
ironic node uuid we can remove the list_node_vifs() call
for each node.

Story: 2010571
Task: 47302
Change-Id: I1d85f3341e04ddf969027a6f6839f4a807666258
2023-02-07 22:59:38 +01:00
Harald Jensås 9c2252ea88 Use a network cache in Instance
When listing NICs for an instance populate a class global
cache of networks by network_id. When listing nodes with VIFs
on the same network this reduces the amount of calls to the
network service.

250 Nodes without patch: real    6m29.342s
250 Nodes with patch:    real    5m26.544s

Story: 2010571
Task: 47301
Change-Id: I99a2d8ecab657c8e4c852c73e816a5a8f2856471
2023-02-07 15:15:28 +01:00
Dmitry Tantsur 77d802f3d6 Deprecate instance network boot
Remove or update the corresponding CI jobs. Use the new custom Cirros
image in the HTTP job to avoid relying on CentOS.

Temporary increase complexity requirements while we have a deprecation
warning in the provisioner.

Change-Id: I5e65f9949ee3b78430309017800b88c1ba21dd02
2022-08-24 13:19:52 +02:00
Steve Baker 6c5e68a443 Do a precise node lookup for unprovision
A hostname or name is passed to the unprovision call, and the node is
looked up by allocation name (hostname), falling back to node name.

This can result in the wrong node being unprovisioned in the following
scenario:
* node and hostname naming scheme are identical
* node and hostname names are mixed because allocation placement
  doesn't take the node name into account
* a node has already been unprovisioned by hostname (allocation)
  lookup
* unprovision is performed a second time, this time matching the
  hostname with a different node's name
* the wrong node is unprovisioned

The unprovision_node method can also take a node object instead of a
string identifier, so this change does a precise node lookup before
calling it. This means only hostnames are used for allocation lookups,
and node names for node lookups.

Change-Id: I9507f8d30c871ae62a250148789393695d59183a
Resolves: rhbz#2092444
2022-07-12 08:55:39 +00:00
Steve Baker 5459c30ed4 metalsmith_instances module, unprovision by hostname
The node lookup for unprovision first attempts the allocation name
(hostname)[1] but the metalsmith_instances unprovision passes the node
name.

This means in cases where the node naming scheme and the allocation
naming scheme are the same, the wrong node may be unprovisioned.

This change switches to passing the hostname for unprovision, only
passing the node name if the hostname is missing from the instances
entry.

[1] https://opendev.org/openstack/metalsmith/src/branch/master/metalsmith/_provisioner.py#L653

Change-Id: Ie6b989f8d67c03606be37310777175cfb8d9303e
Resolves: rhbz#2092444
2022-06-20 10:18:08 +12:00
Steve Baker e6568a02bd metalsmith_instances module, pass hostname in reserve
The allocation name/hostname is set during the provision step, but it
is also possible to set it during the reserve step, which is done in
this change.

Setting the name during reservation is more correct, and triggers some
extra sanity checks during provision. But it also enables this change[1]
which attempts to reserve the node with the same name as the
allocation.

[1] https://review.opendev.org/c/openstack/ironic/+/845856

Change-Id: I0da4644a955b8e9fbf509c074b939b97c64739cb
2022-06-20 10:18:02 +12:00
Steve Baker cf6b37ab22 metalsmith list handle missing port
Currently if a port is missing, running metalsmith list will fail with
an error. This change handles missing ports by not showing any IP
address for that VIF, and logging a warning.

Change-Id: I94924ebc81b46a2aa4c3b6f82bd46480f37b3150
Resolves: rhbz#2092444
2022-06-16 09:43:59 +12:00
Harald Jensås 264836d59a Allow both 'network' and 'subnet' in NIC
Fixes and issue where a port cannot be created on
a specific subnet if there are multiple subnets
with the same name on different networks.

Allows both 'network' and 'subnet' in NIC information,
when looking up the subnet filter on the network_id when
both 'network' and 'subnet' is provided.

Story: 2009732
Task: 44152
Change-Id: Ied2d16ec33fe71522c3461d3df6e70fbfdd976b2
2022-02-01 09:50:41 +01:00
Harald Jensås 043f80b45a Add unit tests for metalsmith/_nics.py
Add unit tests for metalsmith._nics.detach_and_delete_ports
and metalsmith._nics.NICs.

Change-Id: I767a6981fb960954f53d86475927bb97aa967ed6
2021-12-10 18:34:33 +01:00
Harald Jensås 81d820f28f Set binding:host_id on VIFs
Set the 'binding:host_id' on neutron port VIFs when
they are created, or update it for existing ports.

This ensures IP allocation is not deferred by neutron.

If IP allocation is deferred, the config-drive network
metadata will not include enough information to properly
bootstrap the instance networking.

Story: 2009715
Task: 44089
Closes-Bug: #1952573
Change-Id: I7411c1f2fbc57dad0504fe61e278308030f059bf
2021-11-30 02:23:30 +01:00
Harald Jensås f98dfa61c1 Write network_data.json metadata to config-dirve
cloud-init will use fall-back config when network metadata
is *not* present. This works fine if the first NIC on the node is
connected to a network with DHCP. But, when the first NIC is not
used for provisioning, cloud-init will only write a fallback config
for the first NIC. This causes the provisioned node to be unavailable.

Extend instance configuration to include network metadata so that
cloud-init can configure node networking.

Story: 2009238
Task: 43378
Change-Id: I70f1a972a6d5a0398cd348f00308957386d66067
2021-09-22 14:50:02 +02:00
Takashi Kajinami 419e384ebb Replace deprecated import of ABCs from collections
ABCs in collections should be imported from collections.abc and direct
import from collections is deprecated since Python 3.3.

Change-Id: Ibca1d5756d7598e961e21c5ba9bd6e17bb895285
2021-07-17 00:59:22 +09:00
Steve Baker 407e5051d4 Set image_disk_format from file extension for HTTP images
Node instance_info `image_disk_format` needs to be set to `raw` for
large raw images or the deployment may fail with a memory check error
or a full node tmpfs. Even when there is no error, without
image_disk_format=raw the image will not be streamed directly to disk.

image_disk_format is auto-detected and set by ironic for glance and
file sourced images, but this does not occur for direct HTTP based
images.

This change will set image_disk_format=raw when the URL file extension
ends with .raw, which is enough to support TripleO's conventions for
the overcloud raw image.

Change-Id: I6a9c225fc2d14b2d07cd0bf2379cd2c8c548f312
2021-07-06 14:58:59 +12:00
Dmitry Tantsur 65f85451d0 Do not wipe instance_info on normal unprovisioning
Ironic uses information from instance_info on tear down and removes
it afterwards automatically.

Change-Id: I88ea06b7cb07d648cc68b677e905bf403ae8e1ed
2021-01-26 19:19:05 +01:00
Steve Baker 72d7624150 Follow-up to metalsmith_instances config_drive
Docs improvements and review nit changes

Change-Id: I2c22cf4c49eba86722fe4ce42768040253a4db9d
2020-12-08 14:34:21 +13:00
Steve Baker 22a4e4071c Add metalsmith_instances instance option config_drive
This has sub-options ``cloud_config` and ``meta_data`` and allows
customization of data packaged in the config-drive to be consumed by
cloud-init.

This is needed by TripleO to provide an equivalent to the current
heat/nova based firstboot customization support.

Change-Id: Ie384292a3310cb06e908dd9027e9300ca108e7dd
2020-11-11 09:15:24 +13:00
Steve Baker a7bd8fe1ae metalsmith_deployment role switch to metalsmith_instances
Instead of wrapping the metalsmith CLI, the metalsmith_deployment role
now uses the metalsmith_instances module. There are differences between
the instances formats of the role and the module which are partially
resolved with a simple transformation module called
metalsmith_deployment_defaults.

A 'candidates' attribute is added to metalsmith_instances, but keeping
the single 'name' attribute to remain compatible with the TripleO
usage.

Unresolved differences between the 2 are described below:

metalsmith_instances doesn't have a per-instance state attribute,
instead it has one state attribute for all instances. I propose that
support for per-instance state is dropped. This was never documented
in the README.rst anyway.

extra_args only applies to a CLI. Apart from --dry-run these arguments
are either for output formatting or Ironic API authentication. I propose
that this option is dropped. A metalsmith_debug arg is added to make
the ouput more verbose.

Change-Id: Ia30620821182c58050813e807cdde50a27d03c15
2020-10-08 09:48:20 +13:00
Dmitry Tantsur 3621535d67 Stop requiring checksums with file images
Neither deploy method requires checksums with file images, they're
simply ignored. Deprecate providing them.

Change-Id: Ia123c1d3c57cc2814e3f971209cbee3ab336f7bd
2020-09-03 14:23:52 +02:00
Steve Baker 62b8b1d8b9 Move metalsmith_instances from tripleo-ansible
Change-Id: I02407547154d8d6084fa30c5fe164c5b6a060043
2020-07-01 13:30:35 +12:00
Zuul 9aeaa29f5d Merge "Get rid of testtools and fixtures" 2020-05-06 16:21:56 +00:00
Dmitry Tantsur 954a6cab6d Start enforcing W504 in pep8
Apparently, not disabling W503 results in W504 ignored. The latter
seems to be preferred now.

Change-Id: I53124ff7b4083382dc24f32fe9affe6fc7478281
2020-05-04 11:27:57 +02:00
Dmitry Tantsur 90671a01e3 Get rid of testtools and fixtures
testtools was used to provide a smoother transition to Python 3.
fixtures seems no longer actively maintained and is mostly redundant.

Change-Id: I3fff3beafca13a783bcb4d5a811099ad491ac7ac
2020-05-04 11:19:58 +02:00
Iury Gregory Melo Ferreira 05ed2cf76b No need to import print function anymore
Removing print function import

Change-Id: I9a5d8cd44ba980d6b9a7570573c6ed6a9725721e
2020-04-21 13:23:46 +02:00
Sean McGinnis f6fb359cf5
Use unittest.mock instead of third party mock
Now that we no longer support py27, we can use the standard library
unittest.mock module instead of the third party mock lib.

Change-Id: I97af946c244559513689c1ea9ac2d736d55dbe0f
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
2020-04-18 16:05:36 -05:00
Iury Gregory Melo Ferreira c765bbe8a8 Stop using six library
Since we've dropped support for Python 2.7, it's time to look at
the bright future that Python 3.x will bring and stop forcing
compatibility with older versions.
This patch removes the six library from requirements, not
looking back.

Change-Id: I19384db89fc2a68376efc3f9f2e05fbd05046fd6
2019-12-03 15:15:20 +01:00
Dmitry Tantsur 2d801e2526 Stop requiring root size for whole disk images
This requirement has been fixed in newer versions of ironic.

Change-Id: I4460755ee66b4aa0b8a651b6bd142c769d669ee2
2019-11-05 18:29:16 +01:00
Steve Baker a77cfb2ce6 Set useful port name when hostname is provided
It is useful to see the purpose of a port when viewing a port list or
port details. This change will set the port name to
<hostname>-<net-name> when the hostname is provided to the NICs
constructor.

Change-Id: Ic5789c0c3808afaa6b45408bce51d6c4ca86dbe5
2019-08-12 01:00:20 +00:00
Steve Baker 6f316bbad4 Set instance_info.display_name to the hostname
This makes metalsmith consistent with what the nova ironic driver
does, and provides a way of discovering the hostname for a node
without needing to query the allocation API.

Change-Id: I40bbf155421cd2b382f8262eb38393c3300478cd
2019-08-06 22:54:09 +00:00
Zuul 500094fc63 Merge "Remove deprecations from 0.13" 2019-08-06 13:41:03 +00:00
Dmitry Tantsur 70acccc489 Remove deprecations from 0.13
Change-Id: I1da92c8ba3af2923d4ac8e16b787a9cdfc92fe4e
2019-08-02 14:24:33 +02:00
Dmitry Tantsur 97311ce7fb Clean up exceptions metalsmith raises
This change switches from a mix of metalsmith and SDK exceptions
to consistently using metalsmith exceptions.

Change-Id: I43339686a42644877dbe40d1116db1585a8a0800
2019-08-02 13:59:12 +02:00
Dmitry Tantsur 24d006b996 Bring formatting in line with other OpenStack CLI
Change-Id: Ifb299d5d95245e8848785eb2e2a7018fbb4129d6
2019-07-22 15:01:15 +02:00
Dmitry Tantsur e9c25b02e5 Use allocation name for hostname instead of a custom field
This concludes the switch to the allocation API.

Change-Id: I25cdae7d17604140f728fdbcfea4110cbd222679
2019-06-07 11:08:48 +02:00
Zuul b1769b01cc Merge "Split InstanceConfig into GenericConfig and CloudInitConfig" 2019-05-27 09:00:18 +00:00
Dmitry Tantsur 349e5074e3 Split InstanceConfig into GenericConfig and CloudInitConfig
As a side effect allows providing custom user data, not only users.

Change-Id: Ia4c305ea996b3bb58c5898777cc7a3c8b93a413d
2019-05-24 15:18:18 +02:00
Dmitry Tantsur 0e7fa76b5a Remove features deprecated in Stein
Change-Id: I9825df90c69233acaf3c712f371e33aaf2042d4c
2019-05-24 14:20:08 +02:00
Dmitry Tantsur 4920cc26a3 Allow disabling clean up on deployment failure
Change-Id: Iaa9e7ec1c2cd2b71047388e51255ec69d52d6a83
2019-05-17 14:13:10 +02:00
Dmitry Tantsur 814611f022 Switch to allocation API instead of reservations via instance_id
Change-Id: I45882ddd18d2a91db9c3592c6ed527676b91091b
2019-05-17 13:28:58 +02:00
Dmitry Tantsur 0161effc3a Build configdrives on ironic side
Change-Id: Ia058a410d1b1277497fbb645fc102c8b0a7aba4f
2019-05-17 10:30:41 +02:00
Dmitry Tantsur 1afa4ac4ed Expose Allocation objects on Instance
Change-Id: If62a6829478c532428aff2f5f51edc35df8ee2e1
2019-05-16 12:15:52 +02:00
Dmitry Tantsur 9be7472236 Accept hostname in reserve_node in addition to provision_node
With the allocation API we will need to provide the hostname as
the allocation name. Thus, we have to do it earlier.

Change-Id: I8afd8af23ad929fd9768e95a82fecd114fdcbfd9
2019-03-15 14:49:58 +01:00
Dmitry Tantsur 8e7b8d3f39 Ensure instance_info is clean before deploy and after failure
Currently stale values can be left in instance_info (and reused next time)
if a deployment attempts fails. This change ensures that we:
1) Purge instance_info completely on failures
2) Only keep traits and capabilities in instance_info on deploy.

Change-Id: I52a85620d9ac2f471bca6498294871f3bb16d47f
2019-03-08 14:31:47 +01:00
Dmitry Tantsur d64e020fd0 Make resource class required
Allocation API requires a resource class, so we have to require it now.

Change-Id: Ic3729fb8aa02c82379eceb2a2555fc9c0ba9bc57
2019-03-01 15:39:51 +01:00
Dmitry Tantsur 2aeb60434e Display hostname in the default formatter
Change-Id: If6021ee5449cf74159640fdcc3f248c9f99a4105
2019-02-20 14:32:43 +01:00
Dmitry Tantsur e795f6c841 Make sure to not try reserving a reserved node
After the switch to openstacksdk we no longer have a sufficient check
on node's availability or maintenance. This patch restores it.

Change-Id: I2c85cf0adb02061b3dd85f19dd10c8a5af1118da
2019-01-22 18:08:53 +01:00
Dmitry Tantsur 6c55e2f3e2 Properly mock configdrive building in unit tests
Currently we fail unit tests if genisoimage is not present, e.g. in RDO.

Change-Id: Id241c9625628de101e2ed40d71cb8d4ed06a50ed
2019-01-22 10:06:30 +01:00