Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
nadvornik authored and cbosdo committed Jul 19, 2024
1 parent a311dfc commit efc2084
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 12 deletions.
1 change: 1 addition & 0 deletions mgradm/cmd/migrate/kubernetes/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func migrateToKubernetes(

hubXmlrpcImage := ""
if flags.HubXmlrpc.Replicas > 0 {
log.Info().Msg(L("Enabling Hub XML-RPC API container."))
hubXmlrpcImage, err = utils.ComputeImage(globalFlags.Registry, flags.Image.Tag, flags.HubXmlrpc.Image)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion mgradm/cmd/scale/podman.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func podmanScale(
}
if service == podman.HubXmlrpcService {
if newReplicas > 1 {
return errors.New(L("Multiple Hub XML-RPC container replicas are not currently supported."))
return errors.New(L("Multiple Hub XML-RPC API container replicas are not currently supported."))
}
return podman.ScaleService(newReplicas, service)
}
Expand Down
2 changes: 1 addition & 1 deletion mgradm/cmd/upgrade/kubernetes/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ func upgradeKubernetes(
cmd *cobra.Command,
args []string,
) error {
return kubernetes.Upgrade(globalFlags, &flags.Image, &flags.DbUpgradeImage, &flags.HubXmlrpc.Image, flags.Helm, cmd, args)
return kubernetes.Upgrade(globalFlags, &flags.Image, &flags.DbUpgradeImage, &flags.HubXmlrpc, flags.Helm, cmd, args)
}
8 changes: 4 additions & 4 deletions mgradm/shared/kubernetes/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func Deploy(
isK3s := clusterInfos.IsK3s()
IsRke2 := clusterInfos.IsRke2()
if !prepare {
tcpPorts, udpPorts := CompilePortLists(hubXmlrpcFlags.Replicas > 0, debug)
tcpPorts, udpPorts := GetPortLists(hubXmlrpcFlags.Replicas > 0, debug)
if isK3s {
kubernetes.InstallK3sTraefikConfig(tcpPorts, udpPorts)
} else if IsRke2 {
Expand Down Expand Up @@ -129,7 +129,7 @@ func UyuniUpgrade(serverImage string, pullPolicy string, hubXmlrpcReplicas int,
if hubXmlrpcReplicas > 0 {
log.Info().Msg(L("Enabling Hub XMLRPC API container."))
helmParams = append(helmParams,
"--set", fmt.Sprintf("hubXmlrpcRepicas=%v", hubXmlrpcReplicas),
"--set", fmt.Sprintf("hub.api.replicas=%v", hubXmlrpcReplicas),
"--set", "images.hub_xmlrpc="+hubXmlrpcImage)
}
helmParams = append(helmParams, helmArgs...)
Expand Down Expand Up @@ -160,7 +160,7 @@ func Upgrade(

origHubXmlrpcImage, err := kubernetes.GetRunningImage("hub-xmlrpc-api")
if err != nil {
return utils.Errorf(err, L("failed to query Hub XML-RPC container"))
return utils.Errorf(err, L("failed to find Hub XML-RPC API container"))
}

serverImage, err := utils.ComputeImage(globalFlags.Registry, utils.DefaultTag, *image)
Expand Down Expand Up @@ -238,7 +238,7 @@ func Upgrade(
return utils.Errorf(err, L("cannot run post upgrade script"))
}

hubXmlrpcImageName, err := ComputeHubXmlrpcImage(image, hubXmlrpcImage)
hubXmlrpcImageName, err := utils.ComputeImage(globalFlags.Registry, image.Tag, *hubXmlrpcImage)
if err != nil {
return utils.Errorf(err, L("failed to compute image URL"))
}
Expand Down
4 changes: 2 additions & 2 deletions mgradm/shared/kubernetes/k3s.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import (
"github.com/uyuni-project/uyuni-tools/shared/utils"
)

// CompilePortLists returns compiled lists of tcp and udp ports..
func CompilePortLists(hub bool, debug bool) ([]types.PortMap, []types.PortMap) {
// GetPortLists returns compiled lists of tcp and udp ports..
func GetPortLists(hub bool, debug bool) ([]types.PortMap, []types.PortMap) {
tcpPorts := []types.PortMap{}
tcpPorts = append(tcpPorts, utils.TCP_PORTS...)
if debug {
Expand Down
6 changes: 3 additions & 3 deletions shared/kubernetes/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,12 +372,12 @@ func GenerateOverrideDeployment(deployData types.Deployment) (string, error) {
return string(ret), nil
}

// GetRunningImage returns the image running in the current system.
// GetRunningImage returns the image of containerNAme for the server running in the current system.
func GetRunningImage(containerName string) (string, error) {
args := []string{"get", "pods", ServerFilter, "-o", "jsonpath={.items[0].spec.containers[?(@.name=='" + containerName + "')].image}"}
args := []string{"get", "pods", "-A", ServerFilter, "-o", "jsonpath={.items[0].spec.containers[?(@.name=='" + containerName + "')].image}"}
image, err := utils.RunCmdOutput(zerolog.DebugLevel, "kubectl", args...)

log.Info().Msgf(L("%[1]s image is: %[2]s"), containerName, image)
log.Debug().Msgf("%[1]s container image is: %[2]s", containerName, image)
if err != nil {
return "", err
}
Expand Down
2 changes: 1 addition & 1 deletion uyuni-tools.changes.nadvornik.hub-xmlrpc2
Original file line number Diff line number Diff line change
@@ -1 +1 @@
- Improved Hub XML-RPC support
- Handle Hub XML-RPC during migration and upgrade and add Kubernetes support

0 comments on commit efc2084

Please sign in to comment.