Skip to content
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

Feat/net/controlplane Manage FailureDomain on multipld az #298

Closed
wants to merge 2 commits into from
Closed
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
9 changes: 5 additions & 4 deletions api/v1beta1/osccluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ type OscClusterSpec struct {

// OscClusterStatus defines the observed state of OscCluster
type OscClusterStatus struct {
Ready bool `json:"ready,omitempty"`
Network OscNetworkResource `json:"network,omitempty"`
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
VmState *VmState `json:"vmState,omitempty"`
Ready bool `json:"ready,omitempty"`
Network OscNetworkResource `json:"network,omitempty"`
FailureDomains clusterv1.FailureDomains `json:"failureDomains,omitempty"`
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
VmState *VmState `json:"vmState,omitempty"`
}

//+kubebuilder:object:root=true
Expand Down
12 changes: 11 additions & 1 deletion api/v1beta1/oscmachine_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,22 @@ func (m *OscMachine) ValidateUpdate(oldRaw runtime.Object) error {
oscMachineLog.Info("validate update old subregionName", "old subregionName", old.Spec.Node.Vm.SubregionName)
oscMachineLog.Info("validate update subregionName", "subregionName", m.Spec.Node.Vm.SubregionName)

if !reflect.DeepEqual(m.Spec.Node.Vm.SubregionName, old.Spec.Node.Vm.SubregionName) {
if old.Spec.Node.Vm.SubregionName != "" && !reflect.DeepEqual(m.Spec.Node.Vm.SubregionName, old.Spec.Node.Vm.SubregionName) {
allErrs = append(allErrs,
field.Invalid(field.NewPath("spec", "subregionName"),
m.Spec.Node.Vm.SubregionName, "field is immutable"),
)
}

oscMachineLog.Info("validate update old subnetName", "old subnetName", old.Spec.Node.Vm.SubnetName)
oscMachineLog.Info("validate update subnetName", "subnetName", m.Spec.Node.Vm.SubnetName)

if (old.Spec.Node.Vm.SubnetName != "") && !reflect.DeepEqual(m.Spec.Node.Vm.SubnetName, old.Spec.Node.Vm.SubnetName) {
allErrs = append(allErrs,
field.Invalid(field.NewPath("spec", "subnetName"),
m.Spec.Node.Vm.SubnetName, "field is immutable"),
)
}
oscMachineLog.Info("validate update old rootDiskSize", "old rootDiskSize", old.Spec.Node.Vm.RootDisk.RootDiskSize)
oscMachineLog.Info("validate update rootDiskSize", "rootDiskSize", m.Spec.Node.Vm.RootDisk.RootDiskSize)

Expand Down
2 changes: 2 additions & 0 deletions api/v1beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ type OscNetwork struct {
// The Net configuration
// +optional
Net OscNet `json:"net,omitempty"`
// List of subnet to spread controlPlane nodes
ControlPlaneSubnets []string `json:"controlPlaneSubnets,omitempty"`
// The Subnet configuration
// +optional
Subnets []*OscSubnet `json:"subnets,omitempty"`
Expand Down
8 changes: 8 additions & 0 deletions cloud/scope/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,14 @@ func (s ClusterScope) GetLinkRouteTablesRef() map[string][]string {
return s.OscCluster.Status.Network.LinkRouteTableRef
}

// SetFailureDomain sets the infrastructure provider failure domain key to the spec given as input.
func (s *ClusterScope) SetFailureDomain(id string, spec clusterv1.FailureDomainSpec) {
if s.OscCluster.Status.FailureDomains == nil {
s.OscCluster.Status.FailureDomains = make(clusterv1.FailureDomains)
}
s.OscCluster.Status.FailureDomains[id] = spec
}

// SetLinkRouteTableRef set the status of route associate with a routeTables (a Map with tag name with cluster uid associate with resource response id)
func (s ClusterScope) SetLinkRouteTablesRef(linkRouteTableRef map[string][]string) {
s.OscCluster.Status.Network.LinkRouteTableRef = linkRouteTableRef
Expand Down
17 changes: 9 additions & 8 deletions cloud/services/service/load_balancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,14 +222,15 @@ func (s *Service) GetLoadBalancer(spec *infrastructurev1beta1.OscLoadBalancer) (
readLoadBalancersResponse, httpRes, err = oscApiClient.LoadBalancerApi.ReadLoadBalancers(oscAuthClient).ReadLoadBalancersRequest(readLoadBalancerRequest).Execute()
if err != nil {
if httpRes != nil {
return false, fmt.Errorf("error %w httpRes %s", err, httpRes.Status)
}
requestStr := fmt.Sprintf("%v", readLoadBalancerRequest)
if reconciler.KeepRetryWithError(
requestStr,
httpRes.StatusCode,
reconciler.ThrottlingErrors) {
return false, nil
requestStr := fmt.Sprintf("%v", readLoadBalancerRequest)
if reconciler.KeepRetryWithError(
requestStr,
httpRes.StatusCode,
reconciler.ThrottlingErrors) {
return false, nil
} else {
return false, fmt.Errorf("error %w httpRes %s", err, httpRes.Status)
}
}
return false, err
}
Expand Down
9 changes: 6 additions & 3 deletions cloud/tag/tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ import (
"context"
"errors"
"fmt"
"net/http"
"regexp"

"github.com/outscale-dev/cluster-api-provider-outscale.git/util/reconciler"
osc "github.com/outscale/osc-sdk-go/v2"
"k8s.io/apimachinery/pkg/util/wait"
"net/http"
"regexp"
)

//go:generate ../../bin/mockgen -destination mock_tag/tag_mock.go -package mock_tag -source ./tag.go
Expand Down Expand Up @@ -72,7 +73,9 @@ func (s *Service) ReadTag(tagKey string, tagValue string) (*osc.Tag, error) {
oscAuthClient := s.scope.GetAuth()
readTagsResponse, httpRes, err := oscApiClient.TagApi.ReadTags(oscAuthClient).ReadTagsRequest(readTagsRequest).Execute()
if err != nil {
fmt.Printf("Error with http result %s", httpRes.Status)
if httpRes != nil {
fmt.Printf("Error with http result %s", httpRes.Status)
}
return nil, err
}
tags, ok := readTagsResponse.GetTagsOk()
Expand Down
Loading
Loading