Skip to content

Commit 4bf314e

Browse files
Neilhamzaopenshift-cherrypick-robot
authored andcommitted
add env var gate for degraded mode
Signed-off-by: nhamza <nhamza@redhat.com>
1 parent 59dcdec commit 4bf314e

3 files changed

Lines changed: 18 additions & 11 deletions

File tree

cmd/openshift-tests/openshift-tests.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,15 @@ func main() {
6363
os.Unsetenv("ENABLE_STORAGE_GCE_PD_DRIVER")
6464
}
6565

66+
// Detect intentionally degraded clusters (e.g. TNF degraded) based on
67+
// CI-provided environment signals and propagate that context to extended tests
68+
if os.Getenv("DEGRADED_NODE") == "true" {
69+
exutil.ClusterDegraded = true
70+
logrus.Infof("openshift-tests targeting intentionally degraded cluster")
71+
}
72+
6673
pflag.CommandLine.SetNormalizeFunc(utilflag.WordSepNormalizeFunc)
67-
//pflag.CommandLine.AddGoFlagSet(goflag.CommandLine)
74+
// pflag.CommandLine.AddGoFlagSet(goflag.CommandLine)
6875

6976
extensionRegistry, originExtension, err := extensions.InitializeOpenShiftTestsExtensionFramework()
7077
if err != nil {

test/extended/operators/certs.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import (
3232
"github.com/openshift/library-go/pkg/certs/cert-inspection/certgraphutils"
3333
"github.com/openshift/library-go/pkg/operator/resource/resourceread"
3434

35-
configv1 "github.com/openshift/api/config/v1"
3635
"github.com/openshift/origin/pkg/certs"
3736
"github.com/openshift/origin/pkg/monitortestlibrary/platformidentification"
3837
testresult "github.com/openshift/origin/pkg/test/ginkgo/result"
@@ -129,10 +128,10 @@ var _ = g.Describe(fmt.Sprintf("[sig-arch][Late][Jira:%q]", "kube-apiserver"), g
129128
// Skip metal jobs if test image pullspec cannot be determined
130129
if jobType.Platform != "metal" || err == nil {
131130
o.Expect(err).NotTo(o.HaveOccurred())
132-
topo, topoErr := exutil.GetControlPlaneTopology(oc)
133-
o.Expect(topoErr).NotTo(o.HaveOccurred())
134131

135-
if *topo == configv1.DualReplicaTopologyMode {
132+
// Only relax on-disk cert collection when the cluster is intentionally degraded
133+
// and the topology is Two-Node Fencing (DualReplica).
134+
if exutil.ClusterDegraded && exutil.IsTwoNodeFencing(ctx, configClient) {
136135
readyMasters, _ := filterReadyNodes(masters)
137136
onDiskPKIContent, err = fetchOnDiskCertificates(ctx, kubeClient, oc.AdminConfig(), readyMasters, openshiftTestImagePullSpec)
138137
o.Expect(err).NotTo(o.HaveOccurred())

test/extended/util/framework.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,6 @@ func WaitForOpenShiftNamespaceImageStreams(oc *CLI) error {
327327

328328
// Check to see if SamplesOperator managementState is Removed
329329
out, err := oc.AsAdmin().Run("get").Args("configs.samples.operator.openshift.io", "cluster", "-o", "yaml").Output()
330-
331330
if err != nil {
332331
e2e.Logf("\n error on getting samples operator CR: %+v\n%#v\n", err, out)
333332
}
@@ -781,7 +780,7 @@ func VarSubOnFile(srcFile string, destFile string, vars map[string]string) error
781780
k = "${" + k + "}"
782781
srcString = strings.Replace(srcString, k, v, -1) // -1 means unlimited replacements
783782
}
784-
err = ioutil.WriteFile(destFile, []byte(srcString), 0644)
783+
err = ioutil.WriteFile(destFile, []byte(srcString), 0o644)
785784
}
786785
return err
787786
}
@@ -1654,11 +1653,11 @@ func restoreFixtureAsset(dir, name string) error {
16541653
if err != nil {
16551654
return err
16561655
}
1657-
err = os.MkdirAll(assetFilePath(dir, filepath.Dir(name)), os.FileMode(0755))
1656+
err = os.MkdirAll(assetFilePath(dir, filepath.Dir(name)), os.FileMode(0o755))
16581657
if err != nil {
16591658
return err
16601659
}
1661-
err = ioutil.WriteFile(assetFilePath(dir, name), data, 0640)
1660+
err = ioutil.WriteFile(assetFilePath(dir, name), data, 0o640)
16621661
if err != nil {
16631662
return err
16641663
}
@@ -1990,10 +1989,10 @@ type GitRepo struct {
19901989
// AddAndCommit commits a file with its content to local repo
19911990
func (r GitRepo) AddAndCommit(file, content string) error {
19921991
dir := filepath.Dir(file)
1993-
if err := os.MkdirAll(filepath.Join(r.RepoPath, dir), 0777); err != nil {
1992+
if err := os.MkdirAll(filepath.Join(r.RepoPath, dir), 0o777); err != nil {
19941993
return err
19951994
}
1996-
if err := ioutil.WriteFile(filepath.Join(r.RepoPath, file), []byte(content), 0666); err != nil {
1995+
if err := ioutil.WriteFile(filepath.Join(r.RepoPath, file), []byte(content), 0o666); err != nil {
19971996
return err
19981997
}
19991998
if err := r.repo.Add(r.RepoPath, file); err != nil {
@@ -2347,6 +2346,8 @@ func IsTwoNodeFencing(ctx context.Context, configClient clientconfigv1.Interface
23472346
return infrastructure.Status.ControlPlaneTopology == configv1.DualReplicaTopologyMode
23482347
}
23492348

2349+
var ClusterDegraded bool
2350+
23502351
func groupName(groupVersionName string) string {
23512352
return strings.Split(groupVersionName, "/")[0]
23522353
}

0 commit comments

Comments
 (0)