mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-05-17 05:32:22 -04:00
cli: remove old migrations (#2079)
The migrations are not required for upgrading from 2.8.
This commit is contained in:
parent
5f5a752b54
commit
ef526562df
5 changed files with 15 additions and 114 deletions
|
@ -15,7 +15,6 @@ go_library(
|
|||
"//cli/internal/terraform",
|
||||
"//cli/internal/upgrade",
|
||||
"//internal/api/versionsapi",
|
||||
"//internal/attestation/measurements",
|
||||
"//internal/attestation/variant",
|
||||
"//internal/cloud/cloudprovider",
|
||||
"//internal/compatibility",
|
||||
|
|
|
@ -20,7 +20,6 @@ import (
|
|||
"github.com/edgelesssys/constellation/v2/cli/internal/terraform"
|
||||
"github.com/edgelesssys/constellation/v2/cli/internal/upgrade"
|
||||
"github.com/edgelesssys/constellation/v2/internal/api/versionsapi"
|
||||
"github.com/edgelesssys/constellation/v2/internal/attestation/measurements"
|
||||
"github.com/edgelesssys/constellation/v2/internal/attestation/variant"
|
||||
"github.com/edgelesssys/constellation/v2/internal/cloud/cloudprovider"
|
||||
"github.com/edgelesssys/constellation/v2/internal/compatibility"
|
||||
|
@ -58,10 +57,6 @@ const (
|
|||
// ErrInProgress signals that an upgrade is in progress inside the cluster.
|
||||
var ErrInProgress = errors.New("upgrade in progress")
|
||||
|
||||
// ErrLegacyJoinConfig signals that a legacy join-config was found.
|
||||
// TODO(daniel-weisse): v2.9 remove.
|
||||
var ErrLegacyJoinConfig = errors.New("legacy join-config with missing attestationConfig found")
|
||||
|
||||
// GetConstellationVersion queries the constellation-version object for a given field.
|
||||
func GetConstellationVersion(ctx context.Context, client DynamicInterface) (updatev1alpha1.NodeVersion, error) {
|
||||
raw, err := client.GetCurrent(ctx, "constellation-version")
|
||||
|
@ -301,13 +296,7 @@ func (u *Upgrader) CurrentKubernetesVersion(ctx context.Context) (string, error)
|
|||
func (u *Upgrader) UpdateAttestationConfig(ctx context.Context, newAttestConfig config.AttestationCfg) error {
|
||||
currentAttestConfig, joinConfig, err := u.GetClusterAttestationConfig(ctx, newAttestConfig.GetVariant())
|
||||
if err != nil {
|
||||
if !errors.Is(err, ErrLegacyJoinConfig) {
|
||||
return fmt.Errorf("getting cluster attestation config: %w", err)
|
||||
}
|
||||
currentAttestConfig, joinConfig, err = joinConfigMigration(joinConfig, newAttestConfig.GetVariant())
|
||||
if err != nil {
|
||||
return fmt.Errorf("migrating join config: %w", err)
|
||||
}
|
||||
return fmt.Errorf("getting attestation config: %w", err)
|
||||
}
|
||||
equal, err := newAttestConfig.EqualTo(currentAttestConfig)
|
||||
if err != nil {
|
||||
|
@ -343,11 +332,6 @@ func (u *Upgrader) GetClusterAttestationConfig(ctx context.Context, variant vari
|
|||
return nil, nil, fmt.Errorf("retrieving current attestation config: %w", err)
|
||||
}
|
||||
if _, ok := existingConf.Data[constants.AttestationConfigFilename]; !ok {
|
||||
// TODO(daniel-weisse): v2.9 remove legacy config detection since it is only required for upgrades from v2.7
|
||||
if _, ok := existingConf.Data["measurements"]; ok {
|
||||
u.log.Debugf("Legacy join config detected, migrating to new config")
|
||||
return nil, existingConf, ErrLegacyJoinConfig
|
||||
}
|
||||
return nil, nil, errors.New("attestation config missing from join-config")
|
||||
}
|
||||
|
||||
|
@ -527,45 +511,6 @@ func (u *stableClient) KubernetesVersion() (string, error) {
|
|||
return serverVersion.GitVersion, nil
|
||||
}
|
||||
|
||||
// joinConfigMigration prepares a join-config ConfigMap for migration from v2.7 to v2.8.
|
||||
// TODO(daniel-weisse): v2.9: remove this function.
|
||||
func joinConfigMigration(existingConf *corev1.ConfigMap, attestVariant variant.Variant) (config.AttestationCfg, *corev1.ConfigMap, error) {
|
||||
m, ok := existingConf.Data["measurements"]
|
||||
if !ok {
|
||||
return nil, nil, errors.New("no measurements found in configmap")
|
||||
}
|
||||
|
||||
var measurements measurements.M
|
||||
if err := json.Unmarshal([]byte(m), &measurements); err != nil {
|
||||
return nil, nil, fmt.Errorf("unmarshalling measurements: %w", err)
|
||||
}
|
||||
|
||||
var oldConf config.AttestationCfg
|
||||
switch attestVariant {
|
||||
case variant.AWSNitroTPM{}:
|
||||
oldConf = &config.AWSNitroTPM{}
|
||||
case variant.AzureSEVSNP{}:
|
||||
oldConf = &config.AzureSEVSNP{}
|
||||
case variant.AzureTrustedLaunch{}:
|
||||
oldConf = &config.AzureTrustedLaunch{}
|
||||
case variant.GCPSEVES{}:
|
||||
oldConf = &config.GCPSEVES{}
|
||||
case variant.QEMUVTPM{}:
|
||||
oldConf = &config.QEMUVTPM{}
|
||||
default:
|
||||
return nil, nil, fmt.Errorf("unknown variant: %s", attestVariant)
|
||||
}
|
||||
|
||||
oldConf.SetMeasurements(measurements)
|
||||
oldConfJSON, err := json.Marshal(oldConf)
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("marshalling previous config: %w", err)
|
||||
}
|
||||
existingConf.Data[constants.AttestationConfigFilename] = string(oldConfJSON)
|
||||
|
||||
return oldConf, existingConf, nil
|
||||
}
|
||||
|
||||
type helmInterface interface {
|
||||
Upgrade(ctx context.Context, config *config.Config, timeout time.Duration, allowDestructive, force bool, upgradeID string) error
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue