Преглед изворни кода

add correct stack revision update

Mohammed Nafees пре 3 година
родитељ
комит
7f0b15da0e

+ 2 - 0
api/server/handlers/stack/helpers.go

@@ -72,6 +72,7 @@ type updateAppResourceTagOpts struct {
 	namespace  string
 	cluster    *models.Cluster
 	registries []*models.Registry
+	stack      *models.Stack
 }
 
 func updateAppResourceTag(opts *updateAppResourceTagOpts) error {
@@ -93,6 +94,7 @@ func updateAppResourceTag(opts *updateAppResourceTagOpts) error {
 		Repo:       opts.config.Repo,
 		Registries: opts.registries,
 		Values:     rel.Config,
+		Stack:      opts.stack,
 	}
 
 	_, err = opts.helmAgent.UpgradeReleaseByValues(conf, opts.config.DOConf)

+ 9 - 0
api/server/handlers/stack/update_source_put.go

@@ -98,6 +98,14 @@ func (p *StackPutSourceConfigHandler) ServeHTTP(w http.ResponseWriter, r *http.R
 
 	deployErrs := make([]string, 0)
 
+	// read the stack again to get the latest revision info
+	stack, err = p.Repo().Stack().ReadStackByStringID(proj.ID, stack.UID)
+
+	if err != nil {
+		p.HandleAPIError(w, r, apierrors.NewErrInternal(err))
+		return
+	}
+
 	for i, appResource := range clonedAppResources {
 		// get the corresponding source config tag
 		var imageTag string
@@ -119,6 +127,7 @@ func (p *StackPutSourceConfigHandler) ServeHTTP(w http.ResponseWriter, r *http.R
 			namespace:  namespace,
 			cluster:    cluster,
 			registries: registries,
+			stack:      stack,
 		})
 
 		if err != nil {

+ 1 - 1
internal/helm/agent.go

@@ -227,7 +227,7 @@ func (a *Agent) UpgradeReleaseByValues(
 		conf.Values["stack"] = map[string]interface{}{
 			"enabled":  true,
 			"name":     conf.Stack.Name,
-			"revision": conf.Stack.Revisions[0].RevisionNumber,
+			"revision": conf.Stack.Revisions[0].RevisionNumber + 1,
 		}
 	}