Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V2 upgrades without manager #1757

Merged
merged 38 commits into from
Feb 4, 2025
Merged

V2 upgrades without manager #1757

merged 38 commits into from
Feb 4, 2025

Conversation

sgalsaleh
Copy link
Member

What this PR does / why we need it:

Which issue(s) this PR fixes:

Does this PR require a test?

Does this PR require a release note?


Does this PR require documentation?

Copy link

github-actions bot commented Jan 29, 2025

This PR has been released (on staging) and is available for download with a embedded-cluster-smoke-test-staging-app license ID.

Online Installer:

curl "https://staging.replicated.app/embedded/embedded-cluster-smoke-test-staging-app/ci/appver-dev-85c9c0c" -H "Authorization: $EC_SMOKE_TEST_LICENSE_ID" -o embedded-cluster-smoke-test-staging-app-ci.tgz

Airgap Installer (may take a few minutes before the airgap bundle is built):

curl "https://staging.replicated.app/embedded/embedded-cluster-smoke-test-staging-app/ci-airgap/appver-dev-85c9c0c?airgap=true" -H "Authorization: $EC_SMOKE_TEST_LICENSE_ID" -o embedded-cluster-smoke-test-staging-app-ci.tgz

Happy debugging!

@sgalsaleh sgalsaleh force-pushed the v2-upgrades-without-manager branch 3 times, most recently from 4925045 to da76031 Compare January 30, 2025 21:46
@sgalsaleh sgalsaleh force-pushed the v2-upgrades-without-manager branch from da76031 to 2fcf916 Compare January 30, 2025 22:02
sgalsaleh and others added 23 commits January 30, 2025 14:07
* remove TestInstallWithoutEmbed

* use new install

* check postupgrade override labels

* fix extension upgrade messages

* further improve wording

* fix nil map issue when upgrading operator

* f

* Update pkg/extensions/upgrade.go

* Update pkg/extensions/upgrade.go

---------

Co-authored-by: Salah Al Saleh <sg.alsaleh@gmail.com>
* add comments to ignore deprecated BuiltinConfigs field

* fix linting
* chore: no spinner if no terminal (#1778)

* fix panic in TestHostPreflightCustomSpec

* fix compile

* require license for install2

* f

* f

* use single-node-install.sh in LAM e2e test

* improve sudo test logging

* ???

* see if it's just one thing failing in sudo test

* use join2 command in 'node join'. Hide 'node' commands

* improve how we are requiring the license flag for installation

---------

Co-authored-by: Ethan Mosbaugh <ethan@replicated.com>
* feat(v2): fix e2e TestVersion

* f

* f
Short: fmt.Sprintf("Experimental installer for %s", name),
Hidden: true,
Use: "install",
Short: fmt.Sprintf("Experimental installer for %s", name),
Copy link
Member

Choose a reason for hiding this comment

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

Fix this

@@ -214,6 +220,8 @@ func preRunInstall2(cmd *cobra.Command, flags *Install2CmdFlags) error {

flags.isAirgap = flags.airgapBundle != ""

flags.isAirgap = flags.airgapBundle != ""
Copy link
Member

Choose a reason for hiding this comment

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

this is duplicated

return nil
}

func handleExtensionInstall(ctx context.Context, kcli client.Client, hcli helm.Client, in *ecv1beta1.Installation, ext ecv1beta1.Chart) (finalErr error) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
func handleExtensionInstall(ctx context.Context, kcli client.Client, hcli helm.Client, in *ecv1beta1.Installation, ext ecv1beta1.Chart) (finalErr error) {
func handleExtensionInstall(ctx context.Context, kcli client.Client, hcli helm.Client, in *ecv1beta1.Installation, ext ecv1beta1.Chart) error {

})
}

func handleExtensionUpgrade(ctx context.Context, kcli client.Client, hcli helm.Client, in *ecv1beta1.Installation, ext ecv1beta1.Chart, needsUpgrade bool) (finalErr error) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
func handleExtensionUpgrade(ctx context.Context, kcli client.Client, hcli helm.Client, in *ecv1beta1.Installation, ext ecv1beta1.Chart, needsUpgrade bool) (finalErr error) {
func handleExtensionUpgrade(ctx context.Context, kcli client.Client, hcli helm.Client, in *ecv1beta1.Installation, ext ecv1beta1.Chart, needsUpgrade bool) error {

})
}

func handleExtensionUninstall(ctx context.Context, kcli client.Client, hcli helm.Client, in *ecv1beta1.Installation, ext ecv1beta1.Chart) (finalErr error) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
func handleExtensionUninstall(ctx context.Context, kcli client.Client, hcli helm.Client, in *ecv1beta1.Installation, ext ecv1beta1.Chart) (finalErr error) {
func handleExtensionUninstall(ctx context.Context, kcli client.Client, hcli helm.Client, in *ecv1beta1.Installation, ext ecv1beta1.Chart) error {

for _, k := range keys {
version := applierVersions[k]
version := versionsMap[k]
if !strings.HasPrefix(version, "v") {
version = fmt.Sprintf("v%s", version)
Copy link
Member

Choose a reason for hiding this comment

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

are we sure we want to prepend a v to extensions versions?

continue
}
break
return err
Copy link
Member

Choose a reason for hiding this comment

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

this masks the error. should return upgradeErr

for _, k := range keys {
version := applierVersions[k]
version := versionsMap[k]
if !strings.HasPrefix(version, "v") {
version = fmt.Sprintf("v%s", version)
Copy link
Member

Choose a reason for hiding this comment

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

are we sure we want to prepend a v to extensions versions?


func SetConditionStatus(ctx context.Context, cli client.Client, in *ecv1beta1.Installation, condition metav1.Condition) error {
return retry.RetryOnConflict(retry.DefaultRetry, func() error {
var copy ecv1beta1.Installation
Copy link
Member

@emosbaugh emosbaugh Feb 4, 2025

Choose a reason for hiding this comment

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

Do we still need this to be a copy or can we use in directly? This seems like a misuse of the controller runtime client.

err = reApplyInstallation(ctx, cli, in)
if err != nil {
return fmt.Errorf("unlock installation: %w", err)
}

err = support.CreateHostSupportBundle()
if err != nil {
logrus.Warnf("Failed to upgrade host support bundle: %v", err)
logrus.Warnf("upgrade host support bundle: %v", err)
Copy link
Member

Choose a reason for hiding this comment

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

Should put this back as it was more readable before

Suggested change
logrus.Warnf("upgrade host support bundle: %v", err)
logrus.Warnf("Failed to upgrade host support bundle: %v", err)

Copy link
Member

Choose a reason for hiding this comment

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

This should also probably be slog

Force: false,
})
if err != nil {
return errors.Wrap(err, "upgrade admin console")
return errors.Wrap(err, "upgrade")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return errors.Wrap(err, "upgrade")
return errors.Wrap(err, "helm upgrade")

Copy link
Member Author

Choose a reason for hiding this comment

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

i feel like "upgrade admin console" is more accurate here though

Copy link
Member

@emosbaugh emosbaugh Feb 4, 2025

Choose a reason for hiding this comment

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

i dont think so because that will be duplicated if you look up the stack. this is calling helm client upgrade so we should wrap it with exactly what it does

Copy link
Member Author

Choose a reason for hiding this comment

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

looks like you comment was on old code. it only says upgrade in the final version

Copy link
Member

@emosbaugh emosbaugh Feb 5, 2025

Choose a reason for hiding this comment

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

In my opinion we should wrap with the addon name as far up the stack as possible #1757 (comment)

})
if err != nil {
return errors.Wrap(err, "install metrics operator")
return errors.Wrap(err, "install")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return errors.Wrap(err, "install")
return errors.Wrap(err, "helm install")

})
if err != nil {
return errors.Wrap(err, "install admin console")
return errors.Wrap(err, "install")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return errors.Wrap(err, "install")
return errors.Wrap(err, "helm install")

Version: Metadata.Version,
Values: string(values),
TargetNS: namespace,
ForceUpgrade: ptr.To(false),
Copy link
Member

Choose a reason for hiding this comment

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

This is set to false while it is set to true in pkg/addons2/embeddedclusteroperator/upgrade.go on line 37

	_, err = hcli.Upgrade(ctx, helm.UpgradeOptions{
		ReleaseName:  releaseName,
		ChartPath:    e.ChartLocation(),
		ChartVersion: e.ChartVersion(),
		Values:       values,
		Namespace:    namespace,
		Labels:       getBackupLabels(),
		Force:        true,
	})

Copy link
Member Author

Choose a reason for hiding this comment

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

oh interesting. we should probably change that to false.

Force: true,
})
if err != nil {
return errors.Wrap(err, "upgrade")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return errors.Wrap(err, "upgrade")
return errors.Wrap(err, "helm upgrade")

Force: false,
})
if err != nil {
return errors.Wrap(err, "upgrade")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return errors.Wrap(err, "upgrade")
return errors.Wrap(err, "helm upgrade")

Force: false,
})
if err != nil {
return errors.Wrap(err, "upgrade")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return errors.Wrap(err, "upgrade")
return errors.Wrap(err, "helm upgrade")

Force: false,
})
if err != nil {
return errors.Wrap(err, "upgrade registry")
return errors.Wrap(err, "upgrade")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return errors.Wrap(err, "upgrade")
return errors.Wrap(err, "helm upgrade")

Force: false,
})
if err != nil {
return errors.Wrap(err, "upgrade")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return errors.Wrap(err, "upgrade")
return errors.Wrap(err, "helm upgrade")

Namespace: namespace,
})
if err != nil {
return errors.Wrap(err, "install openebs")
return errors.Wrap(err, "install")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return errors.Wrap(err, "install")
return errors.Wrap(err, "helm install")

})
if err != nil {
return errors.Wrap(err, "install registry")
return errors.Wrap(err, "install")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return errors.Wrap(err, "install")
return errors.Wrap(err, "helm install")

})
if err != nil {
return errors.Wrap(err, "install seaweedfs")
return errors.Wrap(err, "install")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return errors.Wrap(err, "install")
return errors.Wrap(err, "helm install")

Namespace: namespace,
})
if err != nil {
return errors.Wrap(err, "install velero")
return errors.Wrap(err, "install")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return errors.Wrap(err, "install")
return errors.Wrap(err, "helm install")

Values: values,
Namespace: namespace,
Labels: getBackupLabels(),
Force: true,
Copy link
Member

Choose a reason for hiding this comment

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

This is backwards

// only add tls secret value if the secret exists
// this is for backwards compatibility when the registry was deployed without TLS
var secret corev1.Secret
if err := kcli.Get(ctx, k8stypes.NamespacedName{Namespace: namespace, Name: tlsSecretName}, &secret); err == nil {
Copy link
Member

@emosbaugh emosbaugh Feb 4, 2025

Choose a reason for hiding this comment

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

we should return all errors other than not found error here

@@ -6,7 +6,7 @@ import (
"github.com/pkg/errors"
"github.com/replicatedhq/embedded-cluster/pkg/release"
"github.com/replicatedhq/embedded-cluster/pkg/runtimeconfig"
"gopkg.in/yaml.v3"
"gopkg.in/yaml.v2"
Copy link
Member

Choose a reason for hiding this comment

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

why revert this?

}
for _, addon := range addons {
if err := upgradeAddOn(ctx, hcli, kcli, in, addon); err != nil {
return err
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return err
return errors.Wrap(err, "addon %s", addon.Name())

@@ -71,7 +72,7 @@ func createCredentialsSecret(ctx context.Context, kcli client.Client) error {
},
Type: "Opaque",
}
if err := kcli.Create(ctx, &credentialsSecret); err != nil {
if err := kcli.Create(ctx, &credentialsSecret); err != nil && !k8serrors.IsAlreadyExists(err) {
Copy link
Member

Choose a reason for hiding this comment

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

can we add a comment as to why we create an empty secret here

@@ -7,7 +7,7 @@ import (
ecv1beta1 "github.com/replicatedhq/embedded-cluster/kinds/apis/v1beta1"
"github.com/replicatedhq/embedded-cluster/pkg/release"
"github.com/replicatedhq/embedded-cluster/pkg/runtimeconfig"
"gopkg.in/yaml.v3"
"gopkg.in/yaml.v2"
Copy link
Member

Choose a reason for hiding this comment

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

why revert?

loading.Infof("Installing %s", ext.Name)

if err := install(ctx, hcli, ext); err != nil {
return errors.Wrap(err, "install extension")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return errors.Wrap(err, "install extension")
return errors.Wrapf(err, "install extension %s", ext.Name)

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

Successfully merging this pull request may close these issues.

3 participants