@@ -204,7 +204,7 @@ func NewRuntimeInstallCommand() *cobra.Command {
204204 cmd .Flags ().StringToStringVar (& installationOpts .NamespaceLabels , "namespace-labels" , nil , "Optional labels that will be set on the namespace resource. (e.g. \" key1=value1,key2=value2\" " )
205205 cmd .Flags ().StringToStringVar (& installationOpts .InternalIngressAnnotation , "internal-ingress-annotation" , nil , "Add annotations to the internal ingress" )
206206 cmd .Flags ().StringToStringVar (& installationOpts .ExternalIngressAnnotation , "external-ingress-annotation" , nil , "Add annotations to the external ingress" )
207- cmd .Flags ().BoolVar (& installationOpts .EnableGitProviders , "enable-git-providers" , false , "Enable git providers (bitbucket-server|gitlab)" )
207+ cmd .Flags ().BoolVar (& installationOpts .EnableGitProviders , "enable-git-providers" , false , "Enable git providers (bitbucket|bitbucket -server|gitlab)" )
208208
209209 installationOpts .InsCloneOpts = apu .AddCloneFlags (cmd , & apu.CloneFlagsOptions {
210210 CreateIfNotExist : true ,
@@ -586,13 +586,15 @@ func runRuntimeInstall(ctx context.Context, opts *RuntimeInstallOptions) error {
586586 return err
587587 }
588588
589+ provider := model .GitProviders (gitProvider )
590+
589591 repoURL := opts .InsCloneOpts .URL ()
590592 token , iv , err := createRuntimeOnPlatform (ctx , & model.RuntimeInstallationArgs {
591593 RuntimeName : opts .RuntimeName ,
592594 Cluster : server ,
593595 RuntimeVersion : runtimeVersion ,
594596 IngressHost : & opts .IngressHost ,
595- GitProvider : model . GitProviders ( gitProvider ) ,
597+ GitProvider : & provider ,
596598 InternalIngressHost : & opts .InternalIngressHost ,
597599 IngressClass : & opts .IngressClass ,
598600 IngressController : & ingressControllerName ,
@@ -672,14 +674,21 @@ func runRuntimeInstall(ctx context.Context, opts *RuntimeInstallOptions) error {
672674 return util .DecorateErrorWithDocsLink (fmt .Errorf ("failed to create project: %w" , err ))
673675 }
674676
675- // persists codefresh-cm, this must be created before events-reporter eventsource
676- // otherwise it will not start and no events will get to the platform.
677- if ! opts .FromRepo {
678- err = persistRuntime (ctx , opts .InsCloneOpts , rt , opts .CommonConfig )
679- } else {
680- // in case of runtime recovery we only update the existing cm
681- err = updateCodefreshCM (ctx , opts , rt , server )
682- }
677+ // bitbucket cloud take more time to push a commit
678+ // all coming retries perpuse is to avoid issues of cloning before pervious commit was pushed
679+ err = util .Retry (ctx , & util.RetryOptions {
680+ Func : func () error {
681+ // persists codefresh-cm, this must be created before events-reporter eventsource
682+ // otherwise it will not start and no events will get to the platform.
683+ if ! opts .FromRepo {
684+ return persistRuntime (ctx , opts .InsCloneOpts , rt , opts .CommonConfig )
685+ } else {
686+ // in case of runtime recovery we only update the existing cm
687+ return updateCodefreshCM (ctx , opts , rt , server )
688+ }
689+ },
690+ Sleep : 2 ,
691+ })
683692 handleCliStep (reporter .InstallStepCreateOrUpdateConfigMap , "Creating/Updating codefresh-cm" , err , false , true )
684693 if err != nil {
685694 return util .DecorateErrorWithDocsLink (fmt .Errorf ("failed to create or update codefresh-cm: %w" , err ))
@@ -1008,13 +1017,23 @@ you can try to create it manually by running:
10081017func installComponents (ctx context.Context , opts * RuntimeInstallOptions , rt * runtime.Runtime ) error {
10091018 var err error
10101019
1020+ // bitbucket cloud take more time to push a commit
1021+ // all coming retries perpuse is to avoid issues of cloning before pervious commit was pushed
10111022 if ! store .Get ().SkipIngress && rt .Spec .IngressController != string (ingressutil .IngressControllerALB ) {
1012- if err = createWorkflowsIngress (ctx , opts , rt ); err != nil {
1023+ if err = util .Retry (ctx , & util.RetryOptions {
1024+ Func : func () error {
1025+ return createWorkflowsIngress (ctx , opts , rt )
1026+ },
1027+ }); err != nil {
10131028 return fmt .Errorf ("failed to patch Argo-Workflows ingress: %w" , err )
10141029 }
10151030 }
10161031
1017- if err = configureAppProxy (ctx , opts , rt ); err != nil {
1032+ if err = util .Retry (ctx , & util.RetryOptions {
1033+ Func : func () error {
1034+ return configureAppProxy (ctx , opts , rt )
1035+ },
1036+ }); err != nil {
10181037 return fmt .Errorf ("failed to patch App-Proxy ingress: %w" , err )
10191038 }
10201039
@@ -1799,23 +1818,29 @@ func createEventsReporter(ctx context.Context, cloneOpts *apgit.CloneOptions, op
17991818 return err
18001819 }
18011820
1802- r , repofs , err := cloneOpts .GetRepo (ctx )
1803- if err != nil {
1804- return err
1805- }
1821+ // bitbucket cloud take more time to push a commit
1822+ // all coming retries perpuse is to avoid issues of cloning before pervious commit was pushed
1823+ return util .Retry (ctx , & util.RetryOptions {
1824+ Func : func () error {
1825+ r , repofs , err := opts .InsCloneOpts .GetRepo (ctx )
1826+ if err != nil {
1827+ return err
1828+ }
18061829
1807- if err := createEventsReporterEventSource (repofs , resPath , opts .RuntimeName , opts .Insecure ); err != nil {
1808- return err
1809- }
1830+ if err = createEventsReporterEventSource (repofs , resPath , opts .RuntimeName , opts .Insecure ); err != nil {
1831+ return err
1832+ }
1833+ eventsReporterTriggers := []string {"events" }
18101834
1811- eventsReporterTriggers := []string {"events" }
1812- if err := createSensor (repofs , store .Get ().EventsReporterName , resPath , opts .RuntimeName , store .Get ().EventsReporterName , eventsReporterTriggers , "data" ); err != nil {
1813- return err
1814- }
1835+ if err = createSensor (repofs , store .Get ().EventsReporterName , resPath , opts .RuntimeName , store .Get ().EventsReporterName , eventsReporterTriggers , "data" ); err != nil {
1836+ return err
1837+ }
18151838
1816- log .G (ctx ).Info ("Pushing Event Reporter manifests" )
1839+ log .G (ctx ).Info ("Pushing Event Reporter manifests" )
1840+ return apu .PushWithMessage (ctx , r , "Created Codefresh Event Reporter" )
1841+ },
1842+ })
18171843
1818- return apu .PushWithMessage (ctx , r , "Created Codefresh Event Reporter" )
18191844}
18201845
18211846func createReporter (ctx context.Context , cloneOpts * apgit.CloneOptions , opts * RuntimeInstallOptions , reporterCreateOpts reporterCreateOptions ) error {
@@ -1839,34 +1864,40 @@ func createReporter(ctx context.Context, cloneOpts *apgit.CloneOptions, opts *Ru
18391864 return err
18401865 }
18411866
1842- r , repofs , err := cloneOpts .GetRepo (ctx )
1843- if err != nil {
1844- return err
1845- }
1867+ // bitbucket cloud take more time to push a commit
1868+ // all coming retries perpuse is to avoid issues of cloning before pervious commit was pushed
1869+ return util .Retry (ctx , & util.RetryOptions {
1870+ Func : func () error {
1871+ r , repofs , err := opts .InsCloneOpts .GetRepo (ctx )
18461872
1847- if err := createReporterRBAC ( repofs , resPath , opts . RuntimeName , reporterCreateOpts . saName , reporterCreateOpts . clusterScope ); err != nil {
1848- return err
1849- }
1873+ if err != nil {
1874+ return err
1875+ }
18501876
1851- if err := createReporterEventSource (repofs , resPath , opts .RuntimeName , reporterCreateOpts , reporterCreateOpts .clusterScope ); err != nil {
1852- return err
1853- }
1877+ if err = createReporterRBAC (repofs , resPath , opts .RuntimeName , reporterCreateOpts . saName , reporterCreateOpts .clusterScope ); err != nil {
1878+ return err
1879+ }
18541880
1855- var triggerNames []string
1856- for _ , gvr := range reporterCreateOpts .gvr {
1857- triggerNames = append (triggerNames , gvr .resourceName )
1858- }
1881+ if err = createReporterEventSource (repofs , resPath , opts .RuntimeName , reporterCreateOpts , reporterCreateOpts .clusterScope ); err != nil {
1882+ return err
1883+ }
1884+ var triggerNames []string
1885+ for _ , gvr := range reporterCreateOpts .gvr {
1886+ triggerNames = append (triggerNames , gvr .resourceName )
1887+ }
18591888
1860- if err : = createSensor (repofs , reporterCreateOpts .reporterName , resPath , opts .RuntimeName , reporterCreateOpts .reporterName , triggerNames , "data.object" ); err != nil {
1861- return err
1862- }
1889+ if err = createSensor (repofs , reporterCreateOpts .reporterName , resPath , opts .RuntimeName , reporterCreateOpts .reporterName , triggerNames , "data.object" ); err != nil {
1890+ return err
1891+ }
18631892
1864- titleCase := cases .Title (language .AmericanEnglish )
1865- log .G (ctx ).Info ("Pushing Codefresh " , titleCase .String (reporterCreateOpts .reporterName ), " manifests" )
1893+ titleCase := cases .Title (language .AmericanEnglish )
1894+ log .G (ctx ).Info ("Pushing Codefresh " , titleCase .String (reporterCreateOpts .reporterName ), " manifests" )
18661895
1867- pushMessage := "Created Codefresh" + titleCase .String (reporterCreateOpts .reporterName ) + "Reporter"
1896+ pushMessage := "Created Codefresh" + titleCase .String (reporterCreateOpts .reporterName ) + "Reporter"
18681897
1869- return apu .PushWithMessage (ctx , r , pushMessage )
1898+ return apu .PushWithMessage (ctx , r , pushMessage )
1899+ },
1900+ })
18701901}
18711902
18721903func updateProject (repofs fs.FS , rt * runtime.Runtime ) error {
0 commit comments