Skip to content

Commit

Permalink
Upgrade env var
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
  • Loading branch information
dvaldivia committed Oct 14, 2021
1 parent 2256769 commit 930e47a
Showing 1 changed file with 42 additions and 8 deletions.
50 changes: 42 additions & 8 deletions pkg/controller/cluster/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ import (
)

const (
version420 = "v4.2.0"
version424 = "v4.2.4"
version428 = "v4.2.8"
version429 = "v4.2.9"
version420 = "v4.2.0"
version424 = "v4.2.4"
version428 = "v4.2.8"
version429 = "v4.2.9"
version4215 = "v4.2.15"
)

type upgradeFunction func(ctx context.Context, tenant *miniov2.Tenant) (*miniov2.Tenant, error)
Expand All @@ -44,10 +45,11 @@ func (c *Controller) checkForUpgrades(ctx context.Context, tenant *miniov2.Tenan

var upgradesToDo []string
upgrades := map[string]upgradeFunction{
version420: c.upgrade420,
version424: c.upgrade424,
version428: c.upgrade428,
version429: c.upgrade429,
version420: c.upgrade420,
version424: c.upgrade424,
version428: c.upgrade428,
version429: c.upgrade429,
version4215: c.upgrade4215,
}

// if the version is empty, do all upgrades
Expand All @@ -56,6 +58,7 @@ func (c *Controller) checkForUpgrades(ctx context.Context, tenant *miniov2.Tenan
upgradesToDo = append(upgradesToDo, version424)
upgradesToDo = append(upgradesToDo, version428)
upgradesToDo = append(upgradesToDo, version429)
upgradesToDo = append(upgradesToDo, version4215)
} else {
currentSyncVersion, err := version.NewVersion(tenant.Status.SyncVersion)
if err != nil {
Expand All @@ -67,6 +70,7 @@ func (c *Controller) checkForUpgrades(ctx context.Context, tenant *miniov2.Tenan
version424,
version428,
version429,
version4215,
}
for _, v := range versionsThatNeedUpgrades {
vp, _ := version.NewVersion(v)
Expand Down Expand Up @@ -277,3 +281,33 @@ func (c *Controller) upgrade429(ctx context.Context, tenant *miniov2.Tenant) (*m

return c.updateTenantSyncVersion(ctx, tenant, version429)
}

// Upgrades the sync version to v4.2.15
// in this version we renamed MINIO_QUERY_AUTH_TOKEN to MINIO_LOG_QUERY_AUTH_TOKEN.
func (c *Controller) upgrade4215(ctx context.Context, tenant *miniov2.Tenant) (*miniov2.Tenant, error) {
logSearchSecret, err := c.kubeClientSet.CoreV1().Secrets(tenant.Namespace).Get(ctx, tenant.LogSecretName(), metav1.GetOptions{})
if err != nil && !k8serrors.IsNotFound(err) {
return nil, err
}

if k8serrors.IsNotFound(err) {
klog.Infof("%s has no log secret", tenant.Name)
} else {
secretChanged := false
if _, ok := logSearchSecret.Data["MINIO_QUERY_AUTH_TOKEN"]; ok {
logSearchSecret.Data["MINIO_LOG_QUERY_AUTH_TOKEN"] = logSearchSecret.Data["MINIO_QUERY_AUTH_TOKEN"]
delete(logSearchSecret.Data, "MINIO_QUERY_AUTH_TOKEN")
secretChanged = true
}

if secretChanged {
_, err = c.kubeClientSet.CoreV1().Secrets(tenant.Namespace).Update(ctx, logSearchSecret, metav1.UpdateOptions{})
if err != nil {
return nil, err
}
}

}

return c.updateTenantSyncVersion(ctx, tenant, version420)
}

0 comments on commit 930e47a

Please sign in to comment.