Skip to content

Commit cf48a5c

Browse files
authored
Fix registry IP during restores (#240)
* fix 'non-ha' logic * fix docker-registry unit test * refactor for readability
1 parent f517c6f commit cf48a5c

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

controllers/helm.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ func updateInfraChartsFromInstall(ctx context.Context, in *v1beta1.Installation,
123123
if in == nil {
124124
return charts
125125
}
126+
serviceCIDR := util.ClusterServiceCIDR(clusterConfig, in)
126127

127128
for i, chart := range charts {
128129
if chart.Name == "admin-console" {
@@ -182,11 +183,11 @@ func updateInfraChartsFromInstall(ctx context.Context, in *v1beta1.Installation,
182183
charts[i].Values = newVals
183184
}
184185
if chart.Name == "docker-registry" {
185-
if !in.Spec.AirGap || !in.Spec.HighAvailability {
186+
if !in.Spec.AirGap {
186187
continue
187188
}
188189

189-
serviceCIDR := util.ClusterServiceCIDR(clusterConfig, in)
190+
// handle the registry IP, which will always be present in airgap
190191
registryEndpoint, err := registry.GetRegistryServiceIP(serviceCIDR)
191192
if err != nil {
192193
log.Error(err, "failed to get registry endpoint", "chart", chart.Name)
@@ -197,7 +198,13 @@ func updateInfraChartsFromInstall(ctx context.Context, in *v1beta1.Installation,
197198
if err != nil {
198199
log.Error(err, "failed to set helm values service.clusterIP", "chart", chart.Name)
199200
}
201+
charts[i].Values = newVals
202+
203+
if !in.Spec.HighAvailability {
204+
continue
205+
}
200206

207+
// handle the seaweedFS endpoint, which will only be present in HA airgap
201208
seaweedfsS3Endpoint, err := registry.GetSeaweedfsS3Endpoint(serviceCIDR)
202209
if err != nil {
203210
log.Error(err, "failed to get seaweedfs s3 endpoint", "chart", chart.Name)

controllers/helm_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1463,20 +1463,21 @@ func Test_updateInfraChartsFromInstall(t *testing.T) {
14631463
ClusterID: "testid",
14641464
BinaryName: "testbin",
14651465
AirGap: true,
1466+
Network: &v1beta1.NetworkSpec{ServiceCIDR: "1.2.0.0/16"},
14661467
},
14671468
},
14681469
clusterConfig: k0sv1beta1.ClusterConfig{},
14691470
charts: []k0sv1beta1.Chart{
14701471
{
14711472
Name: "docker-registry",
1472-
Values: "this: that\nand: another\n",
1473+
Values: "this: that\nand: another\nservice:\n clusterIP: \"abc\"\n",
14731474
},
14741475
},
14751476
},
14761477
want: []k0sv1beta1.Chart{
14771478
{
14781479
Name: "docker-registry",
1479-
Values: "this: that\nand: another\n",
1480+
Values: "and: another\nservice:\n clusterIP: 1.2.0.11\nthis: that\n",
14801481
},
14811482
},
14821483
},

0 commit comments

Comments
 (0)