Skip to content

Commit 8961506

Browse files
authored
Merge pull request #35 from ibrokethecloud/support-v2.8.1
instructions to patch local cluster resource for v2.8.1
2 parents 1ae847b + 805ca0a commit 8961506

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

pkg/plan/bootstrap.go

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

78
"github.com/rancher/system-agent/pkg/applyinator"
89

@@ -134,6 +135,13 @@ func (p *plan) addInstructions(cfg *config.Config, dataDir string) error {
134135
return err
135136
}
136137

138+
// currently instruction is only needed for v2.8.x
139+
if strings.HasPrefix(cfg.RancherVersion, "v2.8") {
140+
if err := p.addInstruction(rancher.PatchLocalProvisioningClusterStatus(cfg.RancherInstallerImage, cfg.SystemDefaultRegistry, k8sVersion)); err != nil {
141+
return err
142+
}
143+
}
144+
137145
if err := p.addInstruction(rancher.ToWaitSUCInstruction(cfg.RancherInstallerImage, cfg.SystemDefaultRegistry, k8sVersion)); err != nil {
138146
return err
139147
}

pkg/rancher/wait.go

+16
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,19 @@ func ToScaleUpFleetControllerInstruction(imageOverride, systemDefaultRegistry, k
123123
Command: cmd,
124124
}, nil
125125
}
126+
127+
// Needs to patch status subresource
128+
// k patch cluster.provisioning local -n fleet-local --subresource=status --type=merge --patch '{"status":{"fleetWorkspaceName": "fleet-local"}}'
129+
func PatchLocalProvisioningClusterStatus(imageOverride, systemDefaultRegistry, k8sVersion string) (*applyinator.Instruction, error) {
130+
cmd, err := self.Self()
131+
if err != nil {
132+
return nil, fmt.Errorf("resolving location of %s: %w", os.Args[0], err)
133+
}
134+
return &applyinator.Instruction{
135+
Name: "wait-suc-plan-resolved",
136+
SaveOutput: true,
137+
Args: []string{"retry", kubectl.Command(k8sVersion), "-n", "fleet-local", "patch", "cluster.provisioning", "local", "--subresource=status", "--type=merge", "--patch", "{\"status\":{\"fleetWorkspaceName\": \"fleet-local\"}}"},
138+
Env: kubectl.Env(k8sVersion),
139+
Command: cmd,
140+
}, nil
141+
}

pkg/resources/resources.go

+3
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ func ToBootstrapFile(config *config.Config, path string) (*applyinator.File, err
102102
"metadata": map[string]interface{}{
103103
"name": "local",
104104
"namespace": "fleet-local",
105+
"labels": map[string]interface{}{
106+
"provisioning.cattle.io/management-cluster-name": "local",
107+
},
105108
},
106109
"spec": map[string]interface{}{
107110
"kubernetesVersion": k8sVersion,

0 commit comments

Comments
 (0)