Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ COPY . .
RUN --mount=type=cache,target="/root/.cache/go-build" .ci/build

############# base #############
FROM gcr.io/distroless/static-debian12:nonroot as base
FROM gcr.io/distroless/static-debian12:nonroot AS base
WORKDIR /

############# machine-controller-manager #############
Expand Down
28 changes: 23 additions & 5 deletions docs/documents/apis.md
Original file line number Diff line number Diff line change
Expand Up @@ -1080,7 +1080,8 @@ Kubernetes meta/v1.Duration
</td>
<td>
<em>(Optional)</em>
<p>DisableHealthTimeout if set to true, health timeout will be ignored. Leading to machine never being declared failed.</p>
<p>DisableHealthTimeout if set to true, health timeout will be ignored. Leading to machine never being declared failed.
This is intended to be used only for in-place updates.</p>
</td>
</tr>
<tr>
Expand Down Expand Up @@ -1542,8 +1543,8 @@ newest MachineSet.</p>
</td>
<td>
<em>
<a href="#machine.sapcloud.io/v1alpha1.*github.com/gardener/machine-controller-manager/pkg/apis/machine/v1alpha1.MachineSummary">
[]*github.com/gardener/machine-controller-manager/pkg/apis/machine/v1alpha1.MachineSummary
<a href="#machine.sapcloud.io/v1alpha1.*../../pkg/apis/machine/v1alpha1.MachineSummary">
[]*../../pkg/apis/machine/v1alpha1.MachineSummary
</a>
</em>
</td>
Expand Down Expand Up @@ -1987,8 +1988,8 @@ LastOperation
</td>
<td>
<em>
<a href="#machine.sapcloud.io/v1alpha1.[]github.com/gardener/machine-controller-manager/pkg/apis/machine/v1alpha1.MachineSummary">
[]github.com/gardener/machine-controller-manager/pkg/apis/machine/v1alpha1.MachineSummary
<a href="#machine.sapcloud.io/v1alpha1.[]../../pkg/apis/machine/v1alpha1.MachineSummary">
[]../../pkg/apis/machine/v1alpha1.MachineSummary
</a>
</em>
</td>
Expand Down Expand Up @@ -2120,6 +2121,23 @@ MachineConfiguration
<tbody>
<tr>
<td>
<code>addresses</code>
</td>
<td>
<em>
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.29/#nodeaddress-v1-core">
[]Kubernetes core/v1.NodeAddress
</a>
</em>
</td>
<td>
<em>(Optional)</em>
<p>Addresses of this machines. This field is only present if the MCM provider runs without a target cluster and may
be used by clients to determine how to connect to the machine, instead of the <code>Node.status.addresses</code> field.</p>
</td>
</tr>
<tr>
<td>
<code>conditions</code>
</td>
<td>
Expand Down
6 changes: 3 additions & 3 deletions kubernetes/crds/machine.sapcloud.io_machinedeployments.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,9 @@ spec:
machinie creation is declared failed.
type: string
disableHealthTimeout:
description: DisableHealthTimeout if set to true, health timeout
will be ignored. Leading to machine never being declared
failed.
description: |-
DisableHealthTimeout if set to true, health timeout will be ignored. Leading to machine never being declared failed.
This is intended to be used only for in-place updates.
type: boolean
drainTimeout:
description: MachineDraintimeout is the timeout after which
Expand Down
24 changes: 22 additions & 2 deletions kubernetes/crds/machine.sapcloud.io_machines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ spec:
creation is declared failed.
type: string
disableHealthTimeout:
description: DisableHealthTimeout if set to true, health timeout will
be ignored. Leading to machine never being declared failed.
description: |-
DisableHealthTimeout if set to true, health timeout will be ignored. Leading to machine never being declared failed.
This is intended to be used only for in-place updates.
type: boolean
drainTimeout:
description: MachineDraintimeout is the timeout after which machine
Expand Down Expand Up @@ -223,6 +224,25 @@ spec:
status:
description: Status contains fields depicting the status
properties:
addresses:
description: |-
Addresses of this machines. This field is only present if the MCM provider runs without a target cluster and may
be used by clients to determine how to connect to the machine, instead of the `Node.status.addresses` field.
items:
description: NodeAddress contains information for the node's address.
properties:
address:
description: The node address.
type: string
type:
description: Node address type, one of Hostname, ExternalIP
or InternalIP.
type: string
required:
- address
- type
type: object
type: array
conditions:
description: Conditions of this machine, same as node
items:
Expand Down
6 changes: 3 additions & 3 deletions kubernetes/crds/machine.sapcloud.io_machinesets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ spec:
machinie creation is declared failed.
type: string
disableHealthTimeout:
description: DisableHealthTimeout if set to true, health timeout
will be ignored. Leading to machine never being declared
failed.
description: |-
DisableHealthTimeout if set to true, health timeout will be ignored. Leading to machine never being declared failed.
This is intended to be used only for in-place updates.
type: boolean
drainTimeout:
description: MachineDraintimeout is the timeout after which
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/machine/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ type CurrentStatus struct {

// MachineStatus holds the most recently observed status of Machine.
type MachineStatus struct {
// Addresses of this machines. This field is only present if the MCM provider runs without a target cluster and may
// be used by clients to determine how to connect to the machine, instead of the `Node.status.addresses` field.
// +optional
Addresses []corev1.NodeAddress `json:"addresses,omitempty"`

// Conditions of this machine, same as node
Conditions []corev1.NodeCondition

Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/machine/v1alpha1/machine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ type NodeTemplateSpec struct {

// MachineStatus holds the most recently observed status of Machine.
type MachineStatus struct {
// Addresses of this machines. This field is only present if the MCM provider runs without a target cluster and may
// be used by clients to determine how to connect to the machine, instead of the `Node.status.addresses` field.
// +optional
Addresses []corev1.NodeAddress `json:"addresses,omitempty"`

// Conditions of this machine, same as node
Conditions []corev1.NodeCondition `json:"conditions,omitempty"`

Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/machine/v1alpha1/zz_generated.conversion.go

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

5 changes: 5 additions & 0 deletions pkg/apis/machine/v1alpha1/zz_generated.deepcopy.go

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

5 changes: 5 additions & 0 deletions pkg/apis/machine/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 pkg/openapi/api_violations.report
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
API rule violation: list_type_missing,github.com/gardener/machine-controller-manager/pkg/apis/machine/v1alpha1,MachineDeploymentStatus,Conditions
API rule violation: list_type_missing,github.com/gardener/machine-controller-manager/pkg/apis/machine/v1alpha1,MachineDeploymentStatus,FailedMachines
API rule violation: list_type_missing,github.com/gardener/machine-controller-manager/pkg/apis/machine/v1alpha1,MachineSetStatus,Conditions
API rule violation: list_type_missing,github.com/gardener/machine-controller-manager/pkg/apis/machine/v1alpha1,MachineStatus,Addresses
API rule violation: list_type_missing,github.com/gardener/machine-controller-manager/pkg/apis/machine/v1alpha1,MachineStatus,Conditions
API rule violation: names_match,github.com/gardener/machine-controller-manager/pkg/apis/machine/v1alpha1,MachineConfiguration,MachineCreationTimeout
API rule violation: names_match,github.com/gardener/machine-controller-manager/pkg/apis/machine/v1alpha1,MachineConfiguration,MachineDrainTimeout
Expand Down
20 changes: 17 additions & 3 deletions pkg/openapi/openapi_generated.go

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

12 changes: 12 additions & 0 deletions pkg/util/provider/driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ type CreateMachineResponse struct {

// LastKnownState represents the last state of the VM during an creation/deletion error
LastKnownState string

// Addresses to reach the VM. Returning this field is optional, and only used if the MCM provider runs without a
// target cluster.
Addresses []corev1.NodeAddress
}

// InitializeMachineRequest encapsulates params for the VM Initialization operation (Driver.InitializeMachine).
Expand All @@ -82,6 +86,10 @@ type InitializeMachineResponse struct {

// NodeName is the name of the node-object registered to kubernetes.
NodeName string

// Addresses to reach the VM. Returning this field is optional, and only used if the MCM provider runs without a
// target cluster.
Addresses []corev1.NodeAddress
}

// DeleteMachineRequest is the delete request for VM deletion
Expand Down Expand Up @@ -123,6 +131,10 @@ type GetMachineStatusResponse struct {

// NodeName is the name of the node-object registered to kubernetes.
NodeName string

// Addresses to reach the VM. Returning this field is optional, and only used if the MCM provider runs without a
// target cluster.
Addresses []corev1.NodeAddress
}

// ListMachinesRequest is the request object to get a list of VMs belonging to a machineClass
Expand Down
9 changes: 8 additions & 1 deletion pkg/util/provider/driver/fake.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ package driver

import (
"context"

"github.com/gardener/machine-controller-manager/pkg/util/provider/machinecodes/codes"
"github.com/gardener/machine-controller-manager/pkg/util/provider/machinecodes/status"
corev1 "k8s.io/api/core/v1"
)

// VMs is the map to hold the VM data
Expand All @@ -20,17 +22,19 @@ type FakeDriver struct {
ProviderID string
NodeName string
LastKnownState string
Addresses []corev1.NodeAddress
Err error
fakeVMs VMs
}

// NewFakeDriver returns a new fakedriver object
func NewFakeDriver(vmExists bool, providerID, nodeName, lastKnownState string, err error, fakeVMs VMs) Driver {
func NewFakeDriver(vmExists bool, providerID, nodeName, lastKnownState string, addresses []corev1.NodeAddress, err error, fakeVMs VMs) Driver {
fakeDriver := &FakeDriver{
VMExists: vmExists,
ProviderID: providerID,
NodeName: nodeName,
LastKnownState: lastKnownState,
Addresses: addresses,
Err: err,
fakeVMs: make(VMs),
}
Expand All @@ -54,6 +58,7 @@ func (d *FakeDriver) CreateMachine(_ context.Context, _ *CreateMachineRequest) (
ProviderID: d.ProviderID,
NodeName: d.NodeName,
LastKnownState: d.LastKnownState,
Addresses: d.Addresses,
}, nil
}

Expand All @@ -78,6 +83,7 @@ func (d *FakeDriver) InitializeMachine(_ context.Context, _ *InitializeMachineRe
return &InitializeMachineResponse{
ProviderID: d.ProviderID,
NodeName: d.NodeName,
Addresses: d.Addresses,
}, d.Err
}

Expand All @@ -99,6 +105,7 @@ func (d *FakeDriver) GetMachineStatus(_ context.Context, _ *GetMachineStatusRequ
return &GetMachineStatusResponse{
ProviderID: d.ProviderID,
NodeName: d.NodeName,
Addresses: d.Addresses,
}, d.Err
}

Expand Down
22 changes: 13 additions & 9 deletions pkg/util/provider/machinecontroller/controller_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"context"
"flag"
"fmt"
"io"
"strconv"
"strings"
"testing"
Expand Down Expand Up @@ -37,22 +36,27 @@ import (
"k8s.io/client-go/tools/record"
"k8s.io/client-go/util/workqueue"
"k8s.io/klog/v2"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
)

func TestMachineControllerSuite(t *testing.T) {
//to enable goroutine leak check , currently not using as it fails tests for less important leaks
//defer goleak.VerifyNone(t)

RegisterFailHandler(Fail)
RunSpecs(t, "Machine Controller Suite")
}

var _ = BeforeSuite(func() {
klog.SetOutput(GinkgoWriter)
//for filtering out warning logs. Reflector short watch warning logs won't print now
klog.SetOutput(io.Discard)
klog.LogToStderr(false)
flags := &flag.FlagSet{}
klog.InitFlags(flags)
_ = flags.Set("logtostderr", "false")
Expect(flags.Set("v", "10")).To(Succeed())

RegisterFailHandler(Fail)
RunSpecs(t, "Machine Controller Suite")
}
DeferCleanup(klog.Flush)
})

var (
controllerKindMachine = v1alpha1.SchemeGroupVersion.WithKind("Machine")
Expand Down Expand Up @@ -171,8 +175,8 @@ func newMachineSetsFromMachineDeployment(
Kind: t.Kind,
Name: machineDeployment.Name,
UID: machineDeployment.UID,
BlockOwnerDeletion: pointer.BoolPtr(true),
Controller: pointer.BoolPtr(true),
BlockOwnerDeletion: ptr.To(true),
Controller: ptr.To(true),
},
annotations,
finalLabels,
Expand Down
Loading