Skip to content

Commit f2f9f29

Browse files
committed
Vibe coding recovery logic
1 parent 2c5f58f commit f2f9f29

40 files changed

+6793
-258
lines changed

go.mod

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ require (
5353
github.com/lestrrat/go-jsschema v0.0.0-20181205002244-5c81c58ffcc3
5454
github.com/lithammer/dedent v1.1.0
5555
github.com/mattn/go-sqlite3 v1.14.30
56+
github.com/metal3-io/baremetal-operator/apis v0.11.0
5657
github.com/metallb/frr-k8s v0.0.15
5758
github.com/microsoftgraph/msgraph-sdk-go v1.81.0
5859
github.com/onsi/ginkgo/v2 v2.23.3
@@ -78,7 +79,7 @@ require (
7879
github.com/spf13/pflag v1.0.6-0.20210604193023-d5e0c0615ace
7980
github.com/spf13/viper v1.8.1
8081
github.com/stretchr/objx v0.5.2
81-
github.com/stretchr/testify v1.10.0
82+
github.com/stretchr/testify v1.11.1
8283
github.com/tecbiz-ch/nutanix-go-sdk v0.1.15
8384
github.com/tidwall/gjson v1.18.0
8485
github.com/tidwall/pretty v1.2.0
@@ -100,9 +101,9 @@ require (
100101
gopkg.in/src-d/go-git.v4 v4.13.1
101102
gopkg.in/yaml.v2 v2.4.0
102103
gopkg.in/yaml.v3 v3.0.1
103-
k8s.io/api v0.33.4
104+
k8s.io/api v0.33.5
104105
k8s.io/apiextensions-apiserver v0.33.4
105-
k8s.io/apimachinery v0.33.4
106+
k8s.io/apimachinery v0.33.5
106107
k8s.io/apiserver v0.33.4
107108
k8s.io/cli-runtime v0.33.4
108109
k8s.io/client-go v0.33.4
@@ -398,7 +399,7 @@ require (
398399
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.2 // indirect
399400
sigs.k8s.io/cloud-provider-azure/pkg/azclient v0.0.29 // indirect
400401
sigs.k8s.io/cloud-provider-azure/pkg/azclient/configloader v0.0.16 // indirect
401-
sigs.k8s.io/controller-runtime v0.19.0 // indirect
402+
sigs.k8s.io/controller-runtime v0.21.0 // indirect
402403
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect
403404
sigs.k8s.io/kube-storage-version-migrator v0.0.6-0.20230721195810-5c8923c5ff96 // indirect
404405
sigs.k8s.io/kustomize/api v0.19.0 // indirect

go.sum

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,8 @@ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWE
707707
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
708708
github.com/mattn/go-sqlite3 v1.14.30 h1:bVreufq3EAIG1Quvws73du3/QgdeZ3myglJlrzSYYCY=
709709
github.com/mattn/go-sqlite3 v1.14.30/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
710+
github.com/metal3-io/baremetal-operator/apis v0.11.0 h1:sYxjnObegWnDyz028m5Rc6gVYxbSLlvjOAqo6Iq1vOE=
711+
github.com/metal3-io/baremetal-operator/apis v0.11.0/go.mod h1:T0v/wKeJeUfVFeTq1sihv76IZEE2Bn+hqKkh5kGMxA4=
710712
github.com/metallb/frr-k8s v0.0.15 h1:6M3UGhovX1EFoaSGjrRD7djUAx3w2I+g81FH8OVtHkM=
711713
github.com/metallb/frr-k8s v0.0.15/go.mod h1:TjrGoAf+v00hYGlI8jUdyDxY5udMAOs2GWwrvLWnA4E=
712714
github.com/microsoft/kiota-abstractions-go v1.9.3 h1:cqhbqro+VynJ7kObmo7850h3WN2SbvoyhypPn8uJ1SE=
@@ -986,8 +988,8 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
986988
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
987989
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
988990
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
989-
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
990-
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
991+
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
992+
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
991993
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
992994
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
993995
github.com/tecbiz-ch/nutanix-go-sdk v0.1.15 h1:ZT5I6OFGswvMceujUE10ZXPNnT5UQIW9gAX4FEFK6Ds=
@@ -1592,8 +1594,8 @@ sigs.k8s.io/cloud-provider-azure/pkg/azclient v0.0.29 h1:qiifAaaBqV3d/EcN9dKJaJI
15921594
sigs.k8s.io/cloud-provider-azure/pkg/azclient v0.0.29/go.mod h1:ZFAt0qF1kR+w8nBVJK56s6CFvLrlosN1i2c+Sxb7LBk=
15931595
sigs.k8s.io/cloud-provider-azure/pkg/azclient/configloader v0.0.16 h1:Fm/Yjv4nXjUtJ90uXKSKwPwaTWYuDFMhDNNOd77PlOg=
15941596
sigs.k8s.io/cloud-provider-azure/pkg/azclient/configloader v0.0.16/go.mod h1:+kl90flu4+WCP6HBGVYbKVQR+5ztDzUNrWJz8rsnvRU=
1595-
sigs.k8s.io/controller-runtime v0.19.0 h1:nWVM7aq+Il2ABxwiCizrVDSlmDcshi9llbaFbC0ji/Q=
1596-
sigs.k8s.io/controller-runtime v0.19.0/go.mod h1:iRmWllt8IlaLjvTTDLhRBXIEtkCK6hwVBJJsYS9Ajf4=
1597+
sigs.k8s.io/controller-runtime v0.21.0 h1:CYfjpEuicjUecRk+KAeyYh+ouUBn4llGyDYytIGcJS8=
1598+
sigs.k8s.io/controller-runtime v0.21.0/go.mod h1:OSg14+F65eWqIu4DceX7k/+QRAbTTvxeQSNSOQpukWM=
15971599
sigs.k8s.io/gateway-api v1.2.1 h1:fZZ/+RyRb+Y5tGkwxFKuYuSRQHu9dZtbjenblleOLHM=
15981600
sigs.k8s.io/gateway-api v1.2.1/go.mod h1:EpNfEXNjiYfUJypf0eZ0P5iXA9ekSGWaS1WgPaM42X0=
15991601
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 h1:gBQPwqORJ8d8/YNZWEjoZs7npUVDpVXUUOFfW6CgAqE=

pkg/clioptions/clusterdiscovery/cluster.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ import (
3030
"github.com/openshift/origin/test/extended/util/azure"
3131
)
3232

33+
// HypervisorConfig contains configuration for hypervisor-based recovery operations
34+
type HypervisorConfig struct {
35+
HypervisorIP string `json:"hypervisorIP"`
36+
SSHUser string `json:"sshUser"`
37+
PrivateKey string `json:"privateKey"`
38+
}
39+
3340
type ClusterConfiguration struct {
3441
ProviderName string `json:"type"`
3542

@@ -76,6 +83,9 @@ type ClusterConfiguration struct {
7683
// IsNoOptionalCapabilities indicates the cluster has no optional capabilities enabled
7784
HasNoOptionalCapabilities bool
7885

86+
// HypervisorConfig contains SSH configuration for hypervisor-based recovery operations
87+
HypervisorConfig *HypervisorConfig
88+
7989
// APIGroups contains the set of API groups available in the cluster
8090
APIGroups sets.Set[string] `json:"-"`
8191
// EnabledFeatureGates contains the set of enabled feature gates in the cluster

pkg/cmd/openshift-tests/run/flags.go

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package run
22

33
import (
4+
"encoding/json"
5+
"fmt"
46
"os"
57

68
"github.com/openshift-eng/openshift-tests-extension/pkg/extension"
@@ -28,9 +30,6 @@ type RunSuiteFlags struct {
2830
ToImage string
2931
TestOptions []string
3032

31-
// Shared by initialization code
32-
config *clusterdiscovery.ClusterConfiguration
33-
3433
genericclioptions.IOStreams
3534
}
3635

@@ -84,7 +83,7 @@ func (f *RunSuiteFlags) ToOptions(args []string, availableSuites []*testginkgo.T
8483
// shallow copy to mutate
8584
ginkgoOptions := f.GinkgoRunSuiteOptions
8685

87-
providerConfig, err := f.SuiteWithKubeTestInitializationPreSuite()
86+
clusterConfig, err := f.SuiteWithKubeTestInitializationPreSuite()
8887
if err != nil {
8988
return nil, err
9089
}
@@ -95,13 +94,39 @@ func (f *RunSuiteFlags) ToOptions(args []string, availableSuites []*testginkgo.T
9594
return nil, err
9695
}
9796

97+
// Parse hypervisor configuration if provided and set it in environment for test context
98+
if f.GinkgoRunSuiteOptions.WithHypervisorConfigJSON != "" {
99+
// Validate the JSON format
100+
var hypervisorConfig clusterdiscovery.HypervisorConfig
101+
if err := json.Unmarshal([]byte(f.GinkgoRunSuiteOptions.WithHypervisorConfigJSON), &hypervisorConfig); err != nil {
102+
return nil, fmt.Errorf("failed to parse hypervisor configuration JSON: %v", err)
103+
}
104+
105+
// Validate required fields
106+
if hypervisorConfig.HypervisorIP == "" {
107+
return nil, fmt.Errorf("hypervisorIP is required in hypervisor configuration")
108+
}
109+
if hypervisorConfig.SSHUser == "" {
110+
return nil, fmt.Errorf("sshUser is required in hypervisor configuration")
111+
}
112+
if hypervisorConfig.PrivateKey == "" {
113+
return nil, fmt.Errorf("privateKey is required in hypervisor configuration")
114+
}
115+
116+
// Set the hypervisor configuration in the cluster config
117+
clusterConfig.HypervisorConfig = &hypervisorConfig
118+
119+
// Also set it in environment for test context access
120+
os.Setenv("HYPERVISOR_CONFIG", f.GinkgoRunSuiteOptions.WithHypervisorConfigJSON)
121+
}
122+
98123
o := &RunSuiteOptions{
99124
GinkgoRunSuiteOptions: ginkgoOptions,
100125
Suite: suite,
101126
Extension: internalExtension,
102-
ClusterConfig: providerConfig,
127+
ClusterConfig: clusterConfig,
103128
FromRepository: f.FromRepository,
104-
CloudProviderJSON: providerConfig.ToJSONString(),
129+
CloudProviderJSON: clusterConfig.ToJSONString(),
105130
CloseFn: closeFn,
106131
IOStreams: f.IOStreams,
107132
}

pkg/cmd/openshift-tests/run/options.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ type RunSuiteOptions struct {
3131
CloseFn iooptions.CloseFunc
3232
genericclioptions.IOStreams
3333

34+
// HypervisorConfig contains SSH configuration for hypervisor-based recovery operations
35+
// If set, will run recovery tests that require the hypervisor-based recovery, such as
36+
// the node replacement test in the two_node recovery suite.
37+
HypervisorConfig *clusterdiscovery.HypervisorConfig
38+
3439
// ClusterConfig contains cluster-specific configuration for filtering tests
3540
ClusterConfig *clusterdiscovery.ClusterConfiguration
3641

pkg/test/filters/cluster_state.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ func NewClusterStateFilter(config *clusterdiscovery.ClusterConfiguration) *Clust
6767
skips = append(skips, "[Skipped:NoOptionalCapabilities]")
6868
}
6969

70+
if config.HypervisorConfig == nil {
71+
skips = append(skips, "[Requires:HypervisorSSHConfig]")
72+
}
73+
7074
logrus.WithField("skips", skips).Info("Generated skips for cluster state")
7175

7276
return &ClusterStateFilter{

pkg/test/ginkgo/cmd_runsuite.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ type GinkgoRunSuiteOptions struct {
9696

9797
// RetryStrategy controls retry behavior and final outcome decisions
9898
RetryStrategy RetryStrategy
99+
100+
// WithHypervisorConfigJSON contains JSON configuration for hypervisor-based recovery operations
101+
WithHypervisorConfigJSON string
99102
}
100103

101104
func NewGinkgoRunSuiteOptions(streams genericclioptions.IOStreams) *GinkgoRunSuiteOptions {
@@ -133,6 +136,7 @@ func (o *GinkgoRunSuiteOptions) BindFlags(flags *pflag.FlagSet) {
133136
flags.StringVar(&o.ShardStrategy, "shard-strategy", o.ShardStrategy, "Which strategy to use for sharding (hash)")
134137
availableStrategies := getAvailableRetryStrategies()
135138
flags.Var(newRetryStrategyFlag(&o.RetryStrategy), "retry-strategy", fmt.Sprintf("Test retry strategy (available: %s, default: %s)", strings.Join(availableStrategies, ", "), defaultRetryStrategy))
139+
flags.StringVar(&o.WithHypervisorConfigJSON, "with-hypervisor-json", os.Getenv("HYPERVISOR_CONFIG"), "JSON configuration for hypervisor-based recovery operations. Must contain hypervisorIP, sshUser, and privateKey fields.")
136140
}
137141

138142
func (o *GinkgoRunSuiteOptions) Validate() error {

0 commit comments

Comments
 (0)