Skip to content

Commit

Permalink
always get template uuid from version/release even if version/release…
Browse files Browse the repository at this point in the history
… is not changed

IF the previous upgrade (from 1.29 to 1.30) fails, the updated value of version/release is still persisted (tf provider behaviour because we don't set version/release in k8s resource READ). Hence when we re-try the upgrade, this piece of code detect no changes in version/release parameter => tf tries to get template uuid from service_template_uuid (which is just the current template of the cluster), hence no upgrade happens.
  • Loading branch information
nvthongswansea committed Jan 2, 2025
1 parent 2c5a458 commit 6bebae8
Showing 1 changed file with 10 additions and 22 deletions.
32 changes: 10 additions & 22 deletions gridscale/resource_gridscale_k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -427,30 +427,18 @@ func deriveK8sTemplateFromResourceData(client *gsclient.Client, d *schema.Resour
releaseInterface, isReleaseSet := d.GetOk("release")
release := releaseInterface.(string)

if !d.IsNewResource() { // case if update of resource is requested
if isVersionSet && d.HasChange("version") {
derivationTypesRequested += 1
derivationType = "version"
}

if isReleaseSet && d.HasChange("release") {
derivationTypesRequested += 1
derivationType = "release"
}
} else { // case if creation of resource is requested
if isVersionSet {
derivationTypesRequested += 1
derivationType = "version"
}
if isVersionSet {
derivationTypesRequested += 1
derivationType = "version"
}

if isReleaseSet {
derivationTypesRequested += 1
derivationType = "release"
}
if isReleaseSet {
derivationTypesRequested += 1
derivationType = "release"
}

if derivationTypesRequested == 0 {
return nil, errors.New("either \"release\" or \"gsk_version\" has to be defined")
}
if derivationTypesRequested == 0 {
return nil, errors.New("either \"release\" or \"gsk_version\" has to be defined")
}

if derivationTypesRequested > 1 {
Expand Down

0 comments on commit 6bebae8

Please sign in to comment.