Skip to content

Commit

Permalink
PRODENG-2789 don't validate MCR version (#522)
Browse files Browse the repository at this point in the history
* PRODENG-2789 don't validate MCR version

- we no longer validate installed MCR version compared to config spec version string
- make the EnsureMCR function responsible for updating metadata (simplify, dedup)

WHY?

MCR versions installed no longer match the spec string, so we can't tell if the version
installed was the expected version, nor can we tell if there is a newer version that
can be installed, so we always run the install script, and never test
version.

ALSO:

- fixed the full smoke GH action, as the branches were cleaned up and
  renamed

Signed-off-by: James Nesbitt <[email protected]>
  • Loading branch information
james-nesbitt authored Nov 27, 2024
1 parent 1979518 commit 1ad92ca
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 25 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/smoke-test-full.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ name: Smoke Full Test
on:
push:
branches:
- master
- v1.5.9-release-branch
- main
paths:
- '**.go'
- '**.tf'
Expand Down
18 changes: 11 additions & 7 deletions pkg/mcr/mcr.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ package mcr
import (
"fmt"

"github.com/Mirantis/mcc/pkg/constant"
"github.com/Mirantis/mcc/pkg/product/mke/api"
log "github.com/sirupsen/logrus"
)

func EnsureMCRVersion(h *api.Host, specMcrVersion string) error {
// EnsureMCRVersion ensure that MCR is running after install/upgrade, and update the host information
// @NOTE will reboot the machine if MCR isn't detected, and MCR can be force restarted if desired (I could drop the mcr restart, but I kept it in case we want a run-time flag for it.)
// @SEE PRODENG-2789 : we no longer perform version checks, as the MCR versions don't always match the spec string.
func EnsureMCRVersion(h *api.Host, specMcrVersion string, forceMCRRestart bool) error {
currentVersion, err := h.MCRVersion()
if err != nil {
if err := h.Reboot(); err != nil {
Expand All @@ -17,8 +20,7 @@ func EnsureMCRVersion(h *api.Host, specMcrVersion string) error {
if err != nil {
return fmt.Errorf("%s: failed to query container runtime version after installation: %w", h, err)
}
}
if currentVersion != specMcrVersion {
} else if !forceMCRRestart {
err = h.Configurer.RestartMCR(h)
if err != nil {
return fmt.Errorf("%s: failed to restart container runtime: %w", h, err)
Expand All @@ -28,8 +30,10 @@ func EnsureMCRVersion(h *api.Host, specMcrVersion string) error {
return fmt.Errorf("%s: failed to query container runtime version after restart: %w", h, err)
}
}
if currentVersion != specMcrVersion {
return fmt.Errorf("%s: %w: container runtime version not %s after upgrade", h, constant.ErrVersionMismatch, specMcrVersion)
}

log.Infof("%s: MCR version %s (requested: %s)", h, currentVersion, specMcrVersion)
h.Metadata.MCRVersion = currentVersion
h.Metadata.MCRRestartRequired = false

return nil
}
13 changes: 5 additions & 8 deletions pkg/product/mke/phase/install_mcr.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (p *InstallMCR) Run() error {
}

func (p *InstallMCR) installMCR(h *api.Host) error {
err := retry.Do(
if err := retry.Do(
func() error {
log.Infof("%s: installing container runtime (%s)", h, p.Config.Spec.MCR.Version)
if err := h.Configurer.InstallMCR(h, h.Metadata.MCRInstallScript, p.Config.Spec.MCR); err != nil {
Expand All @@ -62,22 +62,19 @@ func (p *InstallMCR) installMCR(h *api.Host) error {
}
return nil
},
)
if err != nil {
); err != nil {
return fmt.Errorf("retry count exceeded: %w", err)
}

if err := h.AuthorizeDocker(); err != nil {
return fmt.Errorf("%s: failed to authorize docker: %w", h, err)
}
err = mcr.EnsureMCRVersion(h, p.Config.Spec.MCR.Version)
if err != nil {

// check MCR is running, maybe rebooting and updating metadata (don't bother restarting MCR, as we just installed/started it
if err := mcr.EnsureMCRVersion(h, p.Config.Spec.MCR.Version, false); err != nil {
return fmt.Errorf("failed while attempting to ensure the installed version %w", err)
}

log.Infof("%s: mirantis container runtime version %s installed", h, p.Config.Spec.MCR.Version)
h.Metadata.MCRVersion = p.Config.Spec.MCR.Version
h.Metadata.MCRRestartRequired = false
h.Metadata.MCRInstalled = true
return nil
}
13 changes: 5 additions & 8 deletions pkg/product/mke/phase/upgrade_mcr.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,26 +163,23 @@ func (p *UpgradeMCR) upgradeMCRs() error {
}

func (p *UpgradeMCR) upgradeMCR(h *api.Host) error {
err := retry.Do(
if err := retry.Do(
func() error {
log.Infof("%s: upgrading container runtime (%s -> %s)", h, h.Metadata.MCRVersion, p.Config.Spec.MCR.Version)
if err := h.Configurer.InstallMCR(h, h.Metadata.MCRInstallScript, p.Config.Spec.MCR); err != nil {
return fmt.Errorf("%s: failed to install container runtime: %w", h, err)
}
return nil
},
)
if err != nil {
); err != nil {
log.Errorf("%s: failed to update container runtime -> %s", h, err.Error())
return fmt.Errorf("retry count exceeded: %w", err)
}
err = mcr.EnsureMCRVersion(h, p.Config.Spec.MCR.Version)
if err != nil {

// check MCR is running, and updating metadata
if err := mcr.EnsureMCRVersion(h, p.Config.Spec.MCR.Version, false); err != nil {
return fmt.Errorf("failed while attempting to ensure the installed version: %w", err)
}

log.Infof("%s: upgraded to mirantis container runtime version %s", h, p.Config.Spec.MCR.Version)
h.Metadata.MCRVersion = p.Config.Spec.MCR.Version
h.Metadata.MCRRestartRequired = false
return nil
}

0 comments on commit 1ad92ca

Please sign in to comment.