Skip to content

Commit

Permalink
Add deployments reason for helm history
Browse files Browse the repository at this point in the history
Migration deploys the helm chart multiple times. Identifying which
revision corresponds to which step in helm history is hard without a
description.
  • Loading branch information
cbosdo committed Nov 13, 2024
1 parent aa0b88c commit bc04337
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
1 change: 1 addition & 0 deletions mgradm/cmd/install/kubernetes/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ func installForKubernetes(globalFlags *types.GlobalFlags,

// Deploy Uyuni and wait for it to be up
if err := kubernetes.Deploy(
L("Initial deployment from mgradm install"),
cnx, flags.Image.Registry, &flags.Image, &flags.HubXmlrpc, &flags.Helm, &flags.SSL,
clusterInfos, fqdn, flags.Debug.Java, false, helmArgs...,
); err != nil {
Expand Down
17 changes: 11 additions & 6 deletions mgradm/cmd/migrate/kubernetes/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ func migrateToKubernetes(
"--set", "migration.dataPath="+scriptDir,
)

if err := kubernetes.Deploy(cnx, flags.Image.Registry, &flags.Image, &flags.HubXmlrpc,
if err := kubernetes.Deploy(
fmt.Sprintf(L("Deploy to migrate the data from %s"), fqdn),
cnx, flags.Image.Registry, &flags.Image, &flags.HubXmlrpc,
&flags.Helm, &sslFlags, clusterInfos, fqdn, false, flags.Prepare, migrationArgs...,
); err != nil {
return utils.Errorf(err, L("cannot run deploy"))
Expand Down Expand Up @@ -155,7 +157,8 @@ func migrateToKubernetes(

// Run uyuni upgrade using the new ssl certificate
// We don't need to start the Hub XML-RPC API containers during the setup phase
if err = kubernetes.UyuniUpgrade(
if err := kubernetes.UyuniUpgrade(
L("Upgrade with final volumes"),
serverImage, flags.Image.PullPolicy, 0, hubXmlrpcImage, &flags.Helm,
kubeconfig, fqdn, clusterInfos.Ingress, helmArgs...,
); err != nil {
Expand Down Expand Up @@ -200,10 +203,12 @@ func migrateToKubernetes(
}

// This is the final deployment, all the replicas need to be correct here.
if err := kubernetes.UyuniUpgrade(
serverImage, flags.Image.PullPolicy, hubReplicas, hubXmlrpcImage, &flags.Helm, kubeconfig,
fqdn, clusterInfos.Ingress, helmArgs...,
); err != nil {
err = kubernetes.UyuniUpgrade(
L("Complete deployment after migration"),
serverImage, flags.Image.PullPolicy, hubReplicas, hubXmlrpcImage, &flags.Helm, kubeconfig, fqdn,
clusterInfos.Ingress, helmArgs...,
)
if err != nil {
return utils.Errorf(err, L("cannot upgrade to image %s"), serverImage)
}

Expand Down
16 changes: 11 additions & 5 deletions mgradm/shared/kubernetes/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const HelmAppName = "uyuni"

// Deploy execute a deploy of a given image and helm to a cluster.
func Deploy(
reason string,
cnx *shared.Connection,
registry string,
imageFlags *types.ImageFlags,
Expand Down Expand Up @@ -60,10 +61,11 @@ func Deploy(
}

// Install the uyuni server helm chart
if err := UyuniUpgrade(
serverImage, imageFlags.PullPolicy, hubXmlrpcFlags.Replicas, hubXmlrpcImage, helmFlags,
clusterInfos.GetKubeconfig(), fqdn, clusterInfos.Ingress, helmArgs...,
); err != nil {
err = UyuniUpgrade(
reason, serverImage, imageFlags.PullPolicy, hubXmlrpcFlags.Replicas, hubXmlrpcImage,
helmFlags, clusterInfos.GetKubeconfig(), fqdn, clusterInfos.Ingress, helmArgs...,
)
if err != nil {
return utils.Errorf(err, L("cannot upgrade"))
}

Expand Down Expand Up @@ -118,6 +120,7 @@ func DeployExistingCertificate(

// UyuniUpgrade runs an helm upgrade using images and helm configuration as parameters.
func UyuniUpgrade(
reason string,
serverImage string,
pullPolicy string,
hubXmlrpcReplicas int,
Expand All @@ -144,7 +147,9 @@ func UyuniUpgrade(
helmParams = append(helmParams,
"--set", "images.server="+serverImage,
"--set", "pullPolicy="+kubernetes.GetPullPolicy(pullPolicy),
"--set", "fqdn="+fqdn)
"--set", "fqdn="+fqdn,
"--description", reason,
)

if hubXmlrpcReplicas > 0 {
log.Info().Msg(L("Enabling Hub XMLRPC API container."))
Expand Down Expand Up @@ -280,6 +285,7 @@ func Upgrade(
}

err = UyuniUpgrade(
L("Upgrade from mgradm"),
serverImage, image.PullPolicy, hubXmlrpcReplicas, hubXmlrpcImageName, &helm, kubeconfig, fqdn,
clusterInfos.Ingress, helmArgs...,
)
Expand Down

0 comments on commit bc04337

Please sign in to comment.