Fix version clash in sidecar manager
Mixing grpc versions caused an endless failure loop during vm creation.
Fixes
@@ -196,10 +196,12 @@ func (m *Manager) OnDefineDomain(domainSpec *virtwrapApi.DomainSpec, vmi *v1.Vir
}
defer conn.Close()
- client := hooksV1alpha1.NewCallbacksClient(conn)
-
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
defer cancel()
+
+ switch callback.Version {
+ case hooksV1alpha1.Version:
+ client := hooksV1alpha1.NewCallbacksClient(conn)
result, err := client.OnDefineDomain(ctx, &hooksV1alpha1.OnDefineDomainParams{
DomainXML: domainSpecXML,
Vmi: vmiJSON,
@@ -208,11 +210,22 @@ func (m *Manager) OnDefineDomain(domainSpec *virtwrapApi.DomainSpec, vmi *v1.Vir
return "", err
}
domainSpecXML = result.GetDomainXML()
- } else {
+ case hooksV1alpha2.Version:
+ client := hooksV1alpha2.NewCallbacksClient(conn)
+ result, err := client.OnDefineDomain(ctx, &hooksV1alpha2.OnDefineDomainParams{
+ DomainXML: domainSpecXML,
+ Vmi: vmiJSON,
+ })
+ if err != nil {
+ return "", err
+ }
+ domainSpecXML = result.GetDomainXML()
+ default:
panic("Should never happen, version compatibility check is done during Info call")
}
}
}
+ }
return string(domainSpecXML), nil
}
