Skip to content

Commit 1d9cb63

Browse files
authored
Merge pull request #2716 from mschoenlaub/fix-cache-usage-for-helm
fix: remote cache key should consider helm release name
2 parents 7c8b944 + 2fe8e56 commit 1d9cb63

2 files changed

Lines changed: 30 additions & 4 deletions

File tree

pkg/devspace/deploy/deployer/helm/deploy.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func (d *DeployConfig) Deploy(ctx devspacecontext.Context, forceDeploy bool) (bo
6969
}
7070

7171
// Ensure deployment config is there
72-
deployCache, _ := ctx.Config().RemoteCache().GetDeployment(d.DeploymentConfig.Name)
72+
deployCache, _ := ctx.Config().RemoteCache().GetDeployment(releaseName)
7373

7474
// Check values files for changes
7575
helmOverridesHash := ""
@@ -158,14 +158,14 @@ func (d *DeployConfig) Deploy(ctx devspacecontext.Context, forceDeploy bool) (bo
158158
if rootName, ok := values.RootNameFrom(ctx.Context()); ok && !stringutil.Contains(deployCache.Projects, rootName) {
159159
deployCache.Projects = append(deployCache.Projects, rootName)
160160
}
161-
ctx.Config().RemoteCache().SetDeployment(d.DeploymentConfig.Name, deployCache)
161+
ctx.Config().RemoteCache().SetDeployment(releaseName, deployCache)
162162
return true, nil
163163
}
164164

165165
if rootName, ok := values.RootNameFrom(ctx.Context()); ok && !stringutil.Contains(deployCache.Projects, rootName) {
166166
deployCache.Projects = append(deployCache.Projects, rootName)
167167
}
168-
ctx.Config().RemoteCache().SetDeployment(d.DeploymentConfig.Name, deployCache)
168+
ctx.Config().RemoteCache().SetDeployment(releaseName, deployCache)
169169
return false, nil
170170
}
171171

@@ -191,7 +191,7 @@ func (d *DeployConfig) internalDeploy(ctx devspacecontext.Context, overwriteValu
191191
return nil, nil
192192
}
193193

194-
ctx.Log().Infof("Deploying chart %s (%s) with helm...", d.DeploymentConfig.Helm.Chart.Name, d.DeploymentConfig.Name)
194+
ctx.Log().Infof("Deploying chart %s (%s) with helm...", d.DeploymentConfig.Helm.Chart.Name, releaseName)
195195
valuesOut, _ := yaml.Marshal(overwriteValues)
196196
ctx.Log().Debugf("Deploying chart with values:\n %v\n", string(valuesOut))
197197

pkg/devspace/deploy/deployer/helm/deploy_test.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ type deployTestCase struct {
2727
// builtImages map[string]string
2828
releasesBefore []*helmtypes.Release
2929
deployment string
30+
releaseName string
3031
chart string
3132
valuesFiles []string
3233
values map[string]interface{}
@@ -82,6 +83,30 @@ func TestDeploy(t *testing.T) {
8283
},
8384
},
8485
},
86+
{
87+
name: "Deploy one deployment with different release name",
88+
deployment: "deploy2",
89+
chart: ".",
90+
values: map[string]interface{}{
91+
"val": "fromVal",
92+
},
93+
releaseName: "deploy2-special",
94+
expectedDeployed: true,
95+
expectedCache: &remotecache.RemoteCache{
96+
Deployments: []remotecache.DeploymentCache{
97+
{
98+
Name: "deploy2-special",
99+
DeploymentConfigHash: "aca018bdc51747a41d18361a2a678bb64fd36f834d62303b538dcdbb50c5b410",
100+
Helm: &remotecache.HelmCache{
101+
Release: "deploy2-special",
102+
ReleaseNamespace: "testNamespace",
103+
ReleaseRevision: "1",
104+
ValuesHash: "efd6e101b768968a49f8dba46ef07785ac530ea9f75c4f9ca5733e223b6a4da1",
105+
},
106+
},
107+
},
108+
},
109+
},
85110
}
86111

87112
for _, testCase := range testCases {
@@ -106,6 +131,7 @@ func TestDeploy(t *testing.T) {
106131
Chart: &latest.ChartConfig{
107132
Name: testCase.chart,
108133
},
134+
ReleaseName: testCase.releaseName,
109135
ValuesFiles: testCase.valuesFiles,
110136
Values: testCase.values,
111137
},

0 commit comments

Comments
 (0)