Skip to content

Commit

Permalink
Merge branch 'main' into enh/ori-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
afritzler authored Aug 15, 2023
2 parents c783cf1 + 5c892ce commit 901c7a9
Show file tree
Hide file tree
Showing 155 changed files with 6,534 additions and 6,418 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/clean-cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: cleanup caches by a branch
on:
pull_request:
types:
- closed

jobs:
cleanup:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3

- name: Cleanup
run: |
gh extension install actions/gh-actions-cache
REPO=${{ github.repository }}
BRANCH="refs/pull/${{ github.event.pull_request.number }}/merge"
echo "Fetching list of cache key"
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH | cut -f 1 )
## Setting this to not fail the workflow while deleting cache keys.
set +e
echo "Deleting caches..."
for cacheKey in $cacheKeysForPR
do
gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm
done
echo "Done"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.51.1
version: v1.54.1
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM --platform=$BUILDPLATFORM golang:1.20.6 as builder
FROM --platform=$BUILDPLATFORM golang:1.21.0 as builder

WORKDIR /workspace
# Copy the Go Modules manifests
Expand Down
20 changes: 20 additions & 0 deletions api/common/v1alpha1/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,18 @@ func ParseIP(s string) (IP, error) {
return IP{addr}, nil
}

func ParseIPs(s ...string) ([]IP, error) {
res := make([]IP, len(s))
for i, s := range s {
ip, err := ParseIP(s)
if err != nil {
return nil, err
}
res[i] = ip
}
return res, nil
}

func ParseNewIP(s string) (*IP, error) {
ip, err := ParseIP(s)
if err != nil {
Expand All @@ -190,6 +202,14 @@ func MustParseIP(s string) IP {
return IP{netip.MustParseAddr(s)}
}

func MustParseIPs(s ...string) []IP {
ips, err := ParseIPs(s...)
if err != nil {
panic(err)
}
return ips
}

func MustParseNewIP(s string) *IP {
ip, err := ParseNewIP(s)
utilruntime.Must(err)
Expand Down
28 changes: 0 additions & 28 deletions api/compute/v1alpha1/machine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,6 @@ type NetworkInterfaceStatus struct {
State NetworkInterfaceState `json:"state,omitempty"`
// LastStateTransitionTime is the last time the State transitioned.
LastStateTransitionTime *metav1.Time `json:"lastStateTransitionTime,omitempty"`
// Phase is the NetworkInterface binding phase of the NetworkInterface.
Phase NetworkInterfacePhase `json:"phase,omitempty"`
// LastPhaseTransitionTime is the last time the Phase transitioned.
LastPhaseTransitionTime *metav1.Time `json:"lastPhaseTransitionTime,omitempty"`
}

// NetworkInterfaceState is the infrastructure attachment state a NetworkInterface can be in.
Expand All @@ -165,16 +161,6 @@ const (
NetworkInterfaceStateAttached NetworkInterfaceState = "Attached"
)

// NetworkInterfacePhase represents the binding phase a NetworkInterface can be in.
type NetworkInterfacePhase string

const (
// NetworkInterfacePhasePending is used for a NetworkInterface that is not yet bound.
NetworkInterfacePhasePending NetworkInterfacePhase = "Pending"
// NetworkInterfacePhaseBound is used for a NetworkInterface that is bound.
NetworkInterfacePhaseBound NetworkInterfacePhase = "Bound"
)

// VolumeStatus is the status of a Volume.
type VolumeStatus struct {
// Name is the name of a volume attachment.
Expand All @@ -185,10 +171,6 @@ type VolumeStatus struct {
State VolumeState `json:"state,omitempty"`
// LastStateTransitionTime is the last time the State transitioned.
LastStateTransitionTime *metav1.Time `json:"lastStateTransitionTime,omitempty"`
// Phase represents the binding phase of a Volume.
Phase VolumePhase `json:"phase,omitempty"`
// LastPhaseTransitionTime is the last time the Phase transitioned.
LastPhaseTransitionTime *metav1.Time `json:"lastPhaseTransitionTime,omitempty"`
}

// VolumeState is the infrastructure attachment state a Volume can be in.
Expand All @@ -201,16 +183,6 @@ const (
VolumeStateAttached VolumeState = "Attached"
)

// VolumePhase represents the binding phase a Volume can be in.
type VolumePhase string

const (
// VolumePhasePending is used for a Volume that is not yet bound.
VolumePhasePending VolumePhase = "Pending"
// VolumePhaseBound is used for a Volume that is bound.
VolumePhaseBound VolumePhase = "Bound"
)

// MachineStatus defines the observed state of Machine
type MachineStatus struct {
// MachineID is the provider specific machine ID in the format '<type>://<machine_id>'.
Expand Down
8 changes: 0 additions & 8 deletions api/compute/v1alpha1/zz_generated.deepcopy.go

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

1 change: 1 addition & 0 deletions api/core/v1alpha1/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ type ClassType string

const (
ClassTypeMachineClass ClassType = "machine"
ClassTypeVolumeClass ClassType = "volume"
)

func ClassCountFor(classType ClassType, className string) ResourceName {
Expand Down
46 changes: 28 additions & 18 deletions api/networking/v1alpha1/network_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
package v1alpha1

import (
commonv1alpha1 "github.com/onmetal/onmetal-api/api/common/v1alpha1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
)

// NetworkSpec defines the desired state of Network
Expand All @@ -30,16 +30,40 @@ type NetworkSpec struct {
// +patchMergeKey=name
// +patchStrategy=merge,retainKeys
Peerings []NetworkPeering `json:"peerings,omitempty" patchStrategy:"merge,retainKeys" patchMergeKey:"name"`

// PeeringClaimRefs are the peering claim references of other networks.
// +optional
// +patchMergeKey=name
// +patchStrategy=merge,retainKeys
PeeringClaimRefs []NetworkPeeringClaimRef `json:"incomingPeerings,omitempty" patchStrategy:"merge,retainKeys" patchMergeKey:"name"`
}

type NetworkPeeringClaimRef struct {
// Namespace is the namespace of the referenced entity. If empty,
// the same namespace as the referring resource is implied.
Namespace string `json:"namespace,omitempty"`
// Name is the name of the referenced entity.
Name string `json:"name"`
// UID is the UID of the referenced entity.
UID types.UID `json:"uid,omitempty"`
}

// NetworkPeeringNetworkRef is a reference to a network to peer with.
type NetworkPeeringNetworkRef struct {
// Namespace is the namespace of the referenced entity. If empty,
// the same namespace as the referring resource is implied.
Namespace string `json:"namespace,omitempty"`
// Name is the name of the referenced entity.
Name string `json:"name"`
}

// NetworkPeering defines a network peering with another network.
type NetworkPeering struct {
// Name is the semantical name of the network peering.
Name string `json:"name"`
// NetworkRef is the reference to the network to peer with.
// If the UID is empty, it will be populated once when the peering is successfully bound.
// If namespace is empty it is implied that the target network resides in the same network.
NetworkRef commonv1alpha1.UIDReference `json:"networkRef"`
// An empty namespace indicates that the target network resides in the same namespace as the source network.
NetworkRef NetworkPeeringNetworkRef `json:"networkRef"`
}

// NetworkStatus defines the observed state of Network
Expand All @@ -57,24 +81,10 @@ type NetworkStatus struct {
// +enum
type NetworkState string

// NetworkPeeringPhase is the phase a NetworkPeering can be in.
type NetworkPeeringPhase string

const (
// NetworkPeeringPhasePending signals that the network peering is not bound.
NetworkPeeringPhasePending NetworkPeeringPhase = "Pending"
// NetworkPeeringPhaseBound signals that the network peering is bound.
NetworkPeeringPhaseBound NetworkPeeringPhase = "Bound"
)

// NetworkPeeringStatus is the status of a network peering.
type NetworkPeeringStatus struct {
// Name is the name of the network peering.
Name string `json:"name"`
// Phase represents the binding phase of a network peering.
Phase NetworkPeeringPhase `json:"phase,omitempty"`
// LastPhaseTransitionTime is the last time the Phase transitioned.
LastPhaseTransitionTime *metav1.Time `json:"lastPhaseTransitionTime,omitempty"`
}

const (
Expand Down
23 changes: 4 additions & 19 deletions api/networking/v1alpha1/networkinterface_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import (

// NetworkInterfaceSpec defines the desired state of NetworkInterface
type NetworkInterfaceSpec struct {
// ProviderID is the provider-internal ID of the network interface.
ProviderID string `json:"providerID,omitempty"`
// NetworkRef is the Network this NetworkInterface is connected to
NetworkRef corev1.LocalObjectReference `json:"networkRef"`
// MachineRef is the Machine this NetworkInterface is used by
Expand All @@ -38,6 +40,8 @@ type NetworkInterfaceSpec struct {
Prefixes []PrefixSource `json:"prefixes,omitempty"`
// VirtualIP specifies the virtual ip that should be assigned to this NetworkInterface.
VirtualIP *VirtualIPSource `json:"virtualIP,omitempty"`
// Attributes are provider-specific attributes for the network interface.
Attributes map[string]string `json:"attributes,omitempty"`
}

// IPSource is the definition of how to obtain an IP.
Expand Down Expand Up @@ -71,19 +75,12 @@ type NetworkInterfaceStatus struct {
// LastStateTransitionTime is the last time the State transitioned from one value to another.
LastStateTransitionTime *metav1.Time `json:"lastStateTransitionTime,omitempty"`

// ProviderID is the provider-internal ID of the network interface.
ProviderID string `json:"providerID,omitempty"`
// IPs represent the effective IP addresses of the NetworkInterface.
IPs []commonv1alpha1.IP `json:"ips,omitempty"`
// Prefixes represent the prefixes routed to the NetworkInterface.
Prefixes []commonv1alpha1.IPPrefix `json:"prefixes,omitempty"`
// VirtualIP is any virtual ip assigned to the NetworkInterface.
VirtualIP *commonv1alpha1.IP `json:"virtualIP,omitempty"`

// Phase is the NetworkInterfacePhase of the NetworkInterface.
Phase NetworkInterfacePhase `json:"phase,omitempty"`
// LastPhaseTransitionTime is the last time the Phase transitioned from one value to another.
LastPhaseTransitionTime *metav1.Time `json:"lastPhaseTransitionTime,omitempty"`
}

// NetworkInterfaceState is the onmetal-api state of a NetworkInterface.
Expand All @@ -98,18 +95,6 @@ const (
NetworkInterfaceStateError NetworkInterfaceState = "Error"
)

// NetworkInterfacePhase is the binding phase of a NetworkInterface.
type NetworkInterfacePhase string

const (
// NetworkInterfacePhaseUnbound is used for any NetworkInterface that is not bound.
NetworkInterfacePhaseUnbound NetworkInterfacePhase = "Unbound"
// NetworkInterfacePhasePending is used for any NetworkInterface that is currently awaiting binding.
NetworkInterfacePhasePending NetworkInterfacePhase = "Pending"
// NetworkInterfacePhaseBound is used for any NetworkInterface that is properly bound.
NetworkInterfacePhaseBound NetworkInterfacePhase = "Bound"
)

// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

Expand Down
40 changes: 39 additions & 1 deletion api/networking/v1alpha1/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,45 @@ func NetworkInterfacePrefixIPAMPrefixName(nicName string, idx int) string {
return fmt.Sprintf("%s-pf-%d", nicName, idx)
}

// NetworkInterfaceIPIPAMPrefixName returns the name of a Prefix for a network interface ephemeral prefix.
// LoadBalancerIPIPAMPrefixName returns the name of a Prefix for a network interface ephemeral prefix.
func LoadBalancerIPIPAMPrefixName(loadBalancerName string, idx int) string {
return fmt.Sprintf("%s-%d", loadBalancerName, idx)
}

// NetworkInterfacePrefixNames returns the name of all ipam prefixes the network interface references.
func NetworkInterfacePrefixNames(nic *NetworkInterface) []string {
var names []string

for i, nicIP := range nic.Spec.IPs {
if nicIP.Ephemeral == nil {
continue
}

names = append(names, NetworkInterfaceIPIPAMPrefixName(nic.Name, i))
}

for i, nicPrefix := range nic.Spec.Prefixes {
if nicPrefix.Ephemeral == nil {
continue
}

names = append(names, NetworkInterfacePrefixIPAMPrefixName(nic.Name, i))
}

return names
}

// LoadBalancerPrefixNames returns the name of all ipam prefixes the load balancer references.
func LoadBalancerPrefixNames(loadBalancer *LoadBalancer) []string {
var names []string

for i, loadBalancerIP := range loadBalancer.Spec.IPs {
if loadBalancerIP.Ephemeral == nil {
continue
}

names = append(names, LoadBalancerIPIPAMPrefixName(loadBalancer.Name, i))
}

return names
}
17 changes: 0 additions & 17 deletions api/networking/v1alpha1/virtualip_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,25 +45,8 @@ const (
type VirtualIPStatus struct {
// IP is the allocated IP, if any.
IP *commonv1alpha1.IP `json:"ip,omitempty"`

// Phase is the VirtualIPPhase of the VirtualIP.
Phase VirtualIPPhase `json:"phase,omitempty"`
// LastPhaseTransitionTime is the last time the Phase transitioned from one value to another.
LastPhaseTransitionTime *metav1.Time `json:"phaseLastTransitionTime,omitempty"`
}

// VirtualIPPhase is the binding phase of a VirtualIP.
type VirtualIPPhase string

const (
// VirtualIPPhaseUnbound is used for any VirtualIP that is not bound.
VirtualIPPhaseUnbound VirtualIPPhase = "Unbound"
// VirtualIPPhasePending is used for any VirtualIP that is currently awaiting binding.
VirtualIPPhasePending VirtualIPPhase = "Pending"
// VirtualIPPhaseBound is used for any VirtualIP that is properly bound.
VirtualIPPhaseBound VirtualIPPhase = "Bound"
)

// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

Expand Down
Loading

0 comments on commit 901c7a9

Please sign in to comment.