Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions api/v1beta1/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions api/v1beta2/conditions_consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,23 @@ const (
IBMPowerVSClusterReadyUnknownV1Beta2Reason = clusterv1beta1.ReadyUnknownV1Beta2Reason
)

// IBMVPCCluster's Ready condition and corresponding reasons that will be used in v1Beta2 API version.
const (
// IBMVPCClusterReadyV1Beta2Condition is true if the IBMVPCCluster's deletionTimestamp is not set and IBMVPCCluster's
// conditions are true.
IBMVPCClusterReadyV1Beta2Condition = clusterv1beta1.ReadyV1Beta2Condition

// IBMVPCClusterReadyV1Beta2Reason surfaces when the IBMVPCCluster readiness criteria is met.
IBMVPCClusterReadyV1Beta2Reason = clusterv1beta1.ReadyV1Beta2Reason

// IBMVPCClusterNotReadyV1Beta2Reason surfaces when the IBMVPCCluster readiness criteria is not met.
IBMVPCClusterNotReadyV1Beta2Reason = clusterv1beta1.NotReadyV1Beta2Reason

// IBMVPCClusterReadyUnknownV1Beta2Reason surfaces when at least one of the IBMVPCCluster readiness criteria is unknown
// and none of the IBMVPCCluster readiness criteria is met.
IBMVPCClusterReadyUnknownV1Beta2Reason = clusterv1beta1.ReadyUnknownV1Beta2Reason
)

const (
// WorkspaceReadyV1Beta2Condition reports on the successful reconciliation of a PowerVS workspace.
WorkspaceReadyV1Beta2Condition = "WorkspaceReady"
Expand Down Expand Up @@ -283,6 +300,15 @@ const (
// VPCLoadBalancerDeletingV1Beta2Reason surfaces when the VPC LoadBalancer is being deleted.
VPCLoadBalancerDeletingV1Beta2Reason = clusterv1beta1.DeletingV1Beta2Reason

// VPCImageReadyV1Beta2Condition reports on the successful reconciliation of a VPC custom image.
VPCImageReadyV1Beta2Condition = "VPCImageReady"

// VPCImageReadyV1Beta2Reason surfaces when the VPC custom image is ready.
VPCImageReadyV1Beta2Reason = clusterv1beta1.ReadyV1Beta2Reason

// VPCImageNotReadyV1Beta2Reason surfaces when the VPC custom image is not ready.
VPCImageNotReadyV1Beta2Reason = clusterv1beta1.NotReadyV1Beta2Reason

// COSInstanceReadyV1Beta2Condition reports on the successful reconciliation of a COS instance.
COSInstanceReadyV1Beta2Condition = "COSInstanceReady"

Expand Down
31 changes: 31 additions & 0 deletions api/v1beta2/ibmvpccluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,21 @@ type IBMVPCClusterStatus struct {
// Conditions defines current service state of the load balancer.
// +optional
Conditions clusterv1beta1.Conditions `json:"conditions,omitempty"`

// V1beta2 groups all the fields that will be added or modified in IBMVPCCluster's status with the V1Beta2 version.
// +optional
V1Beta2 *IBMVPCClusterV1Beta2Status `json:"v1beta2,omitempty"`
}

// IBMVPCClusterV1Beta2Status groups all the fields that will be added or modified in IBMVPCClusterStatus with the V1Beta2 version.
// See https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more context.
type IBMVPCClusterV1Beta2Status struct {
// Conditions represents the observations of a IBMVPCCluster's current state.
// +optional
// +listType=map
// +listMapKey=type
// +kubebuilder:validation:MaxItems=32
Conditions []metav1.Condition `json:"conditions,omitempty"`
}

// VPCNetworkStatus provides details on the status of VPC network resources for extended VPC Infrastructure support.
Expand Down Expand Up @@ -400,6 +415,22 @@ func (r *IBMVPCCluster) SetConditions(conditions clusterv1beta1.Conditions) {
r.Status.Conditions = conditions
}

// GetV1Beta2Conditions returns the set of conditions for IBMVPCCluster object.
func (r *IBMVPCCluster) GetV1Beta2Conditions() []metav1.Condition {
if r.Status.V1Beta2 == nil {
return nil
}
return r.Status.V1Beta2.Conditions
}

// SetV1Beta2Conditions sets conditions for IBMVPCCluster object.
func (r *IBMVPCCluster) SetV1Beta2Conditions(conditions []metav1.Condition) {
if r.Status.V1Beta2 == nil {
r.Status.V1Beta2 = &IBMVPCClusterV1Beta2Status{}
}
r.Status.V1Beta2.Conditions = conditions
}

func init() {
objectTypes = append(objectTypes, &IBMVPCCluster{}, &IBMVPCClusterList{})
}
27 changes: 27 additions & 0 deletions api/v1beta2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions cloud/scope/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (

"k8s.io/klog/v2"

ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"

clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
Expand Down Expand Up @@ -334,7 +335,8 @@ func (s *ClusterScope) ensureSubnetUnique(subnetName string) (*vpcv1.Subnet, err
}

// DeleteSubnet deletes a subnet associated with subnet id.
func (s *ClusterScope) DeleteSubnet() error {
func (s *ClusterScope) DeleteSubnet(ctx context.Context) error {
log := ctrl.LoggerFrom(ctx)
if s.IBMVPCCluster.Status.Subnet.ID == nil {
return nil
}
Expand Down Expand Up @@ -377,7 +379,7 @@ func (s *ClusterScope) DeleteSubnet() error {
}

if !found {
s.Logger.V(3).Info("No subnets found with ID", "Subnet ID", subnetID)
log.V(3).Info("No subnets found with ID", "subnetID", subnetID)
return nil
}

Expand Down
12 changes: 6 additions & 6 deletions cloud/scope/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ func TestDeleteSubnet(t *testing.T) {
mockvpc.EXPECT().UnsetSubnetPublicGateway(gomock.AssignableToTypeOf(&vpcv1.UnsetSubnetPublicGatewayOptions{})).Return(&core.DetailedResponse{}, nil)
mockvpc.EXPECT().DeletePublicGateway(gomock.AssignableToTypeOf(&vpcv1.DeletePublicGatewayOptions{})).Return(&core.DetailedResponse{}, nil)
mockvpc.EXPECT().DeleteSubnet(gomock.AssignableToTypeOf(&vpcv1.DeleteSubnetOptions{})).Return(&core.DetailedResponse{}, nil)
err := scope.DeleteSubnet()
err := scope.DeleteSubnet(ctx)
g.Expect(err).To(BeNil())
})

Expand All @@ -482,7 +482,7 @@ func TestDeleteSubnet(t *testing.T) {
mockvpc.EXPECT().ListSubnets(gomock.AssignableToTypeOf(&vpcv1.ListSubnetsOptions{})).Return(subnet, &core.DetailedResponse{}, nil)
mockvpc.EXPECT().GetSubnetPublicGateway(gomock.AssignableToTypeOf(&vpcv1.GetSubnetPublicGatewayOptions{})).Return(publicGateway, &core.DetailedResponse{}, nil)
mockvpc.EXPECT().UnsetSubnetPublicGateway(gomock.AssignableToTypeOf(&vpcv1.UnsetSubnetPublicGatewayOptions{})).Return(&core.DetailedResponse{}, errors.New("Error when unsetting publicgateway for subnet"))
err := scope.DeleteSubnet()
err := scope.DeleteSubnet(ctx)
g.Expect(err).To(Not(BeNil()))
})

Expand All @@ -497,7 +497,7 @@ func TestDeleteSubnet(t *testing.T) {
mockvpc.EXPECT().GetSubnetPublicGateway(gomock.AssignableToTypeOf(&vpcv1.GetSubnetPublicGatewayOptions{})).Return(publicGateway, &core.DetailedResponse{}, nil)
mockvpc.EXPECT().UnsetSubnetPublicGateway(gomock.AssignableToTypeOf(&vpcv1.UnsetSubnetPublicGatewayOptions{})).Return(&core.DetailedResponse{}, nil)
mockvpc.EXPECT().DeletePublicGateway(gomock.AssignableToTypeOf(&vpcv1.DeletePublicGatewayOptions{})).Return(&core.DetailedResponse{}, errors.New("Error when deleting publicgateway for subnet"))
err := scope.DeleteSubnet()
err := scope.DeleteSubnet(ctx)
g.Expect(err).To(Not(BeNil()))
})

Expand All @@ -513,7 +513,7 @@ func TestDeleteSubnet(t *testing.T) {
mockvpc.EXPECT().UnsetSubnetPublicGateway(gomock.AssignableToTypeOf(&vpcv1.UnsetSubnetPublicGatewayOptions{})).Return(&core.DetailedResponse{}, nil)
mockvpc.EXPECT().DeletePublicGateway(gomock.AssignableToTypeOf(&vpcv1.DeletePublicGatewayOptions{})).Return(&core.DetailedResponse{}, nil)
mockvpc.EXPECT().DeleteSubnet(gomock.AssignableToTypeOf(&vpcv1.DeleteSubnetOptions{})).Return(&core.DetailedResponse{}, errors.New("Error when deleting subnet"))
err := scope.DeleteSubnet()
err := scope.DeleteSubnet(ctx)
g.Expect(err).To(Not(BeNil()))
})

Expand All @@ -525,7 +525,7 @@ func TestDeleteSubnet(t *testing.T) {
scope.IBMVPCCluster.Spec = vpcCluster.Spec
scope.IBMVPCCluster.Status = vpcCluster.Status
mockvpc.EXPECT().ListSubnets(gomock.AssignableToTypeOf(&vpcv1.ListSubnetsOptions{})).Return(nil, &core.DetailedResponse{}, errors.New("Error listing subnets"))
err := scope.DeleteSubnet()
err := scope.DeleteSubnet(ctx)
g.Expect(err).To(Not(BeNil()))
})
t.Run("Subnet doesn't exist", func(t *testing.T) {
Expand All @@ -536,7 +536,7 @@ func TestDeleteSubnet(t *testing.T) {
scope.IBMVPCCluster.Spec = vpcCluster.Spec
scope.IBMVPCCluster.Status = vpcCluster.Status
mockvpc.EXPECT().ListSubnets(gomock.AssignableToTypeOf(&vpcv1.ListSubnetsOptions{})).Return(&vpcv1.SubnetCollection{Subnets: []vpcv1.Subnet{}}, &core.DetailedResponse{}, nil)
err := scope.DeleteSubnet()
err := scope.DeleteSubnet(ctx)
g.Expect(err).To(BeNil())
})
})
Expand Down
Loading