diff --git a/src/operator/api/v1alpha3/clientintents_types.go b/src/operator/api/v1alpha3/clientintents_types.go index 75c644f87..c4e626a47 100644 --- a/src/operator/api/v1alpha3/clientintents_types.go +++ b/src/operator/api/v1alpha3/clientintents_types.go @@ -572,13 +572,13 @@ func clientIntentsStatusToCloudFormat(clientIntents ClientIntents, intent Intent status.IstioStatus.ServiceAccountName = toPtrOrNil(serviceAccountName) isSharedValue, ok := clientIntents.Annotations[OtterizeSharedServiceAccountAnnotation] - if !ok { - return nil, false, errors.Errorf("missing annotation shared service account for client intents %s", clientIntents.Name) - } - - isShared, err := strconv.ParseBool(isSharedValue) - if err != nil { - return nil, false, errors.Errorf("failed to parse shared service account annotation for client intents %s", clientIntents.Name) + isShared := false + if ok { + parsedIsShared, err := strconv.ParseBool(isSharedValue) + if err != nil { + return nil, false, errors.Errorf("failed to parse shared service account annotation for client intents %s", clientIntents.Name) + } + isShared = parsedIsShared } status.IstioStatus.IsServiceAccountShared = lo.ToPtr(isShared) diff --git a/src/operator/api/v1beta1/clientintents_types.go b/src/operator/api/v1beta1/clientintents_types.go index 2697af5ff..28e38640e 100644 --- a/src/operator/api/v1beta1/clientintents_types.go +++ b/src/operator/api/v1beta1/clientintents_types.go @@ -574,13 +574,13 @@ func clientIntentsStatusToCloudFormat(clientIntents ClientIntents, intent Intent status.IstioStatus.ServiceAccountName = toPtrOrNil(serviceAccountName) isSharedValue, ok := clientIntents.Annotations[OtterizeSharedServiceAccountAnnotation] - if !ok { - return nil, false, errors.Errorf("missing annotation shared service account for client intents %s", clientIntents.Name) - } - - isShared, err := strconv.ParseBool(isSharedValue) - if err != nil { - return nil, false, errors.Errorf("failed to parse shared service account annotation for client intents %s", clientIntents.Name) + isShared := false + if ok { + parsedIsShared, err := strconv.ParseBool(isSharedValue) + if err != nil { + return nil, false, errors.Errorf("failed to parse shared service account annotation for client intents %s", clientIntents.Name) + } + isShared = parsedIsShared } status.IstioStatus.IsServiceAccountShared = lo.ToPtr(isShared) diff --git a/src/operator/api/v2alpha1/clientintents_types.go b/src/operator/api/v2alpha1/clientintents_types.go index 0794ebf89..a5a37fa65 100644 --- a/src/operator/api/v2alpha1/clientintents_types.go +++ b/src/operator/api/v2alpha1/clientintents_types.go @@ -740,13 +740,13 @@ func clientIntentsStatusToCloudFormat(clientIntents ClientIntents, intent Target status.IstioStatus.ServiceAccountName = toPtrOrNil(serviceAccountName) isSharedValue, ok := clientIntents.Annotations[OtterizeSharedServiceAccountAnnotation] - if !ok { - return nil, false, errors.Errorf("missing annotation shared service account for client intents %s", clientIntents.Name) - } - - isShared, err := strconv.ParseBool(isSharedValue) - if err != nil { - return nil, false, errors.Errorf("failed to parse shared service account annotation for client intents %s", clientIntents.Name) + isShared := false + if ok { + parsedIsShared, err := strconv.ParseBool(isSharedValue) + if err != nil { + return nil, false, errors.Errorf("failed to parse shared service account annotation for client intents %s", clientIntents.Name) + } + isShared = parsedIsShared } status.IstioStatus.IsServiceAccountShared = lo.ToPtr(isShared) diff --git a/src/operator/api/v2beta1/clientintents_types.go b/src/operator/api/v2beta1/clientintents_types.go index 6a6846e5c..73f808bff 100644 --- a/src/operator/api/v2beta1/clientintents_types.go +++ b/src/operator/api/v2beta1/clientintents_types.go @@ -743,13 +743,13 @@ func clientIntentsStatusToCloudFormat(clientIntents ClientIntents, intent Target status.IstioStatus.ServiceAccountName = toPtrOrNil(serviceAccountName) isSharedValue, ok := clientIntents.Annotations[OtterizeSharedServiceAccountAnnotation] - if !ok { - return nil, false, errors.Errorf("missing annotation shared service account for client intents %s", clientIntents.Name) - } - - isShared, err := strconv.ParseBool(isSharedValue) - if err != nil { - return nil, false, errors.Errorf("failed to parse shared service account annotation for client intents %s", clientIntents.Name) + isShared := false + if ok { + parsedIsShared, err := strconv.ParseBool(isSharedValue) + if err != nil { + return nil, false, errors.Errorf("failed to parse shared service account annotation for client intents %s", clientIntents.Name) + } + isShared = parsedIsShared } status.IstioStatus.IsServiceAccountShared = lo.ToPtr(isShared) diff --git a/src/operator/controllers/intents_reconcilers/cloud_reconciler_test.go b/src/operator/controllers/intents_reconcilers/cloud_reconciler_test.go index c9e7508d4..89c05bd38 100644 --- a/src/operator/controllers/intents_reconcilers/cloud_reconciler_test.go +++ b/src/operator/controllers/intents_reconcilers/cloud_reconciler_test.go @@ -476,7 +476,29 @@ func (s *CloudReconcilerTestSuite) TestIntentStatusFormattingError_MissingShared }, } - s.expectReconcilerError(clientIntents) + expectedIntent := graphqlclient.IntentInput{ + ClientName: lo.ToPtr(clientName), + ServerName: lo.ToPtr(server), + Namespace: lo.ToPtr(testNamespace), + ServerNamespace: lo.ToPtr(testNamespace), + Type: lo.ToPtr(graphqlclient.IntentTypeHttp), + Resources: []*graphqlclient.HTTPConfigInput{ + { + Path: lo.ToPtr("/login"), + Methods: []*graphqlclient.HTTPMethod{lo.ToPtr(graphqlclient.HTTPMethodGet), lo.ToPtr(graphqlclient.HTTPMethodPost)}, + }, + }, + Status: &graphqlclient.IntentStatusInput{ + IstioStatus: &graphqlclient.IstioStatusInput{ + ServiceAccountName: lo.ToPtr(serviceAccountName), + IsServiceAccountShared: lo.ToPtr(false), + IsClientMissingSidecar: lo.ToPtr(false), + IsServerMissingSidecar: lo.ToPtr(false), + }, + }, + } + + s.assertReportedIntents(clientIntents, []graphqlclient.IntentInput{expectedIntent}) } func (s *CloudReconcilerTestSuite) TestIntentStatusFormattingError_MissingSidecar() {