@@ -707,7 +707,7 @@ func HandleVersionChange(skyhook SkyhookNodes) ([]*v1alpha1.Package, error) {
707707
708708 if ! exists && packageStatus .Stage != v1alpha1 .StageUninstall {
709709 // Start uninstall of old package
710- err := node .Upsert (packageStatusRef , packageStatus .Image , v1alpha1 .StateInProgress , v1alpha1 .StageUninstall , 0 )
710+ err := node .Upsert (packageStatusRef , packageStatus .Image , v1alpha1 .StateInProgress , v1alpha1 .StageUninstall , 0 , "" )
711711 if err != nil {
712712 return nil , fmt .Errorf ("error updating node status: %w" , err )
713713 }
@@ -724,21 +724,21 @@ func HandleVersionChange(skyhook SkyhookNodes) ([]*v1alpha1.Package, error) {
724724 }
725725
726726 // start upgrade of package
727- err := node .Upsert (_package .PackageRef , _package .Image , v1alpha1 .StateInProgress , v1alpha1 .StageUpgrade , 0 )
727+ err := node .Upsert (_package .PackageRef , _package .Image , v1alpha1 .StateInProgress , v1alpha1 .StageUpgrade , 0 , _package . ContainerSHA )
728728 if err != nil {
729729 return nil , fmt .Errorf ("error updating node status: %w" , err )
730730 }
731731
732732 upgrade = true
733733 } else if comparison == - 1 && packageStatus .Stage != v1alpha1 .StageUninstall {
734734 // Start uninstall of old package
735- err := node .Upsert (packageStatusRef , packageStatus .Image , v1alpha1 .StateInProgress , v1alpha1 .StageUninstall , 0 )
735+ err := node .Upsert (packageStatusRef , packageStatus .Image , v1alpha1 .StateInProgress , v1alpha1 .StageUninstall , 0 , "" )
736736 if err != nil {
737737 return nil , fmt .Errorf ("error updating node status: %w" , err )
738738 }
739739
740740 // If version changed then update new version to wait
741- err = node .Upsert (_package .PackageRef , _package .Image , v1alpha1 .StateSkipped , v1alpha1 .StageUninstall , 0 )
741+ err = node .Upsert (_package .PackageRef , _package .Image , v1alpha1 .StateSkipped , v1alpha1 .StageUninstall , 0 , _package . ContainerSHA )
742742 if err != nil {
743743 return nil , fmt .Errorf ("error updating node status: %w" , err )
744744 }
@@ -949,7 +949,7 @@ func (r *SkyhookReconciler) HandleConfigUpdates(ctx context.Context, clusterStat
949949 skyhook .GetSkyhook ().AddConfigUpdates (_package .Name , newConfigUpdates ... )
950950
951951 for _ , node := range skyhook .GetNodes () {
952- err := node .Upsert (_package .PackageRef , _package .Image , v1alpha1 .StateInProgress , v1alpha1 .StageConfig , 0 )
952+ err := node .Upsert (_package .PackageRef , _package .Image , v1alpha1 .StateInProgress , v1alpha1 .StageConfig , 0 , _package . ContainerSHA )
953953 if err != nil {
954954 return false , fmt .Errorf ("error upserting node status [%s]: %w" , node .GetNode ().Name , err )
955955 }
@@ -1291,7 +1291,7 @@ func (r *SkyhookReconciler) Interrupt(ctx context.Context, skyhookNode wrapper.S
12911291 return fmt .Errorf ("error creating interruption pod: %w" , err )
12921292 }
12931293
1294- _ = skyhookNode .Upsert (_package .PackageRef , _package .Image , v1alpha1 .StateInProgress , v1alpha1 .StageInterrupt , 0 )
1294+ _ = skyhookNode .Upsert (_package .PackageRef , _package .Image , v1alpha1 .StateInProgress , v1alpha1 .StageInterrupt , 0 , _package . ContainerSHA )
12951295
12961296 r .recorder .Eventf (skyhookNode .GetSkyhook ().Skyhook , EventTypeNormal , EventsReasonSkyhookInterrupt ,
12971297 "Interrupting node [%s] package [%s:%s] from [skyhook:%s]" ,
@@ -1603,6 +1603,16 @@ func getAgentImage(opts SkyhookOperatorOptions, _package *v1alpha1.Package) stri
16031603 return opts .AgentImage
16041604}
16051605
1606+ // getPackageImage returns the full image reference for a package, using the digest if specified
1607+ func getPackageImage (_package * v1alpha1.Package ) string {
1608+ if _package .ContainerSHA != "" {
1609+ // When containerSHA is specified, use it instead of the version tag for immutable image reference
1610+ return fmt .Sprintf ("%s@%s" , _package .Image , _package .ContainerSHA )
1611+ }
1612+ // Fall back to version tag
1613+ return fmt .Sprintf ("%s:%s" , _package .Image , _package .Version )
1614+ }
1615+
16061616func getAgentConfigEnvVars (opts SkyhookOperatorOptions , packageName string , packageVersion string , resourceID string , skyhookName string ) []corev1.EnvVar {
16071617 return []corev1.EnvVar {
16081618 {
@@ -1712,7 +1722,7 @@ func createPodFromPackage(opts SkyhookOperatorOptions, _package *v1alpha1.Packag
17121722 InitContainers : []corev1.Container {
17131723 {
17141724 Name : fmt .Sprintf ("%s-init" , trunstr (_package .Name , 43 )),
1715- Image : fmt . Sprintf ( "%s:%s" , _package . Image , _package . Version ),
1725+ Image : getPackageImage ( _package ),
17161726 ImagePullPolicy : "Always" ,
17171727 Command : []string {"/bin/sh" },
17181728 Args : []string {
@@ -2070,7 +2080,7 @@ func (r *SkyhookReconciler) ProcessInterrupt(ctx context.Context, skyhookNode wr
20702080
20712081 //skipping
20722082 if stage == v1alpha1 .StageInterrupt && ! runInterrupt {
2073- err := skyhookNode .Upsert (_package .PackageRef , _package .Image , v1alpha1 .StateSkipped , stage , 0 )
2083+ err := skyhookNode .Upsert (_package .PackageRef , _package .Image , v1alpha1 .StateSkipped , stage , 0 , _package . ContainerSHA )
20742084 if err != nil {
20752085 return false , fmt .Errorf ("error upserting to skip interrupt: %w" , err )
20762086 }
@@ -2185,7 +2195,7 @@ func (r *SkyhookReconciler) ApplyPackage(ctx context.Context, logger logr.Logger
21852195 return fmt .Errorf ("error creating pod: %w" , err )
21862196 }
21872197
2188- if err = skyhookNode .Upsert (_package .PackageRef , _package .Image , v1alpha1 .StateInProgress , stage , 0 ); err != nil {
2198+ if err = skyhookNode .Upsert (_package .PackageRef , _package .Image , v1alpha1 .StateInProgress , stage , 0 , _package . ContainerSHA ); err != nil {
21892199 err = fmt .Errorf ("error upserting package: %w" , err ) // want to keep going in this case, but don't want to lose the err
21902200 }
21912201
0 commit comments