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

Merges PRs for SUSE Manager 5.0.1 #405

Merged
merged 51 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
9194529
Use local images for CoCo and Hub containers (bsc#1227586)
rjmateus Jul 9, 2024
16266b6
Use an object to collect the migration data
cbosdo Jul 11, 2024
bbdf967
Create coco attestation service files during migration
lucidd Jun 10, 2024
0429b4b
Fix computing the image URL
cbosdo Jun 24, 2024
1d100a6
Add confidential computing default image in the help
cbosdo Jun 24, 2024
bb4f4fe
Fix the parameters name for the salt-broker image
cbosdo Jul 17, 2024
c9adaba
Create the hub XML-RPC API service in all cases
cbosdo Jul 10, 2024
d5f1a37
Shared the Hub XML-RPC API setup between install and migrate
cbosdo Jul 10, 2024
b868c64
Add testing utility functions
cbosdo Jul 12, 2024
dbaad53
Remove duplicate getContainerImage function
cbosdo Jul 12, 2024
05675d1
Remove the use of --creds in podman pull
cbosdo Jul 15, 2024
c7bf520
Split the inspection scripts based on their usage
cbosdo Jul 12, 2024
f85ef5d
Add the /etc/uyuni/uyuni-tools.yaml path to the config help
cbosdo Jul 12, 2024
0abda94
replace not working Fatal error by plain error return
aaannz Jul 11, 2024
a647877
During installation and migration, validate FQDN (bsc#1226275)
mbussolotto Jul 9, 2024
dd65980
check if FQDN is resolvable
mbussolotto Jul 10, 2024
102e142
return code for mgr script
mbussolotto Jul 10, 2024
20c40db
Update uyuni-tools.changes.mbussolotto.fqdn
mbussolotto Jul 11, 2024
6cd062b
Update utils.go
mbussolotto Jul 15, 2024
d793b5c
Update mgradm/shared/templates/mgrSetupScriptTemplate.go
mbussolotto Jul 16, 2024
d4d7c0e
Preserve PAGER settings from the host
aaannz Jul 8, 2024
d3e0e72
Use shared envvar list inspired by /etc/profile exports
aaannz Jul 9, 2024
a7c36b3
Create config flags for helm charts registry path
cbosdo Jul 8, 2024
a92af03
Use the basename of the SQL file as filename in the container
cbosdo Jul 8, 2024
fceec5d
Strip the new line when checking for IPv6 on podman network
cbosdo Jul 8, 2024
5b947ea
Use the default logger to log the script outputs
cbosdo Jul 8, 2024
f6355d4
Generate the log file to /var/log/uyuni-tools.log if possible.
cbosdo Jul 8, 2024
18bb7d5
Add uyuni-hub-xmlrpc to the list of values in scale's help
cbosdo Jul 5, 2024
0c0d531
Fix random error during installation of CA certificate (bsc#1227245)
nadvornik Jul 4, 2024
75d90e4
Adjusted log level
nadvornik Jul 8, 2024
68a4ccb
Fix password entry usability (bsc#1226437)
nadvornik Jun 25, 2024
eb22db7
Add localization for password confirmation message
nadvornik Jun 26, 2024
0a892e6
Add --prepare option to migrate command
nadvornik Jun 24, 2024
b3dd827
Fix kubernetes
nadvornik Jun 25, 2024
6077264
Break recursion in the help of child commands of flags grouped ones
cbosdo Jun 24, 2024
3ff1e0d
Disable node exporter port for kubernetes
nadvornik Jun 17, 2024
651473d
Fix start, stop and restart in kubernetes
nadvornik Jun 17, 2024
a7b7bff
Increase start timeout
nadvornik Jun 17, 2024
aa572d2
Fix traefik query
nadvornik Jun 20, 2024
8e22be0
Update changelog
nadvornik Jun 20, 2024
541dbd6
support config improvements
mbussolotto May 29, 2024
df9395a
Add mgrpxy cache clear command
rjpmestre Jun 7, 2024
4accdd5
Split the Service.conf file in a generated and a custom one
cbosdo Jul 16, 2024
9ad66e5
Document signing of Git Commits
juliogonzalez Jul 4, 2024
37b80ff
Add org.GetOrganizationDetails API call
aaannz Jun 10, 2024
f6630c5
Check if server container or volumes already exists
aaannz Jun 10, 2024
3c8ae00
Add hub XML-RPC support to mgradm upgrade podman command
cbosdo Jul 18, 2024
feb3e47
Properly restart the coco containers during upgrade
cbosdo Jul 18, 2024
81c5201
Fix lint errors in ptf modules
cbosdo Jul 18, 2024
ae7b98e
Remove unused SanityCheck function
cbosdo Jul 18, 2024
81100e1
Detect if hub XML-RPC API is running on migrated server
cbosdo Jul 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ https://github.com/uyuni-project/uyuni/tree/master/containers/doc/server-kuberne

# Development documentation

## Sign your Git commits

Signing commits with a GPG/SSH key is mandatory for contributing. That way your commits will be marked as verified on GitHub so other people can be confident that the changes come from a trusted source.

If you are not doing it already, check out the [GitHub documentation](https://docs.github.com/en/authentication/managing-commit-signature-verification/about-commit-signature-verification).

## Building

`go build -o ./bin ./...` will produce the binaries in the root folder with `0.0.0` as version.
Expand Down
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ for shell in "bash" "zsh" "fish"; do
./bin/mgrpxy completion ${shell} >> "${COMPLETION_FILE}"
done

golangci-lint run
GOFLAGS="-tags=ptf" golangci-lint run
./check_localizable
echo "DONE"
2 changes: 1 addition & 1 deletion mgradm/cmd/inspect/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func kuberneteInspect(
cmd *cobra.Command,
args []string,
) error {
serverImage, err := utils.ComputeImage(*flags)
serverImage, err := utils.ComputeImage("", utils.DefaultTag, *flags)
if err != nil && len(serverImage) > 0 {
return utils.Errorf(err, L("failed to determine image"))
}
Expand Down
2 changes: 1 addition & 1 deletion mgradm/cmd/inspect/podman.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func podmanInspect(
cmd *cobra.Command,
args []string,
) error {
serverImage, err := utils.ComputeImage(*flags)
serverImage, err := utils.ComputeImage("", utils.DefaultTag, *flags)
if err != nil && len(serverImage) > 0 {
return utils.Errorf(err, L("failed to determine image"))
}
Expand Down
1 change: 0 additions & 1 deletion mgradm/cmd/install/kubernetes/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ NOTE: installing on a remote cluster is not supported yet!
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
var flags kubernetesInstallFlags
flags.Image.Registry = globalFlags.Registry
return utils.CommandHelper(globalFlags, cmd, args, &flags, installForKubernetes)
},
}
Expand Down
8 changes: 7 additions & 1 deletion mgradm/cmd/install/kubernetes/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ func installForKubernetes(globalFlags *types.GlobalFlags,

fqdn := args[0]

if err := shared_utils.IsValidFQDN(fqdn); err != nil {
return err
}

helmArgs := []string{"--set", "timezone=" + flags.TZ}
if flags.Mirror != "" {
// TODO Handle claims for multi-node clusters
Expand All @@ -65,7 +69,9 @@ func installForKubernetes(globalFlags *types.GlobalFlags,
helmArgs = append(helmArgs, sslArgs...)

// Deploy Uyuni and wait for it to be up
if err := kubernetes.Deploy(cnx, &flags.Image, &flags.Helm, &flags.Ssl, clusterInfos, fqdn, flags.Debug.Java, helmArgs...); err != nil {
if err := kubernetes.Deploy(cnx, globalFlags.Registry, &flags.Image, &flags.Helm, &flags.Ssl,
clusterInfos, fqdn, flags.Debug.Java, false, helmArgs...,
); err != nil {
return shared_utils.Errorf(err, L("cannot deploy uyuni"))
}

Expand Down
1 change: 0 additions & 1 deletion mgradm/cmd/install/podman/podman.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ NOTE: installing on a remote podman is not supported yet!
Args: cobra.MaximumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
var flags podmanInstallFlags
flags.Image.Registry = globalFlags.Registry
return utils.CommandHelper(globalFlags, cmd, args, &flags, installForPodman)
},
}
Expand Down
84 changes: 31 additions & 53 deletions mgradm/cmd/install/podman/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package podman

import (
"errors"
"fmt"
"os/exec"
"strings"

Expand All @@ -14,6 +15,7 @@ import (
"github.com/spf13/cobra"
install_shared "github.com/uyuni-project/uyuni-tools/mgradm/cmd/install/shared"
"github.com/uyuni-project/uyuni-tools/mgradm/shared/coco"
"github.com/uyuni-project/uyuni-tools/mgradm/shared/hub"
"github.com/uyuni-project/uyuni-tools/mgradm/shared/podman"
"github.com/uyuni-project/uyuni-tools/shared"
. "github.com/uyuni-project/uyuni-tools/shared/l10n"
Expand All @@ -22,31 +24,6 @@ import (
"github.com/uyuni-project/uyuni-tools/shared/utils"
)

func setupHubXmlrpcContainer(flags *podmanInstallFlags) error {
if flags.HubXmlrpc.Replicas > 0 {
if flags.HubXmlrpc.Replicas > 1 {
return errors.New(L("Multiple Hub XML-RPC container replicas are not currently supported."))
}
log.Info().Msg(L("Enabling Hub XML-RPC API container."))
if flags.HubXmlrpc.Image.Tag == "" {
flags.HubXmlrpc.Image.Tag = flags.Image.Tag
}
hubXmlrpcImage, err := utils.ComputeImage(flags.HubXmlrpc.Image)
if err != nil {
return utils.Errorf(err, L("failed to compute image URL"))
}

if err := podman.GenerateHubXmlrpcSystemdService(hubXmlrpcImage); err != nil {
return utils.Errorf(err, L("cannot generate systemd service"))
}

if err := shared_podman.ScaleService(flags.HubXmlrpc.Replicas, shared_podman.HubXmlrpcService); err != nil {
return utils.Errorf(err, L("cannot enable service"))
}
}
return nil
}

func waitForSystemStart(cnx *shared.Connection, image string, flags *podmanInstallFlags) error {
err := podman.GenerateSystemdService(flags.TZ, image, flags.Debug.Java, flags.Mirror, flags.Podman.Args)
if err != nil {
Expand All @@ -67,34 +44,38 @@ func installForPodman(
cmd *cobra.Command,
args []string,
) error {
flags.CheckParameters(cmd, "podman")
if _, err := exec.LookPath("podman"); err != nil {
return errors.New(L("install podman before running this command"))
hostData, err := shared_podman.InspectHost()
if err != nil {
return err
}

inspectedHostValues, err := utils.InspectHost(false)
authFile, cleaner, err := shared_podman.PodmanLogin(hostData)
if err != nil {
return utils.Errorf(err, L("cannot inspect host values"))
return utils.Errorf(err, L("failed to login to registry.suse.com"))
}
defer cleaner()

fqdn, err := getFqdn(args)
if hostData.HasUyuniServer {
return fmt.Errorf(L("Server is already initialized! Uninstall before attempting new installation or use upgrade command"))
}

flags.CheckParameters(cmd, "podman")
if _, err := exec.LookPath("podman"); err != nil {
return errors.New(L("install podman before running this command"))
}

fqdn, err := utils.GetFqdn(args)
if err != nil {
return err
}
log.Info().Msgf(L("Setting up the server with the FQDN '%s'"), fqdn)

image, err := utils.ComputeImage(flags.Image)
image, err := utils.ComputeImage(globalFlags.Registry, utils.DefaultTag, flags.Image)
if err != nil {
return utils.Errorf(err, L("failed to compute image URL"))
}
pullArgs := []string{}
_, scc_user_exist := inspectedHostValues["host_scc_username"]
_, scc_user_password := inspectedHostValues["host_scc_password"]
if scc_user_exist && scc_user_password {
pullArgs = append(pullArgs, "--creds", inspectedHostValues["host_scc_username"]+":"+inspectedHostValues["host_scc_password"])
}

preparedImage, err := shared_podman.PrepareImage(image, flags.Image.PullPolicy, pullArgs...)
preparedImage, err := shared_podman.PrepareImage(authFile, image, flags.Image.PullPolicy)
if err != nil {
return err
}
Expand Down Expand Up @@ -138,11 +119,20 @@ func installForPodman(
}
}

if err := coco.SetupCocoContainer(flags.Coco.Replicas, flags.Coco.Image, flags.Image, flags.Db.Name, flags.Db.Port, flags.Db.User, flags.Db.Password); err != nil {
if err := coco.SetupCocoContainer(
authFile, flags.Coco.Replicas, globalFlags.Registry, flags.Coco.Image, flags.Image,
flags.Db.Name, flags.Db.Port, flags.Db.User, flags.Db.Password,
); err != nil {
return err
}

if err := setupHubXmlrpcContainer(flags); err != nil {
if err := hub.SetupHubXmlrpc(
authFile, globalFlags.Registry, flags.Image.PullPolicy, flags.Image.Tag, flags.HubXmlrpc.Image,
); err != nil {
return err
}

if err := hub.EnableHubXmlrpc(flags.HubXmlrpc.Replicas); err != nil {
return err
}

Expand All @@ -157,15 +147,3 @@ func installForPodman(
}
return nil
}

func getFqdn(args []string) (string, error) {
if len(args) == 1 {
return args[0], nil
} else {
fqdn_b, err := utils.RunCmdOutput(zerolog.DebugLevel, "hostname", "-f")
if err != nil {
return "", utils.Errorf(err, L("failed to compute server FQDN"))
}
return strings.TrimSpace(string(fqdn_b)), nil
}
}
27 changes: 3 additions & 24 deletions mgradm/cmd/install/shared/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ package shared
import (
"fmt"
"net/mail"
"path"
"regexp"
"strings"

Expand Down Expand Up @@ -51,12 +50,6 @@ type CocoFlags struct {
Image types.ImageFlags `mapstructure:",squash"`
}

// HubXmlrpcFlags contains settings for Hub XMLRPC container.
type HubXmlrpcFlags struct {
Replicas int
Image types.ImageFlags `mapstructure:",squash"`
}

// InstallFlags stores all the flags used by install command.
type InstallFlags struct {
TZ string
Expand All @@ -72,7 +65,7 @@ type InstallFlags struct {
Debug DebugFlags
Image types.ImageFlags `mapstructure:",squash"`
Coco CocoFlags
HubXmlrpc HubXmlrpcFlags
HubXmlrpc cmd_utils.HubXmlrpcFlags
Admin apiTypes.User
Organization string
}
Expand Down Expand Up @@ -214,23 +207,9 @@ func AddInstallFlags(cmd *cobra.Command) {
cmd.Flags().Bool("debug-java", false, L("Enable tomcat and taskomatic remote debugging"))
cmd_utils.AddImageFlag(cmd)

cmd_utils.AddContainerImageFlags(cmd, "coco", L("confidential computing attestation"))
cmd.Flags().Int("coco-replicas", 0, L("How many replicas of the confidential computing container should be started. (only 0 or 1 supported for now)"))

_ = utils.AddFlagHelpGroup(cmd, &utils.Group{ID: "coco-container", Title: L("Confidential Computing Flags")})
_ = utils.AddFlagToHelpGroupID(cmd, "coco-replicas", "coco-container")
_ = utils.AddFlagToHelpGroupID(cmd, "coco-image", "coco-container")
_ = utils.AddFlagToHelpGroupID(cmd, "coco-tag", "coco-container")

cmd.Flags().Int("hubxmlrpc-replicas", 0, L("How many replicas of the Hub XML-RPC API service container should be started. (only 0 or 1 supported for now)"))
hubXmlrpcImage := path.Join(utils.DefaultNamespace, "server-hub-xmlrpc-api")
cmd.Flags().String("hubxmlrpc-image", hubXmlrpcImage, L("Hub XML-RPC API Image"))
cmd.Flags().String("hubxmlrpc-tag", utils.DefaultTag, L("Hub XML-RPC API Image Tag"))
cmd_utils.AddCocoFlag(cmd)

_ = utils.AddFlagHelpGroup(cmd, &utils.Group{ID: "hubxmlrpc-container", Title: L("Hub XML-RPC API")})
_ = utils.AddFlagToHelpGroupID(cmd, "hubxmlrpc-replicas", "hubxmlrpc-container")
_ = utils.AddFlagToHelpGroupID(cmd, "hubxmlrpc-image", "hubxmlrpc-container")
_ = utils.AddFlagToHelpGroupID(cmd, "hubxmlrpc-tag", "hubxmlrpc-container")
cmd_utils.AddHubXmlrpcFlags(cmd)

cmd.Flags().String("admin-login", "admin", L("Administrator user name"))
cmd.Flags().String("admin-password", "", L("Administrator password"))
Expand Down
46 changes: 43 additions & 3 deletions mgradm/cmd/install/shared/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
package shared

import (
"errors"
"net/url"
"os"
"path/filepath"
"strconv"
Expand All @@ -24,6 +26,13 @@ const setup_name = "setup.sh"

// RunSetup execute the setup.
func RunSetup(cnx *shared.Connection, flags *InstallFlags, fqdn string, env map[string]string) error {
// Containers should be running now, check storage if it is using volume from already configured server
preconfigured := false
if isServerConfigured(cnx) {
log.Warn().Msg(L("Server appears to be already configured. Installation will continue, but installation options may be ignored."))
preconfigured = true
}

tmpFolder := generateSetupScript(flags, fqdn, env)
defer os.RemoveAll(tmpFolder)

Expand All @@ -46,10 +55,37 @@ func RunSetup(cnx *shared.Connection, flags *InstallFlags, fqdn string, env map[
apiCnx := api.ConnectionDetails{
Server: fqdn,
Insecure: false,
User: flags.Admin.Login,
Password: flags.Admin.Password,
}
_, err := org.CreateFirst(&apiCnx, flags.Organization, &flags.Admin)
if err != nil {
return err

// Check if there is already admin user with given password and organization with same name
if _, err := api.Init(&apiCnx); err == nil {
if _, err := org.GetOrganizationDetails(&apiCnx, flags.Organization); err == nil {
log.Info().Msgf(L("Server organization already exists, reusing"))
} else {
log.Debug().Err(err).Msg("Error returned by server")
log.Warn().Msgf(L("Administration user already exists, but organization %s could not be found"), flags.Organization)
}
} else {
var connError *url.Error
if errors.As(err, &connError) {
// We were not able to connect to the server at all
return err
}
// We do not have any user existing, do not try to login
apiCnx = api.ConnectionDetails{
Server: fqdn,
Insecure: false,
}
_, err := org.CreateFirst(&apiCnx, flags.Organization, &flags.Admin)
if err != nil {
if preconfigured {
log.Warn().Msgf(L("Administration user already exists, but provided credentials are not valid"))
} else {
return err
}
}
}
}

Expand Down Expand Up @@ -137,3 +173,7 @@ func boolToString(value bool) string {
}
return "N"
}

func isServerConfigured(cnx *shared.Connection) bool {
return cnx.TestExistenceInPod("/root/.MANAGER_SETUP_COMPLETE")
}
2 changes: 0 additions & 2 deletions mgradm/cmd/migrate/kubernetes/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ NOTE: migrating to a remote cluster is not supported yet!
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
var flags kubernetesMigrateFlags
flags.Image.Registry = globalFlags.Registry
flags.DbUpgradeImage.Registry = globalFlags.Registry
return utils.CommandHelper(globalFlags, cmd, args, &flags, migrateToKubernetes)
},
}
Expand Down
Loading