@@ -4,23 +4,14 @@ package cvo
44
55import (
66 "context"
7- "fmt"
8- "os"
9- "path/filepath"
10- "time"
117
128 g "github.com/onsi/ginkgo/v2"
139 o "github.com/onsi/gomega"
1410
15- apierrors "k8s.io/apimachinery/pkg/api/errors"
1611 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
17- "k8s.io/apimachinery/pkg/util/sets"
1812 "k8s.io/client-go/kubernetes"
1913 "k8s.io/client-go/rest"
2014
21- "github.com/openshift/library-go/pkg/manifest"
22-
23- "github.com/openshift/cluster-version-operator/pkg/cvo/external/dynamicclient"
2415 "github.com/openshift/cluster-version-operator/pkg/external"
2516 "github.com/openshift/cluster-version-operator/test/oc"
2617 ocapi "github.com/openshift/cluster-version-operator/test/oc/api"
@@ -108,54 +99,4 @@ var _ = g.Describe(`[Jira:"Cluster Version Operator"] cluster-version-operator`,
10899 sccAnnotation := cvoPod .Annotations ["openshift.io/scc" ]
109100 o .Expect (sccAnnotation ).To (o .Equal ("hostaccess" ), "Expected the annotation 'openshift.io/scc annotation' on pod %s to have the value 'hostaccess', but got %s" , cvoPod .Name , sccAnnotation )
110101 })
111-
112- g .It (`should not install resources annotated with release.openshift.io/delete=true` , g .Label ("Conformance" , "High" , "42543" ), func () {
113- ctx := context .Background ()
114- err := util .SkipIfHypershift (ctx , restCfg )
115- o .Expect (err ).NotTo (o .HaveOccurred (), "Failed to determine if cluster is HyperShift" )
116- err = util .SkipIfMicroshift (ctx , restCfg )
117- o .Expect (err ).NotTo (o .HaveOccurred (), "Failed to determine if cluster is MicroShift" )
118-
119- // Initialize the ocapi.OC instance
120- g .By ("Setting up oc" )
121- ocClient , err := oc .NewOC (ocapi.Options {Logger : logger , Timeout : 90 * time .Second })
122- o .Expect (err ).NotTo (o .HaveOccurred ())
123-
124- g .By ("Extracting manifests in the release" )
125- annotation := "release.openshift.io/delete"
126- tempDir , err := os .MkdirTemp ("" , "OTA-42543-manifest-" )
127- o .Expect (err ).NotTo (o .HaveOccurred (), "create temp manifest dir failed" )
128- manifestDir := ocapi.ReleaseExtractOptions {To : tempDir }
129- logger .Info (fmt .Sprintf ("Extract manifests to: %s" , manifestDir .To ))
130- defer func () { _ = os .RemoveAll (manifestDir .To ) }()
131- err = ocClient .AdmReleaseExtract (manifestDir )
132- o .Expect (err ).NotTo (o .HaveOccurred (), "extracting manifests failed" )
133-
134- files , err := os .ReadDir (manifestDir .To )
135- o .Expect (err ).NotTo (o .HaveOccurred ())
136- g .By (fmt .Sprintf ("Checking if getting manifests with %s on the cluster led to not-found error" , annotation ))
137- ignore := sets .New ("release-metadata" , "image-references" )
138- for _ , manifestFile := range files {
139- if manifestFile .IsDir () || ignore .Has (manifestFile .Name ()) {
140- continue
141- }
142- filePath := filepath .Join (manifestDir .To , manifestFile .Name ())
143- o .Expect (err ).NotTo (o .HaveOccurred (), "failed to read manifest file" )
144- manifests , err := manifest .ManifestsFromFiles ([]string {filePath })
145- o .Expect (err ).NotTo (o .HaveOccurred (), fmt .Sprintf ("failed to parse manifest file: %s" , filePath ))
146-
147- for _ , ms := range manifests {
148- ann := ms .Obj .GetAnnotations ()
149- if ann [annotation ] != "true" {
150- continue
151- }
152- client , err := dynamicclient .New (restCfg , ms .GVK , ms .Obj .GetNamespace ())
153- o .Expect (err ).NotTo (o .HaveOccurred ())
154- _ , err = client .Get (ctx , ms .Obj .GetName (), metav1.GetOptions {})
155- o .Expect (apierrors .IsNotFound (err )).To (o .BeTrue (),
156- fmt .Sprintf ("The deleted manifest should not be installed, but actually installed: manifest: %s %s in namespace %s from file %q, error: %v" ,
157- ms .GVK , ms .Obj .GetName (), ms .Obj .GetNamespace (), ms .OriginalFilename , err ))
158- }
159- }
160- })
161102})
0 commit comments