Skip to content

Commit d95b92e

Browse files
committed
fix: add patch local provisioing cluster status for rancher v2.9.x
Signed-off-by: PoAn Yang <[email protected]>
1 parent 7f98289 commit d95b92e

File tree

3 files changed

+23
-7
lines changed

3 files changed

+23
-7
lines changed

pkg/plan/bootstrap.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ package plan
33
import (
44
"context"
55
"fmt"
6-
"strings"
76

87
"github.com/rancher/system-agent/pkg/applyinator"
8+
"golang.org/x/mod/semver"
99

1010
"github.com/rancher/rancherd/pkg/cacerts"
1111
"github.com/rancher/rancherd/pkg/config"
@@ -131,12 +131,16 @@ func (p *plan) addInstructions(cfg *config.Config, dataDir string) error {
131131
return err
132132
}
133133

134+
if err := p.addInstruction(rancher.ToDeleteRancherWebhookValidationConfiguration(k8sVersion)); err != nil {
135+
return err
136+
}
137+
134138
if err := p.addInstruction(resources.ToInstruction(cfg.RancherInstallerImage, cfg.SystemDefaultRegistry, k8sVersion, dataDir)); err != nil {
135139
return err
136140
}
137141

138-
// currently instruction is only needed for v2.8.x
139-
if strings.HasPrefix(cfg.RancherVersion, "v2.8") {
142+
// currently instruction is needed for version above v2.8.x
143+
if semver.Compare(cfg.RancherVersion, "v2.8.0") >= 0 {
140144
if err := p.addInstruction(rancher.PatchLocalProvisioningClusterStatus(cfg.RancherInstallerImage, cfg.SystemDefaultRegistry, k8sVersion)); err != nil {
141145
return err
142146
}

pkg/rancher/wait.go

+15-1
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,20 @@ func ToScaleUpFleetControllerInstruction(_, _, k8sVersion string) (*applyinator.
124124
}, nil
125125
}
126126

127+
func ToDeleteRancherWebhookValidationConfiguration(k8sVersion string) (*applyinator.Instruction, error) {
128+
cmd, err := self.Self()
129+
if err != nil {
130+
return nil, fmt.Errorf("resolving location of %s: %w", os.Args[0], err)
131+
}
132+
return &applyinator.Instruction{
133+
Name: "delete-rancher-webhook-validation-configuration",
134+
SaveOutput: true,
135+
Args: []string{"retry", kubectl.Command(k8sVersion), "delete", "validatingwebhookconfiguration", "rancher.cattle.io"},
136+
Env: kubectl.Env(k8sVersion),
137+
Command: cmd,
138+
}, nil
139+
}
140+
127141
// Needs to patch status subresource
128142
// k patch cluster.provisioning local -n fleet-local --subresource=status --type=merge --patch '{"status":{"fleetWorkspaceName": "fleet-local"}}'
129143
func PatchLocalProvisioningClusterStatus(_, _, k8sVersion string) (*applyinator.Instruction, error) {
@@ -132,7 +146,7 @@ func PatchLocalProvisioningClusterStatus(_, _, k8sVersion string) (*applyinator.
132146
return nil, fmt.Errorf("resolving location of %s: %w", os.Args[0], err)
133147
}
134148
return &applyinator.Instruction{
135-
Name: "wait-suc-plan-resolved",
149+
Name: "patch-provisioning-cluster-status",
136150
SaveOutput: true,
137151
Args: []string{"retry", kubectl.Command(k8sVersion), "-n", "fleet-local", "patch", "cluster.provisioning", "local", "--subresource=status", "--type=merge", "--patch", "{\"status\":{\"fleetWorkspaceName\": \"fleet-local\"}}"},
138152
Env: kubectl.Env(k8sVersion),

pkg/resources/resources.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,7 @@ func ToBootstrapFile(config *config.Config, path string) (*applyinator.File, err
107107
},
108108
"spec": map[string]interface{}{
109109
"kubernetesVersion": k8sVersion,
110-
"rkeConfig": map[string]interface{}{
111-
"controlPlaneConfig": config.ConfigValues,
112-
},
110+
"rkeConfig": map[string]interface{}{},
113111
},
114112
},
115113
}, v1.GenericMap{

0 commit comments

Comments
 (0)