Skip to content

Conversation

screspod
Copy link
Member

What this PR does / why we need it:

Adds support for upgrade command in the V3 installation path.

Which issue(s) this PR fixes:

https://app.shortcut.com/replicated/story/128992/iteration-1-new-upgrade-command-with-enable-v3-flag

Does this PR require a test?

Unit tests were added

Does this PR require a release note?

NONE

Does this PR require documentation?

NONE

)

type UpgradeCmdFlags struct {
adminConsolePort int
Copy link
Member

Choose a reason for hiding this comment

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

can't change the admin console port on upgrade, i also don't think this is used

configValues string

// linux flags
dataDir string
Copy link
Member

Choose a reason for hiding this comment

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

can't be changed on upgrade. i'd say remove

dataDir string
ignoreHostPreflights bool
ignoreAppPreflights bool
networkInterface string
Copy link
Member

Choose a reason for hiding this comment

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

ditto

flagSet := pflag.NewFlagSet("linux", pflag.ContinueOnError)

// For upgrade, we'll detect the existing data directory
flagSet.StringVar(&flags.dataDir, "data-dir", "", "Path to the existing data directory (will be auto-detected if not provided)")
Copy link
Member

Choose a reason for hiding this comment

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

ditto


// For upgrade, we'll detect the existing data directory
flagSet.StringVar(&flags.dataDir, "data-dir", "", "Path to the existing data directory (will be auto-detected if not provided)")
flagSet.StringVar(&flags.networkInterface, "network-interface", "", "The network interface to use for the cluster")
Copy link
Member

Choose a reason for hiding this comment

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

ditto

return flagSet
}

func newKubernetesUpgradeFlags(flags *UpgradeCmdFlags) *pflag.FlagSet {
Copy link
Member

Choose a reason for hiding this comment

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

aren't these exactly the same as the install ones? let's just rename and reuse the existing one

return nil
}

func addUpgradeTLSFlags(cmd *cobra.Command, flags *UpgradeCmdFlags) error {
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 come from the cluster, the user shouldn't have to provide them again on upgrade

flags.kubernetesEnvSettings = s
}

func processUpgradeTLSConfig(flags *UpgradeCmdFlags) error {
Copy link
Member

Choose a reason for hiding this comment

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

ditto

Copy link

github-actions bot commented Sep 18, 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-9328d0b" -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-9328d0b?airgap=true" -H "Authorization: $EC_SMOKE_TEST_LICENSE_ID" -o embedded-cluster-smoke-test-staging-app-ci.tgz

Happy debugging!

}

func addUpgradeManagementConsoleFlags(cmd *cobra.Command, flags *UpgradeCmdFlags) error {
cmd.Flags().IntVar(&flags.managerPort, "manager-port", ecv1beta1.DefaultManagerPort, "Port on which the Manager will be served")
Copy link
Member

Choose a reason for hiding this comment

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

hmm, the default of this should ideally come from the runtimeconfig in the cluster because we store that information there.

// this does not return an error - it returns the previous umask
_ = syscall.Umask(0o022)

// If data directory wasn't provided, try to detect it from existing installation
Copy link
Member

Choose a reason for hiding this comment

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

user shouldn't be able to provide a data dir in the upgrade command. in fact, we should disable some fields that can't be updated in the setup page. not in scope for this pr though

if err == nil && existingRC.EmbeddedClusterHomeDirectory() != "" {
flags.dataDir = existingRC.EmbeddedClusterHomeDirectory()
} else {
// Fall back to default locations
Copy link
Member

Choose a reason for hiding this comment

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

this must come from the current runtimeconfig in the cluster, else fail

}

// if a network interface flag was not provided, attempt to discover it
if flags.networkInterface == "" {
Copy link
Member

Choose a reason for hiding this comment

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

this must come from the runtimeconfig in the cluster, else fail

return nil
}

func preRunUpgradeKubernetes(_ *cobra.Command, flags *UpgradeCmdFlags, _ kubernetesinstallation.Installation) error {
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 exactly the same logic as the install one, i think we should rename / reuse

if err == nil {
// Parse admin console port from config if available
// This would depend on the actual structure of the config
flags.adminConsolePort = ecv1beta1.DefaultAdminConsolePort // fallback
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 come from the runtimeconfig in the cluster, not this configmap

-----END PRIVATE KEY-----`
)

func Test_readKotsadmPasswordSecret(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

what is this test testing? i don't see it calling any real function? it's just reading data from a fake client.

}
}

func Test_verifyExistingInstallation(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

ditto, what is this exactly testing?

}
}

func Test_readKotsadmTLSSecret(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

ditto

@screspod screspod marked this pull request as ready for review September 20, 2025 22:53
// default value is the manager port from the runtime config
cmd.Flags().IntVar(&flags.managerPort, "manager-port", upgradeConfig.managerPort, "Port on which the Manager will be served")
return nil
}
Copy link

Choose a reason for hiding this comment

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

Bug: Manager Port Flag Ignored

The manager-port flag defaults to 0 because upgradeConfig.managerPort is uninitialized when the flag is defined. The correct manager port is read from the runtime config later in preRunUpgrade. This also means any user-provided value for the flag is ignored, as the code uses upgradeConfig.managerPort directly.

Fix in Cursor Fix in Web

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.

2 participants