Skip to content

Azure MachinePool types directly reference cluster-api-provider-azure types, creating tight coupling #10181

@ash-thakur-rh

Description

@ash-thakur-rh

The Azure MachinePool types in the OpenShift installer directly import and use types from the external sigs.k8s.io/cluster-api-provider-azure (CAPZ) library, creating a tight coupling with an external dependency. This approach differs from how other cloud providers (e.g., AWS) are implemented and may lead to maintenance challenges.

This was not the case with earlier version of OpenShift installer.

Evidence

In /pkg/types/azure/machinepool.go, we directly reference CAPZ types:

import (                                                                                                                                                                                                                         
    capz "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1"                                                                                                                                                                    
)                                                                                                                                                                                                                                
                                                                                                                                                                                                                                 
type MachinePool struct {                                                                                                                                                                                                        
    // Line 85: Direct reference to CAPZ type                                                                                                                                                                                    
    DataDisks []capz.DataDisk `json:"dataDisks,omitempty"`                                                                                                                                                                       
                                                                                                                                                                                                                                 
    // Line 63:                                                                                                                                                                                                                  
    BootDiagnostics *BootDiagnostics `json:"bootDiagnostics,omitempty"`                                                                                                                                                          
}                                                                                                                                                                                                                                
                                                                                                                                                                                                                                 
type BootDiagnostics struct {                                                                                                                                                                                                    
    // Line 167: Direct reference to CAPZ type                                                                                                                                                                                   
    Type capz.BootDiagnosticsStorageAccountType `json:"type"`                                                                                                                                                                    
    // ...                                                                                                                                                                                                                       
}                                                                                                                                                                                                                                
                                                                                                                                                                                                                                 
type VMIdentity struct {                                                                                                                                                                                                         
    // Line 277: Direct reference to CAPZ type                                                                                                                                                                                   
    Type capz.VMIdentity `json:"type"`                                                                                                                                                                                           
    // ...                                                                                                                                                                                                                       
}     

Comparison with AWS

The AWS installer types (/pkg/types/aws/machinepool.go) do NOT import or reference cluster-api-provider-aws types. Instead, all AWS types are defined locally within the installer package, maintaining independence from external cluster-api providers.

// AWS defines its own types locally
type MachinePool struct {
Zones []string json:"zones,omitempty"
InstanceType string json:"type"
// ... all types defined locally
}

Impact

  1. Tight Coupling: The installer API schema depends on an external cluster-api provider, meaning any breaking changes in CAPZ directly affect the installer API
  2. Maintenance Burden: Upgrading CAPZ requires careful coordination and may force installer API changes
  3. Inconsistency: Different cloud providers are handled differently, making the codebase less consistent
  4. Schema Generation: External tools that generate schemas from installer types (e.g., for client libraries) must also pull in the entire CAPZ dependency to resolve type references
  5. API Stability: The installer's public API stability is now partially dependent on CAPZ's API stability

Observed in Downstream Projects

This coupling affects downstream projects. For example, the Fabric8 Kubernetes Client project generates Java models from OpenShift APIs and encounters this dependency:

  • Their go.mod must include sigs.k8s.io/cluster-api-provider-azure solely to resolve these type references during OpenAPI schema generation
  • This adds ~200+ Java classes just to support these Azure installer types

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions