Skip to content

Commit bf79f2e

Browse files
authored
Merge pull request #63 from jpculp/ap-southeast-5
Add support for ap-southeast-5
2 parents e48f8b8 + 16d04bc commit bf79f2e

File tree

5 files changed

+8
-189
lines changed

5 files changed

+8
-189
lines changed

sources/api/schnauzer/src/helpers.rs

Lines changed: 1 addition & 180 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ lazy_static! {
3737
m.insert("ap-southeast-2", "328549459982");
3838
m.insert("ap-southeast-3", "386774335080");
3939
m.insert("ap-southeast-4", "731751899352");
40+
m.insert("ap-southeast-5", "851725293737");
4041
m.insert("ca-central-1", "328549459982");
4142
m.insert("ca-west-1", "253897149516");
4243
m.insert("cn-north-1", "183470599484");
@@ -69,52 +70,6 @@ lazy_static! {
6970
const ECR_FALLBACK_REGION: &str = "us-east-1";
7071
const ECR_FALLBACK_REGISTRY: &str = "328549459982";
7172

72-
lazy_static! {
73-
/// A map to tell us which registry to pull pause container images from for a given region.
74-
static ref PAUSE_CONTAINER_MAP: HashMap<&'static str, &'static str> = {
75-
let mut m = HashMap::new();
76-
m.insert("af-south-1", "877085696533");
77-
m.insert("ap-east-1", "800184023465");
78-
m.insert("ap-northeast-1", "602401143452");
79-
m.insert("ap-northeast-2", "602401143452");
80-
m.insert("ap-northeast-3", "602401143452");
81-
m.insert("ap-south-1", "602401143452");
82-
m.insert("ap-south-2", "900889452093");
83-
m.insert("ap-southeast-1", "602401143452");
84-
m.insert("ap-southeast-2", "602401143452");
85-
m.insert("ap-southeast-3", "296578399912");
86-
m.insert("ap-southeast-4", "491585149902");
87-
m.insert("ca-central-1", "602401143452");
88-
m.insert("ca-west-1", "761377655185");
89-
m.insert("cn-north-1", "918309763551");
90-
m.insert("cn-northwest-1", "961992271922");
91-
m.insert("eu-central-1", "602401143452");
92-
m.insert("eu-central-2", "900612956339");
93-
m.insert("eu-north-1", "602401143452");
94-
m.insert("eu-south-1", "590381155156");
95-
m.insert("eu-south-2", "455263428931");
96-
m.insert("eu-west-1", "602401143452");
97-
m.insert("eu-west-2", "602401143452");
98-
m.insert("eu-west-3", "602401143452");
99-
m.insert("il-central-1", "066635153087");
100-
m.insert("me-central-1", "759879836304");
101-
m.insert("me-south-1", "558608220178");
102-
m.insert("sa-east-1", "602401143452");
103-
m.insert("us-east-1", "602401143452");
104-
m.insert("us-east-2", "602401143452");
105-
m.insert("us-gov-east-1", "151742754352");
106-
m.insert("us-gov-west-1", "013241004608");
107-
m.insert("us-west-1", "602401143452");
108-
m.insert("us-west-2", "602401143452");
109-
m
110-
};
111-
}
112-
113-
/// But if there is a region that does not exist in our map (for example a new
114-
/// region is created or being tested), then we will fall back to this.
115-
const PAUSE_FALLBACK_REGISTRY: &str = "602401143452";
116-
const PAUSE_FALLBACK_REGION: &str = "us-east-1";
117-
11873
lazy_static! {
11974
/// A map to tell us which endpoint to pull updates from for a given region.
12075
static ref TUF_ENDPOINT_MAP: HashMap<&'static str, &'static str> = {
@@ -175,12 +130,6 @@ mod error {
175130
template: String,
176131
},
177132

178-
#[snafu(display(
179-
"Expected ecr helper to be called with either 'registry' or 'region', got '{}'",
180-
value,
181-
))]
182-
EcrParam { value: String },
183-
184133
#[snafu(display(
185134
"Incorrect number of params provided to helper '{}' in template '{}' - {} expected, {} received",
186135
helper,
@@ -782,59 +731,6 @@ pub fn ecr_prefix(
782731
Ok(())
783732
}
784733

785-
/// The `pause-prefix` helper is used to map an AWS region to the correct pause
786-
/// container registry.
787-
///
788-
/// Because the repo URL includes the the registry number, we created this helper
789-
/// to lookup the correct registry number for a given region.
790-
///
791-
/// This helper takes the AWS region as its only parameter, and returns the
792-
/// fully qualified domain name to the correct registry.
793-
///
794-
/// # Fallback
795-
///
796-
/// If we do not have the region in our map, a fallback region and registry number
797-
/// are returned. This would allow a version of Bottlerocket to run in a new region
798-
/// before this map has been updated.
799-
///
800-
/// # Example
801-
///
802-
/// In this example the registry number for the region will be returned.
803-
/// `{{ pause-prefix settings.aws.region }}`
804-
///
805-
/// This would result in something like:
806-
/// `602401143452.dkr.ecr.eu-central-1.amazonaws.com`
807-
pub fn pause_prefix(
808-
helper: &Helper<'_, '_>,
809-
_: &Handlebars,
810-
_: &Context,
811-
renderctx: &mut RenderContext<'_, '_>,
812-
out: &mut dyn Output,
813-
) -> Result<(), RenderError> {
814-
trace!("Starting pause prefix helper");
815-
let template_name = template_name(renderctx);
816-
check_param_count(helper, template_name, 1)?;
817-
818-
// get the region parameter, which is probably given by the template value
819-
// settings.aws.region. regardless, we expect it to be a string.
820-
let aws_region = get_param(helper, 0)?;
821-
let aws_region = aws_region.as_str().with_context(|| error::AwsRegionSnafu {
822-
value: aws_region.to_owned(),
823-
template: template_name,
824-
})?;
825-
826-
// construct the registry fqdn
827-
let pause_registry = pause_registry(aws_region);
828-
829-
// write it to the template
830-
out.write(&pause_registry)
831-
.with_context(|_| error::TemplateWriteSnafu {
832-
template: template_name.to_owned(),
833-
})?;
834-
835-
Ok(())
836-
}
837-
838734
/// The `tuf-prefix` helper is used to map an AWS region to the correct TUF
839735
/// repository.
840736
///
@@ -1863,24 +1759,6 @@ fn ecr_registry<S: AsRef<str>>(region: S) -> String {
18631759
}
18641760
}
18651761

1866-
/// Constructs the fully qualified domain name for the pause container (pod infra
1867-
/// container) for the given region. Returns a default if the region is not mapped.
1868-
fn pause_registry<S: AsRef<str>>(region: S) -> String {
1869-
// lookup the registry ID or fallback to the default region and id
1870-
let (region, registry_id) = match PAUSE_CONTAINER_MAP.borrow().get(region.as_ref()) {
1871-
None => (PAUSE_FALLBACK_REGION, PAUSE_FALLBACK_REGISTRY),
1872-
Some(registry_id) => (region.as_ref(), *registry_id),
1873-
};
1874-
let partition = match ALT_PARTITION_MAP.borrow().get(region) {
1875-
None => STANDARD_PARTITION,
1876-
Some(partition) => *partition,
1877-
};
1878-
match partition {
1879-
"aws-cn" => format!("{}.dkr.ecr.{}.amazonaws.com.cn", registry_id, region),
1880-
_ => format!("{}.dkr.ecr.{}.amazonaws.com", registry_id, region),
1881-
}
1882-
}
1883-
18841762
/// Constructs the fully qualified domain name for the TUF repository for the
18851763
/// given region. Returns a default if the region is not mapped.
18861764
fn tuf_repository<S: AsRef<str>>(region: S) -> String {
@@ -2413,63 +2291,6 @@ mod test_ecr_registry {
24132291
}
24142292
}
24152293

2416-
#[cfg(test)]
2417-
mod test_pause_registry {
2418-
use super::*;
2419-
use handlebars::RenderError;
2420-
use serde::Serialize;
2421-
use serde_json::json;
2422-
2423-
// A thin wrapper around the handlebars render_template method that includes
2424-
// setup and registration of helpers
2425-
fn setup_and_render_template<T>(tmpl: &str, data: &T) -> Result<String, RenderError>
2426-
where
2427-
T: Serialize,
2428-
{
2429-
let mut registry = Handlebars::new();
2430-
registry.register_helper("pause-prefix", Box::new(pause_prefix));
2431-
2432-
registry.render_template(tmpl, data)
2433-
}
2434-
2435-
const CONTAINER_TEMPLATE: &str = "{{ pause-prefix settings.aws.region }}/container:tag";
2436-
2437-
const PAUSE_REGISTRY_TESTS: &[(&str, &str)] = &[
2438-
(
2439-
"eu-central-1",
2440-
"602401143452.dkr.ecr.eu-central-1.amazonaws.com/container:tag",
2441-
),
2442-
(
2443-
"af-south-1",
2444-
"877085696533.dkr.ecr.af-south-1.amazonaws.com/container:tag",
2445-
),
2446-
(
2447-
"xy-ztown-1",
2448-
"602401143452.dkr.ecr.us-east-1.amazonaws.com/container:tag",
2449-
),
2450-
(
2451-
"cn-north-1",
2452-
"918309763551.dkr.ecr.cn-north-1.amazonaws.com.cn/container:tag",
2453-
),
2454-
(
2455-
"ap-southeast-4",
2456-
"491585149902.dkr.ecr.ap-southeast-4.amazonaws.com/container:tag",
2457-
),
2458-
];
2459-
2460-
#[test]
2461-
fn pause_container_registry() {
2462-
for (region, expected) in PAUSE_REGISTRY_TESTS {
2463-
let result = setup_and_render_template(
2464-
CONTAINER_TEMPLATE,
2465-
&json!({"settings": {"aws": {"region": *region}}}),
2466-
)
2467-
.unwrap();
2468-
assert_eq!(result, *expected);
2469-
}
2470-
}
2471-
}
2472-
24732294
#[cfg(test)]
24742295
mod test_tuf_repository {
24752296
use super::*;

sources/api/schnauzer/src/v1.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ pub fn build_template_registry() -> Result<handlebars::Handlebars<'static>> {
120120
template_registry.register_helper("join_node_taints", Box::new(helpers::join_node_taints));
121121
template_registry.register_helper("default", Box::new(helpers::default));
122122
template_registry.register_helper("ecr-prefix", Box::new(helpers::ecr_prefix));
123-
template_registry.register_helper("pause-prefix", Box::new(helpers::pause_prefix));
124123
template_registry.register_helper("tuf-prefix", Box::new(helpers::tuf_prefix));
125124
template_registry.register_helper("metadata-prefix", Box::new(helpers::metadata_prefix));
126125
template_registry.register_helper("host", Box::new(helpers::host));

sources/api/schnauzer/src/v2/import/helpers.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ fn all_helpers() -> HashMap<ExtensionName, HashMap<HelperName, Box<dyn HelperDef
4545
"join_node_taints" => helper!(handlebars_helpers::join_node_taints),
4646
"kube_reserve_cpu" => helper!(handlebars_helpers::kube_reserve_cpu),
4747
"kube_reserve_memory" => helper!(handlebars_helpers::kube_reserve_memory),
48-
"pause-prefix" => helper!(handlebars_helpers::pause_prefix),
4948
},
5049

5150
"network" => hashmap! {
@@ -280,7 +279,7 @@ mod test {
280279
let success_cases = &[
281280
("network", "v1", vec!["host"]),
282281
("empty-helpers-succeeds", "v1", vec![]),
283-
("kubernetes", "v1", vec!["pause-prefix"]),
282+
("kubernetes", "v1", vec!["join_node_taints"]),
284283
];
285284

286285
for (setting_name, version, helpers) in fail_cases.into_iter() {
@@ -332,7 +331,6 @@ mod test {
332331
"join_node_taints",
333332
"kube_reserve_cpu",
334333
"kube_reserve_memory",
335-
"pause-prefix",
336334
],
337335
),
338336
];

sources/host-ctr/cmd/host-ctr/main.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ import (
2121
"github.com/containerd/containerd/cio"
2222
"github.com/containerd/containerd/containers"
2323
"github.com/containerd/containerd/contrib/seccomp"
24-
"github.com/containerd/containerd/errdefs"
25-
"github.com/containerd/containerd/log"
2624
"github.com/containerd/containerd/namespaces"
2725
"github.com/containerd/containerd/oci"
2826
"github.com/containerd/containerd/remotes/docker"
2927
"github.com/containerd/containerd/runtime/v2/runc/options"
28+
"github.com/containerd/errdefs"
29+
"github.com/containerd/log"
3030
runtimespec "github.com/opencontainers/runtime-spec/specs-go"
3131
"github.com/pkg/errors"
3232
"github.com/sirupsen/logrus"
@@ -597,7 +597,7 @@ func cleanUp(containerdSocket string, namespace string, containerID string) erro
597597
// Referenced source: https://github.com/awslabs/amazon-ecr-containerd-resolver/blob/a5058cf091f4fc573813a032db37a9820952f1f9/ecr/ref.go#L70-L71
598598
func parseImageURISpecialRegions(input string) (ecr.ECRSpec, error) {
599599
ecrRefPrefixMapping := map[string]string{
600-
"ca-west-1": "ecr.aws/arn:aws:ecr:ca-west-1:",
600+
"ap-southeast-5": "ecr.aws/arn:aws:ecr:ap-southeast-5:",
601601
}
602602
// Matching on account, region
603603
matches := ecrRegex.FindStringSubmatch(input)
@@ -1048,6 +1048,7 @@ func pullImage(ctx context.Context, source string, client *containerd.Client, re
10481048
for {
10491049
var err error
10501050

1051+
//nolint:staticcheck // We will re-evaluate the deprecated WithSchema1Conversion
10511052
pullOpts := []containerd.RemoteOpt{
10521053
withDynamicResolver(ctx, source, registryConfig),
10531054
containerd.WithSchema1Conversion,

sources/host-ctr/go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ require (
88
github.com/aws/aws-sdk-go v1.54.20
99
github.com/awslabs/amazon-ecr-containerd-resolver v0.0.0-20240521172427-b580afd02343
1010
github.com/containerd/containerd v1.7.20
11+
github.com/containerd/errdefs v0.1.0
12+
github.com/containerd/log v0.1.0
1113
github.com/opencontainers/runtime-spec v1.2.0
1214
github.com/pelletier/go-toml v1.9.5
1315
github.com/pkg/errors v0.9.1
@@ -36,11 +38,9 @@ require (
3638
github.com/containerd/cgroups/v3 v3.0.2 // indirect
3739
github.com/containerd/containerd/api v1.7.19 // indirect
3840
github.com/containerd/continuity v0.4.3 // indirect
39-
github.com/containerd/errdefs v0.1.0 // indirect
4041
github.com/containerd/fifo v1.1.0 // indirect
4142
github.com/containerd/go-cni v1.1.9 // indirect
4243
github.com/containerd/imgcrypt v1.1.11 // indirect
43-
github.com/containerd/log v0.1.0 // indirect
4444
github.com/containerd/nri v0.6.1 // indirect
4545
github.com/containerd/platforms v0.2.1 // indirect
4646
github.com/containerd/ttrpc v1.2.5 // indirect

0 commit comments

Comments
 (0)