Skip to content
This repository has been archived by the owner on Mar 4, 2024. It is now read-only.

EVEREST-793: upgrade command #297

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
Draft

EVEREST-793: upgrade command #297

wants to merge 11 commits into from

Conversation

michal-kralik
Copy link
Contributor

@michal-kralik michal-kralik commented Feb 14, 2024

CHANGE DESCRIPTION

Problem:
EVEREST-793

Support for everestctl upgrade command.
Upgrades to the next minor version based on metadata from a version service.

CHECKLIST

Jira

  • Is the Jira ticket created and referenced properly?

Tests

  • Is an Integration test/test case added for the new feature/change?
  • Are unit tests added where appropriate?

viper.BindEnv("kubeconfig") //nolint:errcheck,gosec
viper.BindPFlag("kubeconfig", cmd.Flags().Lookup("kubeconfig")) //nolint:errcheck,gosec
viper.BindPFlag("namespaces", cmd.Flags().Lookup("namespaces")) //nolint:errcheck,gosec
viper.BindPFlag("version-metadata-url", cmd.Flags().Lookup("version-metadata-url")) //nolint:errcheck,gosec
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking if we really need this as a cli flag. It's not something the end user would want to configure. Should we have it in build flags then?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The purpose of this flag is to enable:

  • QA/devs to test custom upgrade scenarios
  • Air-gapped environments to be able to point to an internal version metadata service

Comment on lines -75 to +83
func parseConfig() (*upgrade.Config, error) {
c := &upgrade.Config{}
func parseUpgradeConfig() (*upgrade.UpgradeConfig, error) {
c := &upgrade.UpgradeConfig{}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will there config types other than the upgrade in this package so we need to specify the type? upgrade.UpgradeConfig looks redundant which doesn't follow best practices

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, there could be, as we have with other commands.

Comment on lines 40 to 41
wantErr bool
wantErrIs error
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like err error should be enough here. if no error wanted the field remains nil.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

if err != nil {
return nil, errors.Join(err, errors.New("could not parse version metadata URL"))
}
req, err := http.NewRequestWithContext(ctx, http.MethodGet, p.JoinPath("metadata/v1/everest").String(), nil)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this an existing path? if it's under consideration still, I would suggest "everest/v1" so we had version-service-url/product-name/version

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is defined by the version service.
It follows the current structure which is versions/v1/{product}

o.l.Info("Installing Operator Lifecycle Manager")
// TODO: do we upgrade OLM if the version is too old?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should. Another question is how we define if it's too old. Should it be also some kind of mapping for every everest version to have a list of supported OLM versions? Or just hardcoded versions like - Everest 0.8.0 works with the olm X.Y.Z. Once the Everest version is upgraded, olm should be upgraded (if needed) to the version that this version of everest works with.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per discussion, OLM upgrade will be postponed.

Comment on lines +5 to +6
replace github.com/Percona-Lab/percona-version-service => ../percona-version-service

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving a comment so we don't forget about this.

Comment on lines +158 to +161
// TODO: we shall probably split this into "install" and "add namespaces"
// Otherwise the logic is hard to maintain - we need to make sure not to,
// for example, install a different version of operators per namespace, if
// we are always installing the "latest" version.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I already proposed this to Peter and he agreed with the approach as long as users aren't forced to run 2 commands in the initial installation. He wants users to be able to run a single command and have everything set up for them.
In subsequent runs of the install command we can even check and return without doing anything, just saying "Everest is already installed". Adding extra namespaces can be done in a separate command like you suggested.

@@ -236,6 +287,7 @@ func (o *Install) provisionMonitoringStack(ctx context.Context) error {
}

l.Info("Preparing k8s cluster for monitoring")
// TODO: shall we grab VM operator version from metadata?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so. This info lives in the catalog.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The catalog is moving towards having all available versions listed. How do we know which version to use if it's not coming from the metadata service?

Comment on lines +189 to 195
if err := o.provisionDBNamespaces(ctx, recVer); err != nil {
return err
}

if err := o.provisionEverest(ctx); err != nil {
if err := o.provisionEverestOperator(ctx, recVer); err != nil {
return err
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we should get these version from the metadata, this info is part of the catalog.
I thought that the metadata would be used primarily for the everest version itself, the operators' version already exist as part of the catalog, shouldn't we be using that instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The catalog is moving towards having all available versions listed. How do we know which version to use if it's not coming from the metadata service?

Copy link
Collaborator

@recharte recharte Mar 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The catalog is moving towards having all available versions listed.

We agreed on having just 2 versions of operator for a given everest version, right? Since we release a new catalog version with each everest version we would only ever have 2 versions of the operators in the catalog, correct?

commands/upgrade.go Show resolved Hide resolved
pkg/upgrade/upgrade.go Outdated Show resolved Hide resolved
Comment on lines +108 to +109
// We cannot use the latest version of catalog yet since
// at the time of writing, each catalog version supports only one Everest version.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just trying to understand this better. When we update the catalog itself, this doesn't have any side-effects directly right? The subscription would pick up the new versions from the new catalog and would create new install plans that would be waiting approval.
I agree that the most correct way would be to have 2 everest operator versions in the new catalog but is there really any problems with having just one now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When upgrading catalog, we need to use a specific version to be able to upgrade. Otherwise the catalog will not offer correct versions for Everest.
Once the catalog includes all versions of operators, we can always update to the latest one.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants