Skip to content

Commit

Permalink
Prevent unsupported traffic classes to be set and cause crash
Browse files Browse the repository at this point in the history
It would appear newer versions of vCenter responds back with traffic classes
even if those classes aren't accounted in the version of govmomi the provider has.
Need to upgrade govmomi to support new `nvmetcp` class that was causing a crash.
  • Loading branch information
appilon committed Mar 22, 2022
1 parent e79542b commit 99494ee
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
5 changes: 5 additions & 0 deletions vsphere/distributed_virtual_switch_structure.go
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,11 @@ func expandSliceOfDvsHostInfrastructureTrafficResource(d *schema.ResourceData) [
// flattenSliceOfDvsHostInfrastructureTrafficResource reads in the supplied network I/O control allocation entries supplied via a respective DVSConfigInfo field and sets the appropriate keys in the supplied ResourceData.
func flattenSliceOfDvsHostInfrastructureTrafficResource(d *schema.ResourceData, s []types.DvsHostInfrastructureTrafficResource) error {
for _, v := range s {
if !stringInSlice(v.Key, infrastructureTrafficClassValues) {
// this would imply there are new classes introduced by the vCenter
// API but not yet supported by govmomi/provider
continue
}
if err := flattenDvsHostInfrastructureTrafficResource(d, v, v.Key); err != nil {
return err
}
Expand Down
10 changes: 10 additions & 0 deletions vsphere/util.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package vsphere

func stringInSlice(s string, list []string) bool {
for _, i := range list {
if i == s {
return true
}
}
return false
}
3 changes: 2 additions & 1 deletion website/docs/r/distributed_virtual_switch.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ pools, if their use is so desired.

#### Network I/O control traffic classes

There are currently 9 traffic classes that can be used for network I/O
There are currently 10 traffic classes that can be used for network I/O
control - they are below.

Each of these classes has 4 options that can be tuned that are discussed in the
Expand All @@ -254,6 +254,7 @@ next section.
<tr><td>Virtual Machine Traffic</td><td>`virtualmachine`</td></tr>
<tr><td>vMotion Traffic</td><td>`vmotion`</td></tr>
<tr><td>VSAN Traffic</td><td>`vsan`</td></tr>
<tr><td>Backup NFC</td><td>`backupnfc`</td></tr>
</table>

#### Traffic class resource options
Expand Down

0 comments on commit 99494ee

Please # to comment.