- 
                Notifications
    You must be signed in to change notification settings 
- Fork 48
NO-JIRA: Add initial support for CAPI Nutanix provider #383
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Open
      
      
            abhay-nutanix
  wants to merge
  3
  commits into
  openshift:main
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
abhay-nutanix:nutanixInfraChange
  
      
      
   
  
    
  
  
  
 
  
      
    base: main
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
  
     Open
                    Changes from 2 commits
      Commits
    
    
            Show all changes
          
          
            3 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      
    File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,131 @@ | ||
| package e2e | ||
|         
                  abhay-nutanix marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
|  | ||
| import ( | ||
| nutanixv1 "github.com/nutanix-cloud-native/cluster-api-provider-nutanix/api/v1beta1" | ||
| . "github.com/onsi/ginkgo/v2" | ||
| . "github.com/onsi/gomega" | ||
| configv1 "github.com/openshift/api/config/v1" | ||
| "github.com/openshift/cluster-capi-operator/e2e/framework" | ||
| clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" | ||
| "sigs.k8s.io/controller-runtime/pkg/client" | ||
| ) | ||
|  | ||
| var _ = Describe("Cluster API Nutanix InfraCluster", Ordered, func() { | ||
| var nutanixCluster *nutanixv1.NutanixCluster | ||
|  | ||
| BeforeAll(func() { | ||
| if platform != configv1.NutanixPlatformType { | ||
| Skip("Skipping Nutanix E2E tests") | ||
| } | ||
| }) | ||
|  | ||
| AfterEach(func() { | ||
| if platform != configv1.NutanixPlatformType { | ||
| // Because AfterEach always runs, even when tests are skipped, we have to | ||
| // explicitly skip it here for other platforms. | ||
| Skip("Skipping Nutanix E2E tests") | ||
| } | ||
| }) | ||
|  | ||
| It("should have a NutanixCluster created by the infracluster controller", func() { | ||
| By("Fetching the NutanixCluster object") | ||
| nutanixCluster = &nutanixv1.NutanixCluster{} | ||
| err := cl.Get(ctx, client.ObjectKey{ | ||
| Name: clusterName, | ||
| Namespace: framework.CAPINamespace, | ||
| }, nutanixCluster) | ||
| Expect(err).ToNot(HaveOccurred(), "should be able to get the NutanixCluster") | ||
| Expect(nutanixCluster).ToNot(BeNil()) | ||
| }) | ||
|  | ||
| It("should have the correct ManagedBy annotation", func() { | ||
| By("Validating the ManagedBy annotation") | ||
| Expect(nutanixCluster.Annotations).To(HaveKey(clusterv1.ManagedByAnnotation)) | ||
| Expect(nutanixCluster.Annotations[clusterv1.ManagedByAnnotation]).To(Equal(managedByAnnotationValueClusterCAPIOperatorInfraClusterController)) | ||
| }) | ||
|  | ||
| It("should have the control plane endpoint configured", func() { | ||
| By("Validating control plane endpoint") | ||
| Expect(nutanixCluster.Spec.ControlPlaneEndpoint.Host).ToNot(BeEmpty(), "control plane endpoint host should not be empty") | ||
| Expect(nutanixCluster.Spec.ControlPlaneEndpoint.Port).To(BeNumerically(">", 0), "control plane endpoint port should be greater than 0") | ||
| }) | ||
|  | ||
| It("should have PrismCentral configuration if specified in Infrastructure", func() { | ||
| By("Checking Infrastructure for Nutanix PrismCentral configuration") | ||
| if mapiInfrastructure.Spec.PlatformSpec.Nutanix != nil && | ||
| mapiInfrastructure.Spec.PlatformSpec.Nutanix.PrismCentral.Address != "" { | ||
| By("Validating PrismCentral configuration in NutanixCluster") | ||
| Expect(nutanixCluster.Spec.PrismCentral).ToNot(BeNil(), "PrismCentral should be configured") | ||
| Expect(nutanixCluster.Spec.PrismCentral.Address).To(Equal(mapiInfrastructure.Spec.PlatformSpec.Nutanix.PrismCentral.Address)) | ||
| Expect(nutanixCluster.Spec.PrismCentral.Port).To(Equal(mapiInfrastructure.Spec.PlatformSpec.Nutanix.PrismCentral.Port)) | ||
| } | ||
| }) | ||
|  | ||
| It("should have failure domains configured if specified in Infrastructure", func() { | ||
| By("Checking Infrastructure for Nutanix failure domains") | ||
| if mapiInfrastructure.Spec.PlatformSpec.Nutanix != nil && | ||
| len(mapiInfrastructure.Spec.PlatformSpec.Nutanix.FailureDomains) > 0 { | ||
| By("Validating failure domains in NutanixCluster") | ||
| Expect(nutanixCluster.Spec.ControlPlaneFailureDomains).ToNot(BeEmpty(), "failure domains should be configured") | ||
| Expect(len(nutanixCluster.Spec.ControlPlaneFailureDomains)).To(Equal(len(mapiInfrastructure.Spec.PlatformSpec.Nutanix.FailureDomains))) | ||
|  | ||
| // Verify that each failure domain from Infrastructure is present in NutanixCluster | ||
| infraFDNames := make(map[string]bool) | ||
| for _, fd := range mapiInfrastructure.Spec.PlatformSpec.Nutanix.FailureDomains { | ||
| infraFDNames[fd.Name] = true | ||
| } | ||
|  | ||
| for _, fd := range nutanixCluster.Spec.ControlPlaneFailureDomains { | ||
| Expect(infraFDNames).To(HaveKey(fd.Name), "failure domain %s should exist in Infrastructure spec", fd.Name) | ||
| } | ||
| } | ||
| }) | ||
|  | ||
| It("should eventually become ready", func() { | ||
| By("Waiting for NutanixCluster to become ready") | ||
| Eventually(func() bool { | ||
| updatedCluster := &nutanixv1.NutanixCluster{} | ||
| err := cl.Get(ctx, client.ObjectKey{ | ||
| Name: clusterName, | ||
| Namespace: framework.CAPINamespace, | ||
| }, updatedCluster) | ||
| if err != nil { | ||
| return false | ||
| } | ||
| return updatedCluster.Status.Ready | ||
| }, framework.WaitLong).Should(BeTrue(), "NutanixCluster should eventually become ready") | ||
| }) | ||
| }) | ||
|  | ||
| var _ = Describe("Cluster API Nutanix Cluster", Ordered, func() { | ||
| var capiCluster *clusterv1.Cluster | ||
|  | ||
| BeforeAll(func() { | ||
| if platform != configv1.NutanixPlatformType { | ||
| Skip("Skipping Nutanix E2E tests") | ||
| } | ||
| }) | ||
|  | ||
| It("should have a CAPI Cluster with NutanixCluster infrastructure reference", func() { | ||
| By("Fetching the CAPI Cluster object") | ||
| capiCluster = &clusterv1.Cluster{} | ||
| err := cl.Get(ctx, client.ObjectKey{ | ||
| Name: clusterName, | ||
| Namespace: framework.CAPINamespace, | ||
| }, capiCluster) | ||
| Expect(err).ToNot(HaveOccurred(), "should be able to get the CAPI Cluster") | ||
| Expect(capiCluster).ToNot(BeNil()) | ||
|  | ||
| By("Validating infrastructure reference") | ||
| Expect(capiCluster.Spec.InfrastructureRef).ToNot(BeNil()) | ||
| Expect(capiCluster.Spec.InfrastructureRef.Kind).To(Equal("NutanixCluster")) | ||
| Expect(capiCluster.Spec.InfrastructureRef.Name).To(Equal(clusterName)) | ||
| Expect(capiCluster.Spec.InfrastructureRef.Namespace).To(Equal(framework.CAPINamespace)) | ||
| }) | ||
|  | ||
| It("should have control plane endpoint initialized", func() { | ||
| By("Validating CAPI Cluster control plane endpoint") | ||
| Expect(capiCluster.Spec.ControlPlaneEndpoint.Host).ToNot(BeEmpty()) | ||
| Expect(capiCluster.Spec.ControlPlaneEndpoint.Port).To(BeNumerically(">", 0)) | ||
| }) | ||
| }) | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Add Nutanix deps: verify compatibility and build/vendor wiring
Looks good. Please:
Also applies to: 80-80
🏁 Script executed:
Length of output: 28397
Length of output: 383
💡 Result:
cluster-api-provider-nutanix v1.7.2 (CAPX v1.7.x) is validated to work with Cluster API (CAPI) v1.3.x through v1.9.x. [1][2]
Sources:
CAPN v1.7.2 is validated only for CAPI v1.3.x–v1.9.x, but the root go.mod specifies CAPI v1.10.4. Upgrade CAPN to a version supporting v1.10.4 or downgrade CAPI to v1.9.x or earlier.
Root go.mod already correctly declares CAPN v1.7.2 (line 14), and manifests include Nutanix provider assets. However, resolve the version incompatibility before merging.
🤖 Prompt for AI Agents