@@ -128,8 +128,17 @@ var _ = g.Describe(fmt.Sprintf("[sig-arch][Late][Jira:%q]", "kube-apiserver"), g
128128 // Skip metal jobs if test image pullspec cannot be determined
129129 if jobType .Platform != "metal" || err == nil {
130130 o .Expect (err ).NotTo (o .HaveOccurred ())
131- onDiskPKIContent , err = fetchOnDiskCertificates (ctx , kubeClient , oc .AdminConfig (), masters , openshiftTestImagePullSpec )
132- o .Expect (err ).NotTo (o .HaveOccurred ())
131+
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 ) {
135+ readyMasters , _ := filterReadyNodes (masters )
136+ onDiskPKIContent , err = fetchOnDiskCertificates (ctx , kubeClient , oc .AdminConfig (), readyMasters , openshiftTestImagePullSpec )
137+ o .Expect (err ).NotTo (o .HaveOccurred ())
138+ } else {
139+ onDiskPKIContent , err = fetchOnDiskCertificates (ctx , kubeClient , oc .AdminConfig (), masters , openshiftTestImagePullSpec )
140+ o .Expect (err ).NotTo (o .HaveOccurred ())
141+ }
133142 }
134143
135144 actualPKIContent = certgraphanalysis .MergePKILists (ctx , inClusterPKIContent , onDiskPKIContent )
@@ -160,14 +169,13 @@ var _ = g.Describe(fmt.Sprintf("[sig-arch][Late][Jira:%q]", "kube-apiserver"), g
160169 o .Expect (err ).NotTo (o .HaveOccurred ())
161170
162171 pkiDir := filepath .Join (exutil .ArtifactDirPath (), "rawTLSInfo" )
163- err = os .MkdirAll (pkiDir , 0755 )
172+ err = os .MkdirAll (pkiDir , 0o755 )
164173 o .Expect (err ).NotTo (o .HaveOccurred ())
165- err = os .WriteFile (filepath .Join (pkiDir , tlsArtifactFilename ), jsonBytes , 0644 )
174+ err = os .WriteFile (filepath .Join (pkiDir , tlsArtifactFilename ), jsonBytes , 0o644 )
166175 o .Expect (err ).NotTo (o .HaveOccurred ())
167176 })
168177
169178 g .It ("all tls artifacts must be registered" , func () {
170-
171179 violationsPKIContent , err := certs .GetPKIInfoFromEmbeddedOwnership (ownership .PKIViolations )
172180 o .Expect (err ).NotTo (o .HaveOccurred ())
173181
@@ -181,7 +189,6 @@ var _ = g.Describe(fmt.Sprintf("[sig-arch][Late][Jira:%q]", "kube-apiserver"), g
181189
182190 _ , err := certgraphutils .LocateCertKeyPairBySecretLocation (currLocation , expectedPKIContent .CertKeyPairs )
183191 if err != nil {
184-
185192 newTLSRegistry .CertKeyPairs = append (newTLSRegistry .CertKeyPairs , certgraphapi.PKIRegistryCertKeyPair {InClusterLocation : & actualPKIContent .InClusterResourceData .CertKeyPairs [i ]})
186193 }
187194
@@ -269,11 +276,11 @@ var _ = g.Describe(fmt.Sprintf("[sig-arch][Late][Jira:%q]", "kube-apiserver"), g
269276 if len (newTLSRegistry .CertKeyPairs ) > 0 || len (newTLSRegistry .CertificateAuthorityBundles ) > 0 {
270277 registryString , err := json .MarshalIndent (newTLSRegistry , "" , " " )
271278 if err != nil {
272- //g.Fail("Failed to marshal registry %#v: %v", newTLSRegistry, err)
279+ // g.Fail("Failed to marshal registry %#v: %v", newTLSRegistry, err)
273280 testresult .Flakef ("Failed to marshal registry %#v: %v" , newTLSRegistry , err )
274281 }
275282 // TODO: uncomment when test no longer fails and enhancement is merged
276- //g.Fail(fmt.Sprintf("Unregistered TLS certificates:\n%s", registryString))
283+ // g.Fail(fmt.Sprintf("Unregistered TLS certificates:\n%s", registryString))
277284 testresult .Flakef ("Unregistered TLS certificates found:\n %s\n See tls/ownership/README.md in origin repo" , registryString )
278285 }
279286 })
@@ -285,7 +292,7 @@ var _ = g.Describe(fmt.Sprintf("[sig-arch][Late][Jira:%q]", "kube-apiserver"), g
285292
286293 if len (messages ) > 0 {
287294 // TODO: uncomment when test no longer fails and enhancement is merged
288- //g.Fail(strings.Join(messages, "\n"))
295+ // g.Fail(strings.Join(messages, "\n"))
289296 testresult .Flakef ("%s" , strings .Join (messages , "\n " ))
290297 }
291298 })
@@ -323,7 +330,6 @@ var _ = g.Describe(fmt.Sprintf("[sig-arch][Late][Jira:%q]", "kube-apiserver"), g
323330 testresult .Flakef ("Errors found: %s" , utilerrors .NewAggregate (errs ).Error ())
324331 }
325332 })
326-
327333})
328334
329335func fetchOnDiskCertificates (ctx context.Context , kubeClient kubernetes.Interface , podRESTConfig * rest.Config , nodeList []* corev1.Node , testPullSpec string ) (* certgraphapi.PKIList , error ) {
@@ -480,3 +486,21 @@ func isCertKeyPairFromIgnoredNamespace(cert certgraphapi.CertKeyPair, ignoredNam
480486 }
481487 return false
482488}
489+
490+ func filterReadyNodes (nodes []* corev1.Node ) (ready []* corev1.Node , notReady []string ) {
491+ for _ , n := range nodes {
492+ isReady := false
493+ for _ , c := range n .Status .Conditions {
494+ if c .Type == corev1 .NodeReady && c .Status == corev1 .ConditionTrue {
495+ isReady = true
496+ break
497+ }
498+ }
499+ if isReady {
500+ ready = append (ready , n )
501+ } else {
502+ notReady = append (notReady , n .Name )
503+ }
504+ }
505+ return ready , notReady
506+ }
0 commit comments