-
Notifications
You must be signed in to change notification settings - Fork 6
Support upgrade command for V3 #2949
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
base: main
Are you sure you want to change the base?
Support upgrade command for V3 #2949
Conversation
cmd/installer/cli/upgrade.go
Outdated
) | ||
|
||
type UpgradeCmdFlags struct { | ||
adminConsolePort int |
There was a problem hiding this comment.
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
cmd/installer/cli/upgrade.go
Outdated
configValues string | ||
|
||
// linux flags | ||
dataDir string |
There was a problem hiding this comment.
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
cmd/installer/cli/upgrade.go
Outdated
dataDir string | ||
ignoreHostPreflights bool | ||
ignoreAppPreflights bool | ||
networkInterface string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
cmd/installer/cli/upgrade.go
Outdated
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)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
cmd/installer/cli/upgrade.go
Outdated
|
||
// 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") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
cmd/installer/cli/upgrade.go
Outdated
return flagSet | ||
} | ||
|
||
func newKubernetesUpgradeFlags(flags *UpgradeCmdFlags) *pflag.FlagSet { |
There was a problem hiding this comment.
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
cmd/installer/cli/upgrade.go
Outdated
return nil | ||
} | ||
|
||
func addUpgradeTLSFlags(cmd *cobra.Command, flags *UpgradeCmdFlags) error { |
There was a problem hiding this comment.
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
cmd/installer/cli/upgrade.go
Outdated
flags.kubernetesEnvSettings = s | ||
} | ||
|
||
func processUpgradeTLSConfig(flags *UpgradeCmdFlags) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
This PR has been released (on staging) and is available for download with a embedded-cluster-smoke-test-staging-app license ID. Online Installer:
Airgap Installer (may take a few minutes before the airgap bundle is built):
Happy debugging! |
cmd/installer/cli/upgrade.go
Outdated
} | ||
|
||
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") |
There was a problem hiding this comment.
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.
cmd/installer/cli/upgrade.go
Outdated
// 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 |
There was a problem hiding this comment.
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
cmd/installer/cli/upgrade.go
Outdated
if err == nil && existingRC.EmbeddedClusterHomeDirectory() != "" { | ||
flags.dataDir = existingRC.EmbeddedClusterHomeDirectory() | ||
} else { | ||
// Fall back to default locations |
There was a problem hiding this comment.
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
cmd/installer/cli/upgrade.go
Outdated
} | ||
|
||
// if a network interface flag was not provided, attempt to discover it | ||
if flags.networkInterface == "" { |
There was a problem hiding this comment.
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
cmd/installer/cli/upgrade.go
Outdated
return nil | ||
} | ||
|
||
func preRunUpgradeKubernetes(_ *cobra.Command, flags *UpgradeCmdFlags, _ kubernetesinstallation.Installation) error { |
There was a problem hiding this comment.
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
cmd/installer/cli/upgrade.go
Outdated
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 |
There was a problem hiding this comment.
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
cmd/installer/cli/upgrade_test.go
Outdated
-----END PRIVATE KEY-----` | ||
) | ||
|
||
func Test_readKotsadmPasswordSecret(t *testing.T) { |
There was a problem hiding this comment.
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.
cmd/installer/cli/upgrade_test.go
Outdated
} | ||
} | ||
|
||
func Test_verifyExistingInstallation(t *testing.T) { |
There was a problem hiding this comment.
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?
cmd/installer/cli/upgrade_test.go
Outdated
} | ||
} | ||
|
||
func Test_readKotsadmTLSSecret(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
// 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 | ||
} |
There was a problem hiding this comment.
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.
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?
Does this PR require documentation?
NONE