Skip to content

Commit

Permalink
Merge pull request #2929 from sjenning/skip-release-version-validation
Browse files Browse the repository at this point in the history
TRT-1202: add annotation to skip release image validation
  • Loading branch information
openshift-merge-robot committed Aug 22, 2023
2 parents 572a756 + 4a1f3a4 commit 9b25e74
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions api/v1alpha1/hostedcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const (
// AuditWebhookKubeconfigKey is the key name in the AuditWebhook secret that stores audit webhook kubeconfig
AuditWebhookKubeconfigKey = "webhook-kubeconfig"
DisablePKIReconciliationAnnotation = "hypershift.openshift.io/disable-pki-reconciliation"
SkipReleaseImageValidation = "hypershift.openshift.io/skip-release-image-validation"
IdentityProviderOverridesAnnotationPrefix = "idpoverrides.hypershift.openshift.io/"
OauthLoginURLOverrideAnnotation = "oauth.hypershift.openshift.io/login-url-override"
// KonnectivityServerImageAnnotation is a temporary annotation that allows the specification of the konnectivity server image.
Expand Down
1 change: 1 addition & 0 deletions api/v1beta1/hostedcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const (
// AuditWebhookKubeconfigKey is the key name in the AuditWebhook secret that stores audit webhook kubeconfig
AuditWebhookKubeconfigKey = "webhook-kubeconfig"
DisablePKIReconciliationAnnotation = "hypershift.openshift.io/disable-pki-reconciliation"
SkipReleaseImageValidation = "hypershift.openshift.io/skip-release-image-validation"
IdentityProviderOverridesAnnotationPrefix = "idpoverrides.hypershift.openshift.io/"
OauthLoginURLOverrideAnnotation = "oauth.hypershift.openshift.io/login-url-override"
// ControlPlanePriorityClass is for pods in the HyperShift Control Plane that are not API critical but still need elevated priority. E.g Cluster Version Operator.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3599,6 +3599,9 @@ func (r *HostedClusterReconciler) validateUserCAConfigMaps(ctx context.Context,
}

func (r *HostedClusterReconciler) validateReleaseImage(ctx context.Context, hc *hyperv1.HostedCluster) error {
if _, exists := hc.Annotations[hyperv1.SkipReleaseImageValidation]; exists {
return nil
}
var pullSecret corev1.Secret
if err := r.Client.Get(ctx, types.NamespacedName{Namespace: hc.Namespace, Name: hc.Spec.PullSecret.Name}, &pullSecret); err != nil {
return fmt.Errorf("failed to get pull secret: %w", err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1483,6 +1483,36 @@ func TestValidateReleaseImage(t *testing.T) {
},
expectedResult: nil,
},
{
name: "skip release image validation with annotation, success",
other: []crclient.Object{
&corev1.Secret{
ObjectMeta: metav1.ObjectMeta{Name: "pull-secret"},
Data: map[string][]byte{
corev1.DockerConfigJsonKey: nil,
},
},
},
hostedCluster: &hyperv1.HostedCluster{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{
hyperv1.SkipReleaseImageValidation: "true",
},
},
Spec: hyperv1.HostedClusterSpec{
Networking: hyperv1.ClusterNetworking{
NetworkType: hyperv1.OVNKubernetes,
},
PullSecret: corev1.LocalObjectReference{
Name: "pull-secret",
},
Release: hyperv1.Release{
Image: "image-4.11.0",
},
},
},
expectedResult: nil,
},
}

for _, tc := range testCases {
Expand Down
3 changes: 3 additions & 0 deletions test/e2e/util/hypershift_framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ func (h *hypershiftTest) createHostedCluster(opts *core.CreateOptions, platform
ObjectMeta: metav1.ObjectMeta{
Namespace: namespace.Name,
Name: SimpleNameGenerator.GenerateName("example-"),
Annotations: map[string]string{
hyperv1.SkipReleaseImageValidation: "true",
},
},
Spec: hyperv1.HostedClusterSpec{
Platform: hyperv1.PlatformSpec{
Expand Down

0 comments on commit 9b25e74

Please sign in to comment.