Capture error from schema check in preupgrade verification (#2285)

Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>
This commit is contained in:
Sanket Sudake
2021-12-21 20:25:51 +05:30
committed by GitHub
parent 223892f121
commit f635f6d16a
2 changed files with 5 additions and 5 deletions
+4 -4
View File
@@ -96,21 +96,21 @@ func (client *PreUpgradeTaskClient) LatestSchemaApplied(ctx context.Context) err
client.logger.Info("Checking if user has applied the latest CRDs")
funcCRD := client.GetFunctionCRD(ctx)
if funcCRD == nil {
return errors.New("Could not get the Function CRD")
return fmt.Errorf("could not get the Function CRD")
}
// Any new field added in Function spec can be checked here provided the substring matches the description in CRD Validation of the field
if !strings.Contains(funcCRD.Spec.String(), "RequestsPerPod") || !strings.Contains(funcCRD.Spec.String(), "OnceOnly") || !strings.Contains(funcCRD.Spec.String(), "PodSpec") {
return errors.New("Apply the newer CRDs before upgrading")
return fmt.Errorf("could not find RequestPerPod/OnceOnly/PodSpec in Function CRD")
}
mqtCRD := client.GetMqtCRD(ctx)
if mqtCRD == nil {
return errors.New("Could not get the MQT CRD")
return fmt.Errorf("could not get the MQT CRD")
}
// Any new field added in MQT spec can be checked here provided the substring matches the description in CRD Validation of the field
if !strings.Contains(mqtCRD.Spec.String(), "PodSpec") {
return errors.New("Apply the newer CRDs before upgrading")
return fmt.Errorf("could not find PodSpec field in MQT CRD")
}
return nil
+1 -1
View File
@@ -67,7 +67,7 @@ Options:
err = crdBackedClient.LatestSchemaApplied(ctx)
if err != nil {
logger.Fatal("New CRDs are not applied")
logger.Fatal("New CRDs are not applied", zap.Error(err))
}
crdBackedClient.VerifyFunctionSpecReferences(ctx)
}