Fix CSI chart version not being compared to CLI version

Signed-off-by: Daniel Weiße <dw@edgeless.systems>
This commit is contained in:
Daniel Weiße 2023-08-11 10:25:57 +02:00 committed by Daniel Weiße
parent 4acfcaf723
commit dcd1c8bd1e

View File

@ -99,13 +99,12 @@ func (c *UpgradeClient) shouldUpgrade(releaseName string, newVersion semver.Semv
return err return err
} }
} }
cliVersion := constants.BinaryVersion()
// at this point we conclude that the release should be upgraded. check that this CLI supports the upgrade. // at this point we conclude that the release should be upgraded. check that this CLI supports the upgrade.
if releaseName == constellationOperatorsInfo.releaseName || releaseName == constellationServicesInfo.releaseName { cliVersion := constants.BinaryVersion()
if cliVersion.Compare(newVersion) != 0 { if isCLIVersionedRelease(releaseName) && cliVersion.Compare(newVersion) != 0 {
return fmt.Errorf("this CLI only supports microservice version %s for upgrading", cliVersion.String()) return fmt.Errorf("this CLI only supports microservice version %s for upgrading", cliVersion.String())
} }
}
c.log.Debugf("Upgrading %s from %s to %s", releaseName, currentVersion, newVersion) c.log.Debugf("Upgrading %s from %s to %s", releaseName, currentVersion, newVersion)
return nil return nil
@ -130,7 +129,7 @@ func (c *UpgradeClient) Upgrade(ctx context.Context, config *config.Config, idFi
// Since our bundled charts are embedded with version 0.0.0, // Since our bundled charts are embedded with version 0.0.0,
// we need to update them to the same version as the CLI // we need to update them to the same version as the CLI
var upgradeVersion semver.Semver var upgradeVersion semver.Semver
if info == constellationOperatorsInfo || info == constellationServicesInfo || info == csiInfo { if isCLIVersionedRelease(info.releaseName) {
updateVersions(chart, constants.BinaryVersion()) updateVersions(chart, constants.BinaryVersion())
upgradeVersion = config.MicroserviceVersion upgradeVersion = config.MicroserviceVersion
} else { } else {
@ -519,3 +518,11 @@ func (a actions) installAction(ctx context.Context, releaseName string, chart *c
} }
return nil return nil
} }
// isCLIVersionedRelease checks if the given release is versioned by the CLI,
// meaning that the version of the Helm release is equal to the version of the CLI that installed it.
func isCLIVersionedRelease(releaseName string) bool {
return releaseName == constellationOperatorsInfo.releaseName ||
releaseName == constellationServicesInfo.releaseName ||
releaseName == csiInfo.releaseName
}