Skip to content

Commit

Permalink
fix: parsing release tags upon server update response
Browse files Browse the repository at this point in the history
fixes #812
  • Loading branch information
harshavardhana committed Feb 6, 2022
1 parent 86a57b5 commit 4f879fe
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
12 changes: 10 additions & 2 deletions pkg/apis/minio.min.io/v2/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,21 @@ func (t *Tenant) KESReplicas() int32 {
}

const (
minioReleaseTagTimeLayout = "2006-01-02T15-04-05Z"
releasePrefix = "RELEASE"
minioReleaseTagTimeLayout = "2006-01-02T15-04-05Z"
minioReleaseTagTimeLayoutBackup = "2006-01-02T15:04:05Z"
releasePrefix = "RELEASE"
)

// ReleaseTagToReleaseTime - converts a 'RELEASE.2017-09-29T19-16-56Z.hotfix' into the build time
func ReleaseTagToReleaseTime(releaseTag string) (releaseTime time.Time, err error) {
fields := strings.Split(releaseTag, ".")
if len(fields) == 1 {
releaseTime, err = time.Parse(minioReleaseTagTimeLayout, fields[0])
if err != nil {
return time.Parse(minioReleaseTagTimeLayoutBackup, fields[0])
}
return releaseTime, nil
}
if len(fields) < 2 || len(fields) > 3 {
return releaseTime, fmt.Errorf("%s is not a valid release tag", releaseTag)
}
Expand Down
6 changes: 2 additions & 4 deletions pkg/controller/cluster/main-controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1063,15 +1063,13 @@ func (c *Controller) syncHandler(key string) error {
}

if us.CurrentVersion != us.UpdatedVersion {
klog.Infof("Updating '%s' MinIO from: %s, to: %s",
tenantName, us.CurrentVersion, us.UpdatedVersion)
// In case the upgrade is from an older version to RELEASE.2021-07-27T02-40-15Z (which introduced
// MinIO server integrated with Console), we need to delete the old console deployment and service.
// We do this only when MinIO server is successfully updated and
// We do this only when MinIO server is successfully updated.
unifiedConsoleReleaseTime, _ := miniov2.ReleaseTagToReleaseTime("RELEASE.2021-07-27T02-40-15Z")
newVer, err := miniov2.ReleaseTagToReleaseTime(us.UpdatedVersion)
if err != nil {
klog.Errorf("Unsupported release tag on new image, non-disruptive update not allowed %w", err)
klog.Errorf("Unsupported release tag on new image, server updated but might leave dangling console deployment %v", err)
return err
}
consoleDeployment, err := c.deploymentLister.Deployments(tenant.Namespace).Get(tenant.ConsoleDeploymentName())
Expand Down

0 comments on commit 4f879fe

Please sign in to comment.