Skip to content

Commit

Permalink
chore: Remove machine references
Browse files Browse the repository at this point in the history
  • Loading branch information
Callisto13 committed Dec 1, 2022
1 parent 24dee39 commit eae1da0
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 36 deletions.
16 changes: 8 additions & 8 deletions api/v1alpha1/microvm_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,39 +107,39 @@ type MicrovmStatus struct {
VMState *microvm.VMState `json:"vmState,omitempty"`

// FailureReason will be set in the event that there is a terminal problem
// reconciling the Machine and will contain a succinct value suitable
// reconciling the Microvm and will contain a succinct value suitable
// for machine interpretation.
//
// This field should not be set for transitive errors that a controller
// faces that are expected to be fixed automatically over
// time (like service outages), but instead indicate that something is
// fundamentally wrong with the Machine's spec or the configuration of
// fundamentally wrong with the Microvm's spec or the configuration of
// the controller, and that manual intervention is required. Examples
// of terminal errors would be invalid combinations of settings in the
// spec, values that are unsupported by the controller, or the
// responsible controller itself being critically misconfigured.
//
// Any transient errors that occur during the reconciliation of Machines
// can be added as events to the Machine object and/or logged in the
// Any transient errors that occur during the reconciliation of Microvm
// can be added as events to the Microvm object and/or logged in the
// controller's output.
// +optional
FailureReason *string `json:"failureReason,omitempty"`

// FailureMessage will be set in the event that there is a terminal problem
// reconciling the Machine and will contain a more verbose string suitable
// reconciling the Microvm and will contain a more verbose string suitable
// for logging and human consumption.
//
// This field should not be set for transitive errors that a controller
// faces that are expected to be fixed automatically over
// time (like service outages), but instead indicate that something is
// fundamentally wrong with the Machine's spec or the configuration of
// fundamentally wrong with the Microvm's spec or the configuration of
// the controller, and that manual intervention is required. Examples
// of terminal errors would be invalid combinations of settings in the
// spec, values that are unsupported by the controller, or the
// responsible controller itself being critically misconfigured.
//
// Any transient errors that occur during the reconciliation of Machines
// can be added as events to the Machine object and/or logged in the
// Any transient errors that occur during the reconciliation of Microvm
// can be added as events to the Microvm object and/or logged in the
// controller's output.
// +optional
FailureMessage *string `json:"failureMessage,omitempty"`
Expand Down
20 changes: 10 additions & 10 deletions controllers/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@ func assertConditionFalse(g *WithT, from conditions.Getter, conditionType cluste
g.Expect(c.Reason).To(Equal(reason))
}

func assertVMState(g *WithT, machine *infrav1.Microvm, expectedState microvm.VMState) {
g.Expect(machine.Status.VMState).NotTo(BeNil())
g.Expect(*machine.Status.VMState).To(BeEquivalentTo(expectedState))
func assertVMState(g *WithT, mvm *infrav1.Microvm, expectedState microvm.VMState) {
g.Expect(mvm.Status.VMState).NotTo(BeNil())
g.Expect(*mvm.Status.VMState).To(BeEquivalentTo(expectedState))
}

func assertMicrovmReconciled(g *WithT, reconciled *infrav1.Microvm) {
Expand All @@ -182,20 +182,20 @@ func assertMicrovmReconciled(g *WithT, reconciled *infrav1.Microvm) {
g.Expect(reconciled.Spec.ProviderID).ToNot(BeNil())
expectedProviderID := fmt.Sprintf("microvm://127.0.0.1:9090/%s", testMicrovmUID)
g.Expect(*reconciled.Spec.ProviderID).To(Equal(expectedProviderID))
g.Expect(reconciled.Status.Ready).To(BeTrue(), "The Ready property must be true when the machine has been reconciled")
g.Expect(reconciled.Status.Ready).To(BeTrue(), "The Ready property must be true when the mvm has been reconciled")
}

func assertFinalizer(g *WithT, reconciled *infrav1.Microvm) {
g.Expect(reconciled.ObjectMeta.Finalizers).NotTo(BeEmpty(), "Expected at least one finalizer to be set")
g.Expect(hasMicrovmFinalizer(reconciled)).To(BeTrue(), "Expect the mvm machine finalizer")
g.Expect(hasMicrovmFinalizer(reconciled)).To(BeTrue(), "Expect the mvm finalizer")
}

func hasMicrovmFinalizer(machine *infrav1.Microvm) bool {
if len(machine.ObjectMeta.Finalizers) == 0 {
func hasMicrovmFinalizer(mvm *infrav1.Microvm) bool {
if len(mvm.ObjectMeta.Finalizers) == 0 {
return false
}

for _, f := range machine.ObjectMeta.Finalizers {
for _, f := range mvm.ObjectMeta.Finalizers {
if f == infrav1.MvmFinalizer {
return true
}
Expand All @@ -204,8 +204,8 @@ func hasMicrovmFinalizer(machine *infrav1.Microvm) bool {
return false
}

func assertMicrovmNotReady(g *WithT, machine *infrav1.Microvm) {
g.Expect(machine.Status.Ready).To(BeFalse())
func assertMicrovmNotReady(g *WithT, mvm *infrav1.Microvm) {
g.Expect(mvm.Status.Ready).To(BeFalse())
}

func assertVendorData(g *WithT, vendorDataRaw string, expectedSSHKeys []microvm.SSHPublicKey) {
Expand Down
8 changes: 4 additions & 4 deletions controllers/microvm_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ func (r *MicrovmReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
Logger: log,
})
if err != nil {
log.Error(err, "failed to create machine scope")
log.Error(err, "failed to create mvm scope")

return ctrl.Result{}, fmt.Errorf("failed to create machine scope: %w", err)
return ctrl.Result{}, fmt.Errorf("failed to create mvm scope: %w", err)
}

defer func() {
Expand All @@ -99,7 +99,7 @@ func (r *MicrovmReconciler) reconcileDelete(
ctx context.Context,
mvmScope *scope.MicrovmScope,
) (reconcile.Result, error) {
mvmScope.Info("Reconciling MicrovmMachine delete")
mvmScope.Info("Reconciling Microvm delete")

mvmSvc, err := r.getMicrovmService(mvmScope)
if err != nil {
Expand All @@ -120,7 +120,7 @@ func (r *MicrovmReconciler) reconcileDelete(
if microvm != nil {
mvmScope.Info("deleting microvm", "name", mvmScope.Name())

// Mark the machine as no longer ready before we delete.
// Mark the mvm as no longer ready before we delete.
mvmScope.SetNotReady(infrav1.MicrovmDeletingReason, "Info", "")

defer func() {
Expand Down
16 changes: 8 additions & 8 deletions controllers/microvm_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func TestMicrovm_ReconcileNormal_VMExistsAndPending(t *testing.T) {
g.Expect(result.IsZero()).To(BeFalse(), "Expect a requeue to be requested")

reconciled, err := getMicrovm(client, testMicrovmName, testNamespace)
g.Expect(err).NotTo(HaveOccurred(), "Getting microvm machine should not fail")
g.Expect(err).NotTo(HaveOccurred(), "Getting microvm should not fail")

assertConditionFalse(g, reconciled, infrav1.MicrovmReadyCondition, infrav1.MicrovmPendingReason)
assertVMState(g, reconciled, microvm.VMStatePending)
Expand All @@ -92,7 +92,7 @@ func TestMicrovm_ReconcileNormal_VMExistsButFailed(t *testing.T) {
g.Expect(err).To(HaveOccurred(), "Reconciling when microvm service exists and state failed should return an error")

reconciled, err := getMicrovm(client, testMicrovmName, testNamespace)
g.Expect(err).NotTo(HaveOccurred(), "Getting microvm machine should not fail")
g.Expect(err).NotTo(HaveOccurred(), "Getting microvm should not fail")

assertConditionFalse(g, reconciled, infrav1.MicrovmReadyCondition, infrav1.MicrovmProvisionFailedReason)
assertVMState(g, reconciled, microvm.VMStateFailed)
Expand All @@ -112,7 +112,7 @@ func TestMicrovm_ReconcileNormal_VMExistsButUnknownState(t *testing.T) {
g.Expect(err).To(HaveOccurred(), "Reconciling when microvm service exists and state is unknown should return an error")

reconciled, err := getMicrovm(client, testMicrovmName, testNamespace)
g.Expect(err).NotTo(HaveOccurred(), "Getting microvm machine should not fail")
g.Expect(err).NotTo(HaveOccurred(), "Getting microvm should not fail")

assertConditionFalse(g, reconciled, infrav1.MicrovmReadyCondition, infrav1.MicrovmUnknownStateReason)
assertVMState(g, reconciled, microvm.VMStateUnknown)
Expand All @@ -139,7 +139,7 @@ func TestMicrovm_ReconcileNormal_NoVmCreateSucceeds(t *testing.T) {
g.Expect(createReq.Microvm).ToNot(BeNil())

reconciled, err := getMicrovm(client, testMicrovmName, testNamespace)
g.Expect(err).NotTo(HaveOccurred(), "Getting microvm machine should not fail")
g.Expect(err).NotTo(HaveOccurred(), "Getting microvm should not fail")

expectedProviderID := fmt.Sprintf("microvm://127.0.0.1:9090/%s", testMicrovmUID)
g.Expect(reconciled.Spec.ProviderID).To(Equal(pointer.String(expectedProviderID)))
Expand Down Expand Up @@ -204,10 +204,10 @@ func TestMicrovm_ReconcileNormal_NoVmCreateWithSSHSucceeds(t *testing.T) {
g := NewWithT(t)

expectedKeys := []microvm.SSHPublicKey{{
AuthorizedKeys: []string{"MachineSSH"},
AuthorizedKeys: []string{"SSH"},
User: "root",
}, {
AuthorizedKeys: []string{"MachineSSH"},
AuthorizedKeys: []string{"SSH"},
User: "ubuntu",
}}

Expand Down Expand Up @@ -256,7 +256,7 @@ func TestMicrovm_ReconcileNormal_NoVmCreateWithAdditionalReconcileSucceeds(t *te
g.Expect(err).NotTo(HaveOccurred(), "Reconciling should not return an error")

reconciled, err := getMicrovm(client, testMicrovmName, testNamespace)
g.Expect(err).NotTo(HaveOccurred(), "Getting microvm machine should not fail")
g.Expect(err).NotTo(HaveOccurred(), "Getting microvm should not fail")
assertMicrovmReconciled(g, reconciled)
}

Expand Down Expand Up @@ -353,7 +353,7 @@ func TestMicrovm_ReconcileDelete_DeleteErrors(t *testing.T) {
g.Expect(err).To(HaveOccurred(), "Reconciling when deleting microvm errors should return error")

reconciled, err := getMicrovm(client, testMicrovmName, testNamespace)
g.Expect(err).NotTo(HaveOccurred(), "Getting microvm machine should not fail")
g.Expect(err).NotTo(HaveOccurred(), "Getting microvm should not fail")

assertConditionFalse(g, reconciled, infrav1.MicrovmReadyCondition, infrav1.MicrovmDeleteFailedReason)
assertMicrovmNotReady(g, reconciled)
Expand Down
2 changes: 1 addition & 1 deletion internal/scope/mvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func NewMicrovmScope(params MicrovmScopeParams) (*MicrovmScope, error) {

patchHelper, err := patch.NewHelper(params.MicroVM, params.Client)
if err != nil {
return nil, fmt.Errorf("creating patch helper for microvm machine: %w", err)
return nil, fmt.Errorf("creating patch helper for microvm: %w", err)
}

scope := &MicrovmScope{
Expand Down
10 changes: 5 additions & 5 deletions internal/scope/mvm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func TestMicrovmProviderID(t *testing.T) {
Expect(mvmScope.GetProviderID()).To(Equal("microvm://fd1/abcdef"))
}

func TestMachineGetInstanceID(t *testing.T) {
func TestMicrovmGetInstanceID(t *testing.T) {
RegisterTestingT(t)

scheme, err := setupScheme()
Expand All @@ -63,7 +63,7 @@ func TestMachineGetInstanceID(t *testing.T) {
}

// This is all temporary
func TestMachineGetBasicAuthToken(t *testing.T) {
func TestMicrovmGetBasicAuthToken(t *testing.T) {
RegisterTestingT(t)

scheme, err := setupScheme()
Expand Down Expand Up @@ -150,7 +150,7 @@ func TestMachineGetBasicAuthToken(t *testing.T) {
}
}

func TestMachineGetTLSConfig(t *testing.T) {
func TestMicrovmGetTLSConfig(t *testing.T) {
RegisterTestingT(t)

scheme, err := setupScheme()
Expand Down Expand Up @@ -233,14 +233,14 @@ func TestMachineGetTLSConfig(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
RegisterTestingT(t)
client := fake.NewClientBuilder().WithScheme(scheme).WithObjects(tc.initObjects...).Build()
machineScope, err := scope.NewMicrovmScope(scope.MicrovmScopeParams{
mvm, err := scope.NewMicrovmScope(scope.MicrovmScopeParams{
Client: client,
MicroVM: tc.mvm,
Logger: testr.New(t),
})
Expect(err).NotTo(HaveOccurred())

tc.expected(machineScope.GetTLSConfig())
tc.expected(mvm.GetTLSConfig())
})
}
}
Expand Down

0 comments on commit eae1da0

Please sign in to comment.