Skip to content

Commit

Permalink
Status Propagation (Part 1)
Browse files Browse the repository at this point in the history
We need to propagate the status of machines and workload pools up to the
API so clients can actually see them, and most pertinently get the
hostnames and IP addresses.
  • Loading branch information
spjmurray committed Dec 4, 2024
1 parent 189d1d9 commit 55a2661
Show file tree
Hide file tree
Showing 13 changed files with 414 additions and 136 deletions.
78 changes: 78 additions & 0 deletions charts/compute/crds/compute.unikorn-cloud.org_computeclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,84 @@ spec:
namespace:
description: Namespace defines the namespace a cluster resides in.
type: string
workloadpools:
description: WorkloadPools is the status of all pools.
items:
properties:
machines:
description: Machines in the pool.
items:
properties:
conditions:
description: Conditions is a set of status conditions
for the machine.
items:
description: |-
Condition is a generic condition type for use across all resource types.
It's generic so that the underlying controller-manager functionality can
be shared across all resources.
properties:
lastTransitionTime:
description: Last time the condition transitioned
from one status to another.
format: date-time
type: string
message:
description: Human-readable message indicating details
about last transition.
type: string
reason:
description: Unique, one-word, CamelCase reason
for the condition's last transition.
enum:
- Provisioning
- Provisioned
- Cancelled
- Errored
- Deprovisioning
- Deprovisioned
type: string
status:
description: |-
Status is the status of the condition.
Can be True, False, Unknown.
type: string
type:
description: Type is the type of the condition.
enum:
- Available
type: string
required:
- lastTransitionTime
- message
- reason
- status
- type
type: object
type: array
hostname:
description: Hostname of the machine.
type: string
privateIP:
description: PrivateIP is the private IP address.
type: string
publicIP:
description: PublicIP is the public IP address if requested.
type: string
required:
- hostname
type: object
type: array
name:
description: Name of the workload pool.
type: string
replicas:
description: Replicas that actually exist.
type: integer
required:
- name
type: object
type: array
type: object
required:
- spec
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ require (
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.60.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/spjmurray/go-util v0.1.3 // indirect
github.com/x448/float16 v0.8.4 // indirect
go.opentelemetry.io/otel v1.31.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.31.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/spjmurray/go-util v0.1.3 h1:EJxYEH6FnKJwgRWw8sSEyOreqU07lI2V8+KZnCSsLoE=
github.com/spjmurray/go-util v0.1.3/go.mod h1:fARcBeaHio/6h9H7Ht+egZPBZMNxEwxmHC1vyjBtPbs=
github.com/spkg/bom v0.0.0-20160624110644-59b7046e48ad/go.mod h1:qLr4V1qq6nMqFKkMo8ZTx3f+BZEkzsRUY10Xsm2mwU0=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
Expand Down
16 changes: 16 additions & 0 deletions pkg/apis/unikorn/v1alpha1/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,22 @@ func (c *ComputeCluster) ResourceLabels() (labels.Set, error) {
return labels, nil
}

func (c *ComputeCluster) GetWorkloadPoolStatus(name string) *WorkloadPoolStatus {
for i, status := range c.Status.WorkloadPools {
if name == status.Name {
return &c.Status.WorkloadPools[i]
}
}

status := WorkloadPoolStatus{
Name: name,
}

c.Status.WorkloadPools = append(c.Status.WorkloadPools, status)

return &c.Status.WorkloadPools[len(c.Status.WorkloadPools)-1]
}

func (p *FirewallRulePort) String() string {
if p.Number != nil {
return fmt.Sprintf("%d", *p.Number)
Expand Down
24 changes: 24 additions & 0 deletions pkg/apis/unikorn/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,30 @@ type ComputeClusterWorkloadPoolsSpec struct {
type ComputeClusterStatus struct {
// Namespace defines the namespace a cluster resides in.
Namespace string `json:"namespace,omitempty"`
// WorkloadPools is the status of all pools.
WorkloadPools []WorkloadPoolStatus `json:"workloadpools,omitempty"`
// Current service state of a Compute cluster.
Conditions []unikornv1core.Condition `json:"conditions,omitempty"`
}

type WorkloadPoolStatus struct {
// Name of the workload pool.
Name string `json:"name"`
// Replicas that actually exist.
Replicas int `json:"replicas,omitempty"`
// Machines in the pool.
Machines []MachineStatus `json:"machines,omitempty"`
}

type MachineStatus struct {
// Hostname of the machine.
Hostname string `json:"hostname"`
// PrivateIP is the private IP address.
// TODO: should be IPv4Address.
PrivateIP *string `json:"privateIp,omitempty"`
// PublicIP is the public IP address if requested.
// TODO: should be IPv4Address.
PublicIP *string `json:"publicIp,omitempty"`
// Conditions is a set of status conditions for the machine.
Conditions []unikornv1core.Condition `json:"conditions,omitempty"`
}
63 changes: 63 additions & 0 deletions pkg/apis/unikorn/v1alpha1/zz_generated.deepcopy.go

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

112 changes: 56 additions & 56 deletions pkg/openapi/schema.go

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

Loading

0 comments on commit 55a2661

Please sign in to comment.