@@ -204,7 +204,7 @@ func NewRuntimeInstallCommand() *cobra.Command {
204
204
cmd .Flags ().StringToStringVar (& installationOpts .NamespaceLabels , "namespace-labels" , nil , "Optional labels that will be set on the namespace resource. (e.g. \" key1=value1,key2=value2\" " )
205
205
cmd .Flags ().StringToStringVar (& installationOpts .InternalIngressAnnotation , "internal-ingress-annotation" , nil , "Add annotations to the internal ingress" )
206
206
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)" )
208
208
209
209
installationOpts .InsCloneOpts = apu .AddCloneFlags (cmd , & apu.CloneFlagsOptions {
210
210
CreateIfNotExist : true ,
@@ -586,13 +586,15 @@ func runRuntimeInstall(ctx context.Context, opts *RuntimeInstallOptions) error {
586
586
return err
587
587
}
588
588
589
+ provider := model .GitProviders (gitProvider )
590
+
589
591
repoURL := opts .InsCloneOpts .URL ()
590
592
token , iv , err := createRuntimeOnPlatform (ctx , & model.RuntimeInstallationArgs {
591
593
RuntimeName : opts .RuntimeName ,
592
594
Cluster : server ,
593
595
RuntimeVersion : runtimeVersion ,
594
596
IngressHost : & opts .IngressHost ,
595
- GitProvider : model . GitProviders ( gitProvider ) ,
597
+ GitProvider : & provider ,
596
598
InternalIngressHost : & opts .InternalIngressHost ,
597
599
IngressClass : & opts .IngressClass ,
598
600
IngressController : & ingressControllerName ,
@@ -672,14 +674,21 @@ func runRuntimeInstall(ctx context.Context, opts *RuntimeInstallOptions) error {
672
674
return util .DecorateErrorWithDocsLink (fmt .Errorf ("failed to create project: %w" , err ))
673
675
}
674
676
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
+ })
683
692
handleCliStep (reporter .InstallStepCreateOrUpdateConfigMap , "Creating/Updating codefresh-cm" , err , false , true )
684
693
if err != nil {
685
694
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:
1008
1017
func installComponents (ctx context.Context , opts * RuntimeInstallOptions , rt * runtime.Runtime ) error {
1009
1018
var err error
1010
1019
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
1011
1022
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 {
1013
1028
return fmt .Errorf ("failed to patch Argo-Workflows ingress: %w" , err )
1014
1029
}
1015
1030
}
1016
1031
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 {
1018
1037
return fmt .Errorf ("failed to patch App-Proxy ingress: %w" , err )
1019
1038
}
1020
1039
@@ -1799,23 +1818,29 @@ func createEventsReporter(ctx context.Context, cloneOpts *apgit.CloneOptions, op
1799
1818
return err
1800
1819
}
1801
1820
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
+ }
1806
1829
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" }
1810
1834
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
+ }
1815
1838
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
+ })
1817
1843
1818
- return apu .PushWithMessage (ctx , r , "Created Codefresh Event Reporter" )
1819
1844
}
1820
1845
1821
1846
func 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
1839
1864
return err
1840
1865
}
1841
1866
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 )
1846
1872
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
+ }
1850
1876
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
+ }
1854
1880
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
+ }
1859
1888
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
+ }
1863
1892
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" )
1866
1895
1867
- pushMessage := "Created Codefresh" + titleCase .String (reporterCreateOpts .reporterName ) + "Reporter"
1896
+ pushMessage := "Created Codefresh" + titleCase .String (reporterCreateOpts .reporterName ) + "Reporter"
1868
1897
1869
- return apu .PushWithMessage (ctx , r , pushMessage )
1898
+ return apu .PushWithMessage (ctx , r , pushMessage )
1899
+ },
1900
+ })
1870
1901
}
1871
1902
1872
1903
func updateProject (repofs fs.FS , rt * runtime.Runtime ) error {
0 commit comments