Skip to content

Commit

Permalink
Display Cilium upgrade skipped status in upgrade plan command (#8909)
Browse files Browse the repository at this point in the history
  • Loading branch information
abhay-krishna authored Oct 30, 2024
1 parent 9907eaf commit 4047261
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
14 changes: 14 additions & 0 deletions pkg/networking/cilium/upgrade_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,20 @@ func ChangeDiff(currentSpec, newSpec *cluster.Spec) *types.ChangeDiff {

func ciliumChangeDiff(currentSpec, newSpec *cluster.Spec) *types.ChangeDiff {
currentVersionsBundle := currentSpec.RootVersionsBundle()

newCiliumCfg := newSpec.Cluster.Spec.ClusterNetwork.CNIConfig.Cilium
if !newCiliumCfg.IsManaged() {
return &types.ChangeDiff{
ComponentReports: []types.ComponentChangeDiff{
{
ComponentName: "cilium",
OldVersion: currentVersionsBundle.Cilium.Version,
NewVersion: "Upgrade skipped (skipUpgrade: true)",
},
},
}
}

newVersionsBundle := newSpec.RootVersionsBundle()
if currentVersionsBundle.Cilium.Version == newVersionsBundle.Cilium.Version {
return nil
Expand Down
27 changes: 26 additions & 1 deletion pkg/networking/cilium/upgrade_plan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/aws/eks-anywhere/pkg/cluster"
"github.com/aws/eks-anywhere/pkg/networking/cilium"
"github.com/aws/eks-anywhere/pkg/types"
"github.com/aws/eks-anywhere/pkg/utils/ptr"
)

func TestBuildUpgradePlan(t *testing.T) {
Expand Down Expand Up @@ -563,7 +564,7 @@ func daemonSet(image string, opts ...dsOpt) *appsv1.DaemonSet {

type cmOpt func(*corev1.ConfigMap)

func ciliumConfigMap(enforcementMode string, egressMasqueradeInterface string, opts ...cmOpt) *corev1.ConfigMap {
func ciliumConfigMap(enforcementMode, egressMasqueradeInterface string, opts ...cmOpt) *corev1.ConfigMap {
cm := &corev1.ConfigMap{
TypeMeta: metav1.TypeMeta{
APIVersion: "v1",
Expand Down Expand Up @@ -918,6 +919,30 @@ func TestChangeDiff(t *testing.T) {
},
},
},
{
name: "cilium upgrade skipped",
currentSpec: test.NewClusterSpec(func(s *cluster.Spec) {
s.Cluster.Spec.KubernetesVersion = "1.22"
s.VersionsBundles["1.22"] = test.VersionBundle()
s.VersionsBundles["1.22"].Cilium.Version = "v1.9.10-eksa.1"
s.Cluster.Spec.ClusterNetwork.CNIConfig = &v1alpha1.CNIConfig{Cilium: &v1alpha1.CiliumConfig{}}
}),
newSpec: test.NewClusterSpec(func(s *cluster.Spec) {
s.Cluster.Spec.KubernetesVersion = "1.22"
s.VersionsBundles["1.22"] = test.VersionBundle()
s.VersionsBundles["1.22"].Cilium.Version = "v1.9.10-eksa.1"
s.Cluster.Spec.ClusterNetwork.CNIConfig = &v1alpha1.CNIConfig{Cilium: &v1alpha1.CiliumConfig{SkipUpgrade: ptr.Bool(true)}}
}),
want: &types.ChangeDiff{
ComponentReports: []types.ComponentChangeDiff{
{
ComponentName: "cilium",
OldVersion: "v1.9.10-eksa.1",
NewVersion: "Upgrade skipped (skipUpgrade: true)",
},
},
},
},
}

for _, tt := range tests {
Expand Down

0 comments on commit 4047261

Please sign in to comment.