Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
paths-ignore: [docs/**, "**.md", "**.mdx", "**.png", "**.jpg"]

env:
GO_VERSION: '1.23.1'
GO_VERSION: '1.23.6'

jobs:
detect-noop:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/code-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:

env:
# Common versions
GO_VERSION: '1.23.1'
GO_VERSION: '1.23.6'

jobs:

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codespell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0
uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1
with:
egress-policy: audit

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/trivy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ env:
MEMBER_AGENT_IMAGE_NAME: member-agent
REFRESH_TOKEN_IMAGE_NAME: refresh-token

GO_VERSION: '1.23.1'
GO_VERSION: '1.23.6'

jobs:
export-registry:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ on:
paths-ignore: [docs/**, "**.md", "**.mdx", "**.png", "**.jpg"]

env:
GO_VERSION: '1.23.1'
GO_VERSION: '1.23.6'

jobs:
detect-noop:
Expand Down
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
run:
timeout: 15m
go: '1.23.1'
go: '1.23.6'

linters-settings:
stylecheck:
Expand Down
2 changes: 1 addition & 1 deletion docker/hub-agent.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the hubagent binary
FROM mcr.microsoft.com/oss/go/microsoft/golang:1.23.1 AS builder
FROM mcr.microsoft.com/oss/go/microsoft/golang:1.23.6 AS builder

WORKDIR /workspace
# Copy the Go Modules manifests
Expand Down
2 changes: 1 addition & 1 deletion docker/member-agent.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the memberagent binary
FROM mcr.microsoft.com/oss/go/microsoft/golang:1.23.1 AS builder
FROM mcr.microsoft.com/oss/go/microsoft/golang:1.23.6 AS builder

WORKDIR /workspace
# Copy the Go Modules manifests
Expand Down
2 changes: 1 addition & 1 deletion docker/refresh-token.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the hubagent binary
FROM mcr.microsoft.com/oss/go/microsoft/golang:1.23.1 AS builder
FROM mcr.microsoft.com/oss/go/microsoft/golang:1.23.6 AS builder

WORKDIR /workspace
# Copy the Go Modules manifests
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module go.goms.io/fleet

go 1.23.1
go 1.23.6

require (
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.16.0
Expand Down
36 changes: 3 additions & 33 deletions pkg/controllers/clusterresourceplacementeviction/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import (
"go.goms.io/fleet/pkg/utils/controller"
"go.goms.io/fleet/pkg/utils/controller/metrics"
"go.goms.io/fleet/pkg/utils/defaulter"
evictionutils "go.goms.io/fleet/pkg/utils/eviction"
)

// Reconciler reconciles a ClusterResourcePlacementEviction object.
Expand Down Expand Up @@ -70,7 +71,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req runtime.Request) (runtim
return runtime.Result{}, client.IgnoreNotFound(err)
}

if isEvictionInTerminalState(&eviction) {
if evictionutils.IsEvictionInTerminalState(&eviction) {
return runtime.Result{}, nil
}

Expand Down Expand Up @@ -200,7 +201,7 @@ func (r *Reconciler) executeEviction(ctx context.Context, validationResult *evic
return nil
}

if !isPlacementPresent(evictionTargetBinding) {
if !evictionutils.IsPlacementPresent(evictionTargetBinding) {
klog.V(2).InfoS("No resources have been placed for ClusterResourceBinding in target cluster",
"clusterResourcePlacementEviction", eviction.Name, "clusterResourceBinding", evictionTargetBinding.Name, "targetCluster", eviction.Spec.ClusterName)
markEvictionNotExecuted(eviction, condition.EvictionBlockedMissingPlacementMessage)
Expand Down Expand Up @@ -251,37 +252,6 @@ func (r *Reconciler) executeEviction(ctx context.Context, validationResult *evic
return nil
}

// isEvictionInTerminalState checks to see if eviction is in a terminal state.
func isEvictionInTerminalState(eviction *placementv1beta1.ClusterResourcePlacementEviction) bool {
validCondition := eviction.GetCondition(string(placementv1beta1.PlacementEvictionConditionTypeValid))
if condition.IsConditionStatusFalse(validCondition, eviction.GetGeneration()) {
klog.V(2).InfoS("Invalid eviction, no need to reconcile", "clusterResourcePlacementEviction", eviction.Name)
return true
}

executedCondition := eviction.GetCondition(string(placementv1beta1.PlacementEvictionConditionTypeExecuted))
if executedCondition != nil {
klog.V(2).InfoS("Eviction has executed condition specified, no need to reconcile", "clusterResourcePlacementEviction", eviction.Name)
return true
}
return false
}

// isPlacementPresent checks to see if placement on target cluster could be present.
func isPlacementPresent(binding *placementv1beta1.ClusterResourceBinding) bool {
if binding.Spec.State == placementv1beta1.BindingStateBound {
return true
}
if binding.Spec.State == placementv1beta1.BindingStateUnscheduled {
currentAnnotation := binding.GetAnnotations()
previousState, exist := currentAnnotation[placementv1beta1.PreviousBindingStateAnnotation]
if exist && placementv1beta1.BindingState(previousState) == placementv1beta1.BindingStateBound {
return true
}
}
return false
}

// isEvictionAllowed calculates if eviction allowed based on available bindings and spec specified in placement disruption budget.
func isEvictionAllowed(bindings []placementv1beta1.ClusterResourceBinding, crp placementv1beta1.ClusterResourcePlacement, db placementv1beta1.ClusterResourcePlacementDisruptionBudget) (bool, int) {
availableBindings := 0
Expand Down
15 changes: 15 additions & 0 deletions pkg/controllers/updaterun/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,19 @@ func (r *Reconciler) ensureFinalizer(ctx context.Context, updateRun *placementv1

// recordUpdateRunSucceeded records the succeeded condition in the ClusterStagedUpdateRun status.
func (r *Reconciler) recordUpdateRunSucceeded(ctx context.Context, updateRun *placementv1beta1.ClusterStagedUpdateRun) error {
meta.SetStatusCondition(&updateRun.Status.Conditions, metav1.Condition{
Type: string(placementv1beta1.StagedUpdateRunConditionProgressing),
Status: metav1.ConditionFalse,
ObservedGeneration: updateRun.Generation,
Reason: condition.UpdateRunSucceededReason,
Message: "All stages are completed",
})
meta.SetStatusCondition(&updateRun.Status.Conditions, metav1.Condition{
Type: string(placementv1beta1.StagedUpdateRunConditionSucceeded),
Status: metav1.ConditionTrue,
ObservedGeneration: updateRun.Generation,
Reason: condition.UpdateRunSucceededReason,
Message: "All stages are completed successfully",
})
if updateErr := r.Client.Status().Update(ctx, updateRun); updateErr != nil {
klog.ErrorS(updateErr, "Failed to update the ClusterStagedUpdateRun status as succeeded", "clusterStagedUpdateRun", klog.KObj(updateRun))
Expand All @@ -212,6 +220,13 @@ func (r *Reconciler) recordUpdateRunSucceeded(ctx context.Context, updateRun *pl

// recordUpdateRunFailed records the failed condition in the ClusterStagedUpdateRun status.
func (r *Reconciler) recordUpdateRunFailed(ctx context.Context, updateRun *placementv1beta1.ClusterStagedUpdateRun, message string) error {
meta.SetStatusCondition(&updateRun.Status.Conditions, metav1.Condition{
Type: string(placementv1beta1.StagedUpdateRunConditionProgressing),
Status: metav1.ConditionFalse,
ObservedGeneration: updateRun.Generation,
Reason: condition.UpdateRunFailedReason,
Message: "The stages are aborted due to a non-recoverable error",
})
meta.SetStatusCondition(&updateRun.Status.Conditions, metav1.Condition{
Type: string(placementv1beta1.StagedUpdateRunConditionSucceeded),
Status: metav1.ConditionFalse,
Expand Down
23 changes: 23 additions & 0 deletions pkg/controllers/updaterun/controller_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,8 @@ func generateFalseCondition(obj client.Object, condType any) metav1.Condition {
switch cond {
case placementv1beta1.StageUpdatingConditionSucceeded:
reason = condition.StageUpdatingFailedReason
case placementv1beta1.StageUpdatingConditionProgressing:
reason = condition.StageUpdatingWaitingReason
}
typeStr = string(cond)
case placementv1beta1.ClusterUpdatingStatusConditionType:
Expand All @@ -592,3 +594,24 @@ func generateFalseCondition(obj client.Object, condType any) metav1.Condition {
Reason: reason,
}
}

func generateFalseProgressingCondition(obj client.Object, condType any, succeeded bool) metav1.Condition {
falseCond := generateFalseCondition(obj, condType)
reason := ""
switch condType {
case placementv1beta1.StagedUpdateRunConditionProgressing:
if succeeded {
reason = condition.UpdateRunSucceededReason
} else {
reason = condition.UpdateRunFailedReason
}
case placementv1beta1.StageUpdatingConditionProgressing:
if succeeded {
reason = condition.StageUpdatingSucceededReason
} else {
reason = condition.StageUpdatingFailedReason
}
}
falseCond.Reason = reason
return falseCond
}
24 changes: 24 additions & 0 deletions pkg/controllers/updaterun/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ func (r *Reconciler) updateApprovalRequestAccepted(ctx context.Context, appReq *
Status: metav1.ConditionTrue,
ObservedGeneration: appReq.Generation,
Reason: condition.ApprovalRequestApprovalAcceptedReason,
Message: "The approval request has been approved and cannot be reverted",
}
meta.SetStatusCondition(&appReq.Status.Conditions, cond)
if err := r.Client.Status().Update(ctx, appReq); err != nil {
Expand Down Expand Up @@ -454,6 +455,7 @@ func markUpdateRunStarted(updateRun *placementv1beta1.ClusterStagedUpdateRun) {
Status: metav1.ConditionTrue,
ObservedGeneration: updateRun.Generation,
Reason: condition.UpdateRunStartedReason,
Message: "The stages started updating",
})
}

Expand All @@ -467,6 +469,7 @@ func markStageUpdatingStarted(stageUpdatingStatus *placementv1beta1.StageUpdatin
Status: metav1.ConditionTrue,
ObservedGeneration: generation,
Reason: condition.StageUpdatingStartedReason,
Message: "Clusters in the stage started updating",
})
}

Expand All @@ -477,6 +480,7 @@ func markStageUpdatingWaiting(stageUpdatingStatus *placementv1beta1.StageUpdatin
Status: metav1.ConditionFalse,
ObservedGeneration: generation,
Reason: condition.StageUpdatingWaitingReason,
Message: "All clusters in the stage are updated, waiting for after-stage tasks to complete",
})
}

Expand All @@ -485,11 +489,19 @@ func markStageUpdatingSucceeded(stageUpdatingStatus *placementv1beta1.StageUpdat
if stageUpdatingStatus.EndTime == nil {
stageUpdatingStatus.EndTime = &metav1.Time{Time: time.Now()}
}
meta.SetStatusCondition(&stageUpdatingStatus.Conditions, metav1.Condition{
Type: string(placementv1beta1.StageUpdatingConditionProgressing),
Status: metav1.ConditionFalse,
ObservedGeneration: generation,
Reason: condition.StageUpdatingSucceededReason,
Message: "All clusters in the stage are updated and after-stage tasks are completed",
})
meta.SetStatusCondition(&stageUpdatingStatus.Conditions, metav1.Condition{
Type: string(placementv1beta1.StageUpdatingConditionSucceeded),
Status: metav1.ConditionTrue,
ObservedGeneration: generation,
Reason: condition.StageUpdatingSucceededReason,
Message: "Stage update completed successfully",
})
}

Expand All @@ -498,6 +510,13 @@ func markStageUpdatingFailed(stageUpdatingStatus *placementv1beta1.StageUpdating
if stageUpdatingStatus.EndTime == nil {
stageUpdatingStatus.EndTime = &metav1.Time{Time: time.Now()}
}
meta.SetStatusCondition(&stageUpdatingStatus.Conditions, metav1.Condition{
Type: string(placementv1beta1.StageUpdatingConditionProgressing),
Status: metav1.ConditionFalse,
ObservedGeneration: generation,
Reason: condition.StageUpdatingFailedReason,
Message: "Stage update aborted due to a non-recoverable error",
})
meta.SetStatusCondition(&stageUpdatingStatus.Conditions, metav1.Condition{
Type: string(placementv1beta1.StageUpdatingConditionSucceeded),
Status: metav1.ConditionFalse,
Expand All @@ -514,6 +533,7 @@ func markClusterUpdatingStarted(clusterUpdatingStatus *placementv1beta1.ClusterU
Status: metav1.ConditionTrue,
ObservedGeneration: generation,
Reason: condition.ClusterUpdatingStartedReason,
Message: "Cluster update started",
})
}

Expand All @@ -524,6 +544,7 @@ func markClusterUpdatingSucceeded(clusterUpdatingStatus *placementv1beta1.Cluste
Status: metav1.ConditionTrue,
ObservedGeneration: generation,
Reason: condition.ClusterUpdatingSucceededReason,
Message: "Cluster update completed successfully",
})
}

Expand All @@ -545,6 +566,7 @@ func markAfterStageRequestCreated(afterStageTaskStatus *placementv1beta1.AfterSt
Status: metav1.ConditionTrue,
ObservedGeneration: generation,
Reason: condition.AfterStageTaskApprovalRequestCreatedReason,
Message: "ClusterApprovalRequest is created",
})
}

Expand All @@ -555,6 +577,7 @@ func markAfterStageRequestApproved(afterStageTaskStatus *placementv1beta1.AfterS
Status: metav1.ConditionTrue,
ObservedGeneration: generation,
Reason: condition.AfterStageTaskApprovalRequestApprovedReason,
Message: "ClusterApprovalRequest is approved",
})
}

Expand All @@ -565,5 +588,6 @@ func markAfterStageWaitTimeElapsed(afterStageTaskStatus *placementv1beta1.AfterS
Status: metav1.ConditionTrue,
ObservedGeneration: generation,
Reason: condition.AfterStageTaskWaitTimeElapsedReason,
Message: "Wait time elapsed",
})
}
Loading
Loading