mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
cni: fix plugin fingerprinting versions (#16776)
CNI plugins v1.2.0 and above output a second line, containing supported protocol versions.
This commit is contained in:
3
.changelog/16776.txt
Normal file
3
.changelog/16776.txt
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
```release-note:bug
|
||||||
|
client: Fix CNI plugin version fingerprint when output includes protocol version
|
||||||
|
```
|
||||||
@@ -108,9 +108,9 @@ func (f *PluginsCNIFingerprint) detectOnePlugin(pluginPath string, entry os.DirE
|
|||||||
// e.g.
|
// e.g.
|
||||||
// /opt/cni/bin/bridge <no args>
|
// /opt/cni/bin/bridge <no args>
|
||||||
// CNI bridge plugin v1.0.0
|
// CNI bridge plugin v1.0.0
|
||||||
|
// (and optionally another line that contains the supported CNI protocol versions)
|
||||||
tokens := strings.Fields(string(output))
|
tokens := strings.Fields(string(output))
|
||||||
for i := len(tokens) - 1; i >= 0; i-- {
|
for _, token := range tokens {
|
||||||
token := tokens[i]
|
|
||||||
if _, parseErr := version.NewSemver(token); parseErr == nil {
|
if _, parseErr := version.NewSemver(token); parseErr == nil {
|
||||||
return token, true
|
return token, true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,8 +29,10 @@ func TestPluginsCNIFingerprint_Fingerprint_present(t *testing.T) {
|
|||||||
must.True(t, response.Detected)
|
must.True(t, response.Detected)
|
||||||
attrCustom := f.(*PluginsCNIFingerprint).attribute("custom")
|
attrCustom := f.(*PluginsCNIFingerprint).attribute("custom")
|
||||||
attrBridge := f.(*PluginsCNIFingerprint).attribute("bridge")
|
attrBridge := f.(*PluginsCNIFingerprint).attribute("bridge")
|
||||||
|
attrVlan := f.(*PluginsCNIFingerprint).attribute("vlan")
|
||||||
must.Eq(t, "v1.2.3", response.Attributes[attrCustom])
|
must.Eq(t, "v1.2.3", response.Attributes[attrCustom])
|
||||||
must.Eq(t, "v1.0.2", response.Attributes[attrBridge])
|
must.Eq(t, "v1.0.2", response.Attributes[attrBridge])
|
||||||
|
must.Eq(t, "v1.2.0", response.Attributes[attrVlan])
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPluginsCNIFingerprint_Fingerprint_multi(t *testing.T) {
|
func TestPluginsCNIFingerprint_Fingerprint_multi(t *testing.T) {
|
||||||
@@ -49,10 +51,12 @@ func TestPluginsCNIFingerprint_Fingerprint_multi(t *testing.T) {
|
|||||||
must.True(t, response.Detected)
|
must.True(t, response.Detected)
|
||||||
attrCustom := f.(*PluginsCNIFingerprint).attribute("custom")
|
attrCustom := f.(*PluginsCNIFingerprint).attribute("custom")
|
||||||
attrBridge := f.(*PluginsCNIFingerprint).attribute("bridge")
|
attrBridge := f.(*PluginsCNIFingerprint).attribute("bridge")
|
||||||
|
attrVlan := f.(*PluginsCNIFingerprint).attribute("vlan")
|
||||||
attrCustom2 := f.(*PluginsCNIFingerprint).attribute("custom2")
|
attrCustom2 := f.(*PluginsCNIFingerprint).attribute("custom2")
|
||||||
must.Eq(t, "v1.2.3", response.Attributes[attrCustom])
|
must.Eq(t, "v1.2.3", response.Attributes[attrCustom])
|
||||||
must.Eq(t, "v1.0.2", response.Attributes[attrBridge])
|
must.Eq(t, "v1.0.2", response.Attributes[attrBridge])
|
||||||
must.Eq(t, "v9.9.9", response.Attributes[attrCustom2])
|
must.Eq(t, "v9.9.9", response.Attributes[attrCustom2])
|
||||||
|
must.Eq(t, "v1.2.0", response.Attributes[attrVlan])
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPluginsCNIFingerprint_Fingerprint_absent(t *testing.T) {
|
func TestPluginsCNIFingerprint_Fingerprint_absent(t *testing.T) {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
|
# This fixture uses the old version output, without the supported CNI protocol versions.
|
||||||
echo "CNI bridge plugin v1.0.2"
|
echo "CNI bridge plugin v1.0.2"
|
||||||
|
|||||||
5
client/fingerprint/test_fixtures/cni/vlan
Executable file
5
client/fingerprint/test_fixtures/cni/vlan
Executable file
@@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# This fixture uses the new version output, including the supported CNI protocol versions.
|
||||||
|
echo "CNI vlan plugin v1.2.0"
|
||||||
|
echo "CNI protocol versions supported: 0.1.0, 0.2.0, 0.3.0, 0.3.1, 0.4.0, 1.0.0"
|
||||||
Reference in New Issue
Block a user