Skip to content

Commit

Permalink
change annotation so that pod is restarted
Browse files Browse the repository at this point in the history
  • Loading branch information
agouin committed Oct 18, 2023
1 parent 5fa45da commit dcd6a4e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 19 deletions.
19 changes: 1 addition & 18 deletions controllers/cosmosfullnode_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,24 +226,7 @@ func (r *CosmosFullNodeReconciler) updateStatus(ctx context.Context, crd *cosmos
status.Phase = crd.Status.Phase
status.StatusMessage = crd.Status.StatusMessage
status.Peers = crd.Status.Peers
if len(status.SyncInfo.Pods) != len(consensus.Pods) {
status.SyncInfo = &consensus
} else {
for i := range consensus.Pods {
if consensus.Pods[i].Height != nil {
status.SyncInfo.Pods[i].Height = consensus.Pods[i].Height
}
if consensus.Pods[i].InSync != nil {
status.SyncInfo.Pods[i].InSync = consensus.Pods[i].InSync
}
if consensus.Pods[i].Error != nil {
status.SyncInfo.Pods[i].Error = consensus.Pods[i].Error
}
if !consensus.Pods[i].Timestamp.IsZero() {
status.SyncInfo.Pods[i].Timestamp = consensus.Pods[i].Timestamp
}
}
}
status.SyncInfo = &consensus
}); err != nil {
log.FromContext(ctx).Error(err, "Failed to patch status")
}
Expand Down
6 changes: 5 additions & 1 deletion internal/fullnode/build_pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
)

const configChecksumAnnotation = "cosmos.strange.love/config-checksum"
const (
configChecksumAnnotation = "cosmos.strange.love/config-checksum"
desiredImageAnnotation = "cosmos.strange.love/desired-image"
)

// BuildPods creates the final state of pods given the crd.
func BuildPods(crd *cosmosv1.CosmosFullNode, cksums ConfigChecksums) ([]diff.Resource[*corev1.Pod], error) {
Expand Down Expand Up @@ -58,6 +61,7 @@ func BuildPods(crd *cosmosv1.CosmosFullNode, cksums ConfigChecksums) ([]diff.Res
setMainContainerImage(pod, o.Image)
}
}
pod.Annotations[desiredImageAnnotation] = pod.Spec.Containers[0].Image
pod.Annotations[configChecksumAnnotation] = cksums[client.ObjectKeyFromObject(pod)]
pods = append(pods, diff.Adapt(pod, i))
}
Expand Down

0 comments on commit dcd6a4e

Please sign in to comment.