nstamatelopoulos / OCP-disconnected-wrapper

4 stars 1 forks source link

user_data template file has grown too large #3

Open bverschueren opened 8 months ago

bverschueren commented 8 months ago

The user_data file has grown loo large, making the creation of a registry fail with:

module.Cluster_Dependencies[0].aws_vpc_endpoint.elb: Refreshing state... [id=<vpcid>]                                                                                                                                          
╷                                                                                                                                                                                                                                             
│ Error: expected length of user_data to be in the range (0 - 16384), got #!/bin/bash                                                                                                                                                         
│                                                                                                                      
│ #=================================================================================================                                                                                                                                          
│ echo "Creating root directory"                                                                                                                                                                                                              
│ #=================================================================================================     
.
<...>
.
│   with aws_instance.mirror-registry,
│   on Disconnected-template.tf line 103, in resource "aws_instance" "mirror-registry":
│  103:   user_data = templatefile("registry-mirror-script-terraform.tpl", {
│  104:         private_subnet_1 = var.Create_Cluster ? module.Cluster_Dependencies[0].Subnet_1 : "N/A"
│  105:         private_subnet_2 = var.Create_Cluster ? module.Cluster_Dependencies[0].Subnet_2 : "N/A"
│  106:         private_subnet_3 = var.Create_Cluster ? module.Cluster_Dependencies[0].Subnet_3 : "N/A"
│  107:         region           = data.aws_region.current.name
│  108:         access_key_id     = var.Create_Cluster ? module.Cluster_Dependencies[0].IAM_User_Access_Key_id : "N/A"
│  109:         access_key_secret = var.Create_Cluster ? module.Cluster_Dependencies[0].IAM_User_Access_key_Secret : "N/A"
│  110:         cluster_VPC_id    = aws_vpc.disconnected-vpc.id
│  111:   })
nstamatelopoulos commented 8 months ago

Thanks Bram for noticing this. The issue is with the size of the pull-secret the user is using. In more detail:

The user_data file after is populated with all the required variables from Terraform is getting too big. The limits from AWS are 0 - 16384 bytes. If that is exceeded then this error will appear.

I noticed that the pull secret is getting injected in the user_data file beautified that is adding ~ 200 bytes more depending on the size of the pull-secret.

I can try to make it one liner and also to remove some data from user_data script to make it more difficult for this to happen, but again this is not a fix but a workaround as the file is very close to the limit and it can cause problems.

I have plans to reduce the file to half the size as im planning to remove the need to predefine everything during installation and to enable post installation actions to be also possible. But this will take some time.

I will make some changes and update here.

nstamatelopoulos commented 8 months ago

Resolved with release v1.2. Bram please test again and let me know if I can close this issue.