mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-08-12 16:55:31 -04:00
cli: change upgrade-plan to upgrade-check
Upgrade check is used to find updates for the current cluster. Optionally the found upgrades can be persisted to the config for consumption by the upgrade-execute cmd. The old `upgrade execute` in this commit does not work with the new `upgrade plan`. The current versions are read from the cluster. Supported versions are read from the cli and the versionsapi. Adds a new config field MicroserviceVersion that will be used by `upgrade execute` to update the service versions. The field is optional until 2.7 A deprecation warning for the upgrade key is printed during config validation. Kubernetes versions now specify the patch version to make it explicit for users if an upgrade changes the k8s version.
This commit is contained in:
parent
f204c24174
commit
c275464634
27 changed files with 1080 additions and 992 deletions
|
@ -54,12 +54,12 @@ func runAdd(cmd *cobra.Command, args []string) (retErr error) {
|
|||
log := logger.New(logger.PlainLog, flags.logLevel)
|
||||
log.Debugf("Parsed flags: %+v", flags)
|
||||
|
||||
log.Debugf("Validating flags.")
|
||||
log.Debugf("Validating flags")
|
||||
if err := flags.validate(log); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
log.Debugf("Creating version struct.")
|
||||
log.Debugf("Creating version struct")
|
||||
ver := versionsapi.Version{
|
||||
Ref: flags.ref,
|
||||
Stream: flags.stream,
|
||||
|
@ -70,19 +70,19 @@ func runAdd(cmd *cobra.Command, args []string) (retErr error) {
|
|||
return err
|
||||
}
|
||||
|
||||
log.Debugf("Creating versions API client.")
|
||||
log.Debugf("Creating versions API client")
|
||||
client, err := verclient.NewClient(cmd.Context(), flags.region, flags.bucket, flags.distributionID, flags.dryRun, log)
|
||||
if err != nil {
|
||||
return fmt.Errorf("creating client: %w", err)
|
||||
}
|
||||
defer func(retErr *error) {
|
||||
log.Infof("Invalidating cache. This may take some time.")
|
||||
log.Infof("Invalidating cache. This may take some time")
|
||||
if err := client.InvalidateCache(cmd.Context()); err != nil && retErr == nil {
|
||||
*retErr = fmt.Errorf("invalidating cache: %w", err)
|
||||
}
|
||||
}(&retErr)
|
||||
|
||||
log.Infof("Adding version.")
|
||||
log.Infof("Adding version")
|
||||
if err := ensureVersion(cmd.Context(), client, ver, versionsapi.GranularityMajor, log); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -127,19 +127,19 @@ func ensureVersion(ctx context.Context, client *verclient.Client, ver versionsap
|
|||
insertVersion := ver.WithGranularity(insertGran)
|
||||
|
||||
if verList.Contains(insertVersion) {
|
||||
log.Infof("Version %q already exists in list %v.", insertVersion, verList.Versions)
|
||||
log.Infof("Version %q already exists in list %v", insertVersion, verList.Versions)
|
||||
return nil
|
||||
}
|
||||
log.Infof("Inserting %s version %q into list.", insertGran.String(), insertVersion)
|
||||
log.Infof("Inserting %s version %q into list", insertGran.String(), insertVersion)
|
||||
|
||||
verList.Versions = append(verList.Versions, insertVersion)
|
||||
log.Debugf("New %s version list: %v.", gran.String(), verList)
|
||||
log.Debugf("New %s version list: %v", gran.String(), verList)
|
||||
|
||||
if err := client.UpdateVersionList(ctx, verList); err != nil {
|
||||
return fmt.Errorf("failed to add %s version: %w", gran.String(), err)
|
||||
}
|
||||
|
||||
log.Infof("Added %q to list.", insertVersion)
|
||||
log.Infof("Added %q to list", insertVersion)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -162,7 +162,7 @@ func updateLatest(ctx context.Context, client *verclient.Client, ver versionsapi
|
|||
return nil
|
||||
}
|
||||
|
||||
log.Infof("Setting %q as latest version.", ver)
|
||||
log.Infof("Setting %q as latest version", ver)
|
||||
latest = versionsapi.Latest{
|
||||
Ref: ver.Ref,
|
||||
Stream: ver.Stream,
|
||||
|
|
|
@ -41,18 +41,18 @@ func runLatest(cmd *cobra.Command, args []string) error {
|
|||
log := logger.New(logger.PlainLog, flags.logLevel)
|
||||
log.Debugf("Parsed flags: %+v", flags)
|
||||
|
||||
log.Debugf("Validating flags.")
|
||||
log.Debugf("Validating flags")
|
||||
if err := flags.validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
log.Debugf("Creating versions API client.")
|
||||
log.Debugf("Creating versions API client")
|
||||
client, err := verclient.NewReadOnlyClient(cmd.Context(), flags.region, flags.bucket, flags.distributionID, log)
|
||||
if err != nil {
|
||||
return fmt.Errorf("creating client: %w", err)
|
||||
}
|
||||
|
||||
log.Debugf("Requesting latest version.")
|
||||
log.Debugf("Requesting latest version")
|
||||
latest := versionsapi.Latest{
|
||||
Ref: flags.ref,
|
||||
Stream: flags.stream,
|
||||
|
|
|
@ -45,12 +45,12 @@ func runList(cmd *cobra.Command, args []string) error {
|
|||
log := logger.New(logger.PlainLog, flags.logLevel)
|
||||
log.Debugf("Parsed flags: %+v", flags)
|
||||
|
||||
log.Debugf("Validating flags.")
|
||||
log.Debugf("Validating flags")
|
||||
if err := flags.validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
log.Debugf("Creating versions API client.")
|
||||
log.Debugf("Creating versions API client")
|
||||
client, err := verclient.NewReadOnlyClient(cmd.Context(), flags.region, flags.bucket, flags.distributionID, log)
|
||||
if err != nil {
|
||||
return fmt.Errorf("creating client: %w", err)
|
||||
|
@ -60,7 +60,7 @@ func runList(cmd *cobra.Command, args []string) error {
|
|||
if flags.minorVersion != "" {
|
||||
minorVersions = []string{flags.minorVersion}
|
||||
} else {
|
||||
log.Debugf("Getting minor versions.")
|
||||
log.Debugf("Getting minor versions")
|
||||
minorVersions, err = listMinorVersions(cmd.Context(), client, flags.ref, flags.stream)
|
||||
var errNotFound *verclient.NotFoundError
|
||||
if err != nil && errors.As(err, &errNotFound) {
|
||||
|
@ -71,7 +71,7 @@ func runList(cmd *cobra.Command, args []string) error {
|
|||
}
|
||||
}
|
||||
|
||||
log.Debugf("Getting patch versions.")
|
||||
log.Debugf("Getting patch versions")
|
||||
patchVersions, err := listPatchVersions(cmd.Context(), client, flags.ref, flags.stream, minorVersions)
|
||||
var errNotFound *verclient.NotFoundError
|
||||
if err != nil && errors.As(err, &errNotFound) {
|
||||
|
@ -82,7 +82,7 @@ func runList(cmd *cobra.Command, args []string) error {
|
|||
}
|
||||
|
||||
if flags.json {
|
||||
log.Debugf("Printing versions as JSON.")
|
||||
log.Debugf("Printing versions as JSON")
|
||||
var vers []string
|
||||
for _, v := range patchVersions {
|
||||
vers = append(vers, v.Version)
|
||||
|
@ -95,7 +95,7 @@ func runList(cmd *cobra.Command, args []string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
log.Debugf("Printing versions.")
|
||||
log.Debugf("Printing versions")
|
||||
for _, v := range patchVersions {
|
||||
fmt.Println(v.ShortPath())
|
||||
}
|
||||
|
|
|
@ -78,36 +78,36 @@ func runRemove(cmd *cobra.Command, args []string) (retErr error) {
|
|||
log := logger.New(logger.PlainLog, flags.logLevel)
|
||||
log.Debugf("Parsed flags: %+v", flags)
|
||||
|
||||
log.Debugf("Validating flags.")
|
||||
log.Debugf("Validating flags")
|
||||
if err := flags.validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
log.Debugf("Creating GCP client.")
|
||||
log.Debugf("Creating GCP client")
|
||||
gcpClient, err := newGCPClient(cmd.Context(), flags.gcpProject)
|
||||
if err != nil {
|
||||
return fmt.Errorf("creating GCP client: %w", err)
|
||||
}
|
||||
|
||||
log.Debugf("Creating AWS client.")
|
||||
log.Debugf("Creating AWS client")
|
||||
awsClient, err := newAWSClient(cmd.Context(), flags.region)
|
||||
if err != nil {
|
||||
return fmt.Errorf("creating AWS client: %w", err)
|
||||
}
|
||||
|
||||
log.Debugf("Creating Azure client.")
|
||||
log.Debugf("Creating Azure client")
|
||||
azClient, err := newAzureClient(flags.azSubscription, flags.azLocation, flags.azResourceGroup)
|
||||
if err != nil {
|
||||
return fmt.Errorf("creating Azure client: %w", err)
|
||||
}
|
||||
|
||||
log.Debugf("Creating versions API client.")
|
||||
log.Debugf("Creating versions API client")
|
||||
verclient, err := verclient.NewClient(cmd.Context(), flags.region, flags.bucket, flags.distributionID, flags.dryrun, log)
|
||||
if err != nil {
|
||||
return fmt.Errorf("creating client: %w", err)
|
||||
}
|
||||
defer func(retErr *error) {
|
||||
log.Infof("Invalidating cache. This may take some time.")
|
||||
log.Infof("Invalidating cache. This may take some time")
|
||||
if err := verclient.InvalidateCache(cmd.Context()); err != nil && retErr == nil {
|
||||
*retErr = fmt.Errorf("invalidating cache: %w", err)
|
||||
}
|
||||
|
@ -205,8 +205,8 @@ func deleteImage(ctx context.Context, clients rmImageClients, ver versionsapi.Ve
|
|||
imageInfo, err := clients.version.FetchImageInfo(ctx, imageInfo)
|
||||
var notFound *verclient.NotFoundError
|
||||
if errors.As(err, ¬Found) {
|
||||
log.Warnf("Image info for %s not found.", ver.Version)
|
||||
log.Warnf("Skipping image deletion.")
|
||||
log.Warnf("Image info for %s not found", ver.Version)
|
||||
log.Warnf("Skipping image deletion")
|
||||
return nil
|
||||
} else if err != nil {
|
||||
return fmt.Errorf("fetching image info: %w", err)
|
||||
|
@ -550,7 +550,7 @@ func (g *gcpClient) deleteImage(ctx context.Context, image string, dryrun bool,
|
|||
return fmt.Errorf("deleting image %s: %w", image, err)
|
||||
}
|
||||
|
||||
log.Debugf("Waiting for operation to finish.")
|
||||
log.Debugf("Waiting for operation to finish")
|
||||
if err := op.Wait(ctx); err != nil {
|
||||
return fmt.Errorf("waiting for operation: %w", err)
|
||||
}
|
||||
|
@ -643,7 +643,7 @@ func (a *azureClient) deleteImage(ctx context.Context, image string, dryrun bool
|
|||
return fmt.Errorf("begin delete image version: %w", err)
|
||||
}
|
||||
|
||||
log.Debugf("Waiting for operation to finish.")
|
||||
log.Debugf("Waiting for operation to finish")
|
||||
if _, err := poller.PollUntilDone(ctx, nil); err != nil {
|
||||
return fmt.Errorf("waiting for operation: %w", err)
|
||||
}
|
||||
|
@ -670,7 +670,7 @@ func (a *azureClient) deleteImage(ctx context.Context, image string, dryrun bool
|
|||
return fmt.Errorf("deleting image definition %s: %w", azImage.imageDefinition, err)
|
||||
}
|
||||
|
||||
log.Debugf("Waiting for operation to finish.")
|
||||
log.Debugf("Waiting for operation to finish")
|
||||
if _, err := op.PollUntilDone(ctx, nil); err != nil {
|
||||
return fmt.Errorf("waiting for operation: %w", err)
|
||||
}
|
||||
|
@ -688,7 +688,7 @@ type azImage struct {
|
|||
func (a *azureClient) parseImage(ctx context.Context, image string, log *logger.Logger) (azImage, error) {
|
||||
if m := azImageRegex.FindStringSubmatch(image); len(m) == 5 {
|
||||
log.Debugf(
|
||||
"Image matches local image format, resource group: %s, gallery: %s, image definition: %s, version: %s.",
|
||||
"Image matches local image format, resource group: %s, gallery: %s, image definition: %s, version: %s",
|
||||
m[1], m[2], m[3], m[4],
|
||||
)
|
||||
return azImage{
|
||||
|
@ -709,7 +709,7 @@ func (a *azureClient) parseImage(ctx context.Context, image string, log *logger.
|
|||
version := m[3]
|
||||
|
||||
log.Debugf(
|
||||
"Image matches community image format, gallery public name: %s, image definition: %s, version: %s.",
|
||||
"Image matches community image format, gallery public name: %s, image definition: %s, version: %s",
|
||||
galleryPublicName, imageDefinition, version,
|
||||
)
|
||||
|
||||
|
@ -722,24 +722,24 @@ func (a *azureClient) parseImage(ctx context.Context, image string, log *logger.
|
|||
}
|
||||
for _, v := range nextResult.Value {
|
||||
if v.Name == nil {
|
||||
log.Debugf("Skipping gallery with nil name.")
|
||||
log.Debugf("Skipping gallery with nil name")
|
||||
continue
|
||||
}
|
||||
if v.Properties.SharingProfile == nil {
|
||||
log.Debugf("Skipping gallery %s with nil sharing profile.", *v.Name)
|
||||
log.Debugf("Skipping gallery %s with nil sharing profile", *v.Name)
|
||||
continue
|
||||
}
|
||||
if v.Properties.SharingProfile.CommunityGalleryInfo == nil {
|
||||
log.Debugf("Skipping gallery %s with nil community gallery info.", *v.Name)
|
||||
log.Debugf("Skipping gallery %s with nil community gallery info", *v.Name)
|
||||
continue
|
||||
}
|
||||
if v.Properties.SharingProfile.CommunityGalleryInfo.PublicNames == nil {
|
||||
log.Debugf("Skipping gallery %s with nil public names.", *v.Name)
|
||||
log.Debugf("Skipping gallery %s with nil public names", *v.Name)
|
||||
continue
|
||||
}
|
||||
for _, publicName := range v.Properties.SharingProfile.CommunityGalleryInfo.PublicNames {
|
||||
if publicName == nil {
|
||||
log.Debugf("Skipping nil public name.")
|
||||
log.Debugf("Skipping nil public name")
|
||||
continue
|
||||
}
|
||||
if *publicName == galleryPublicName {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue