From 1ae0938ff4dee6ee2ff2c6e639f9b85a862ab9a5 Mon Sep 17 00:00:00 2001 From: Gyuho Lee Date: Fri, 15 May 2020 16:09:27 -0700 Subject: [PATCH] eksconfig: fix ECR repos Signed-off-by: Gyuho Lee --- eksconfig/add-on-cluster-loader-remote.go | 2 +- eksconfig/add-on-fargate.go | 2 +- eksconfig/add-on-hollow-nodes-remote.go | 3 +-- eksconfig/add-on-irsa-fargate.go | 2 +- eksconfig/add-on-irsa.go | 2 +- eksconfig/default.yaml | 6 +++--- eksconfig/env_test.go | 25 +++++++++++++++++++++++ 7 files changed, 33 insertions(+), 9 deletions(-) diff --git a/eksconfig/add-on-cluster-loader-remote.go b/eksconfig/add-on-cluster-loader-remote.go index ccf093f76..08f72ad14 100644 --- a/eksconfig/add-on-cluster-loader-remote.go +++ b/eksconfig/add-on-cluster-loader-remote.go @@ -115,7 +115,7 @@ func (cfg *Config) validateAddOnClusterLoaderRemote() error { if cfg.AddOnClusterLoaderRemote.RepositoryURI == "" { return errors.New("AddOnClusterLoaderRemote.RepositoryURI empty") } - if strings.Contains(cfg.AddOnClusterLoaderRemote.RepositoryURI, cfg.AddOnClusterLoaderRemote.RepositoryAccountID) { + if !strings.Contains(cfg.AddOnClusterLoaderRemote.RepositoryURI, cfg.AddOnClusterLoaderRemote.RepositoryAccountID) { return fmt.Errorf("AddOnClusterLoaderRemote.RepositoryURI %q does not have AddOnClusterLoaderRemote.RepositoryAccountID %q", cfg.AddOnClusterLoaderRemote.RepositoryURI, cfg.AddOnClusterLoaderRemote.RepositoryAccountID) } if cfg.AddOnClusterLoaderRemote.RepositoryImageTag == "" { diff --git a/eksconfig/add-on-fargate.go b/eksconfig/add-on-fargate.go index 99a8269e6..83171d2a6 100644 --- a/eksconfig/add-on-fargate.go +++ b/eksconfig/add-on-fargate.go @@ -145,7 +145,7 @@ func (cfg *Config) validateAddOnFargate() error { if cfg.AddOnFargate.RepositoryName == "" { return errors.New("AddOnFargate.RepositoryName empty") } - if strings.Contains(cfg.AddOnFargate.RepositoryURI, cfg.AddOnFargate.RepositoryAccountID) { + if !strings.Contains(cfg.AddOnFargate.RepositoryURI, cfg.AddOnFargate.RepositoryAccountID) { return fmt.Errorf("AddOnFargate.RepositoryURI %q does not have AddOnFargate.RepositoryAccountID %q", cfg.AddOnFargate.RepositoryURI, cfg.AddOnFargate.RepositoryAccountID) } if cfg.AddOnFargate.RepositoryImageTag == "" { diff --git a/eksconfig/add-on-hollow-nodes-remote.go b/eksconfig/add-on-hollow-nodes-remote.go index 285e5106b..29d9d320a 100644 --- a/eksconfig/add-on-hollow-nodes-remote.go +++ b/eksconfig/add-on-hollow-nodes-remote.go @@ -47,7 +47,6 @@ type AddOnHollowNodesRemote struct { // "cmd/kubelet/app.rlimit.SetNumFiles(MaxOpenFiles)" sets this for the host. MaxOpenFiles int64 `json:"max-open-files"` - // RepositoryAccountID is the account ID for tester ECR image. // e.g. "aws/aws-k8s-tester" for "[ACCOUNT_ID].dkr.ecr.us-west-2.amazonaws.com/aws/aws-k8s-tester" RepositoryAccountID string `json:"repository-account-id,omitempty"` @@ -132,7 +131,7 @@ func (cfg *Config) validateAddOnHollowNodesRemote() error { if cfg.AddOnHollowNodesRemote.RepositoryURI == "" { return errors.New("AddOnHollowNodesRemote.RepositoryURI empty") } - if strings.Contains(cfg.AddOnHollowNodesRemote.RepositoryURI, cfg.AddOnHollowNodesRemote.RepositoryAccountID) { + if !strings.Contains(cfg.AddOnHollowNodesRemote.RepositoryURI, cfg.AddOnHollowNodesRemote.RepositoryAccountID) { return fmt.Errorf("AddOnHollowNodesRemote.RepositoryURI %q does not have AddOnHollowNodesRemote.RepositoryAccountID %q", cfg.AddOnHollowNodesRemote.RepositoryURI, cfg.AddOnHollowNodesRemote.RepositoryAccountID) } if cfg.AddOnHollowNodesRemote.RepositoryImageTag == "" { diff --git a/eksconfig/add-on-irsa-fargate.go b/eksconfig/add-on-irsa-fargate.go index ef6462e83..e12bcb8cd 100644 --- a/eksconfig/add-on-irsa-fargate.go +++ b/eksconfig/add-on-irsa-fargate.go @@ -118,7 +118,7 @@ func (cfg *Config) validateAddOnIRSAFargate() error { if cfg.AddOnIRSAFargate.RepositoryURI == "" { return errors.New("AddOnIRSAFargate.RepositoryURI empty") } - if strings.Contains(cfg.AddOnIRSAFargate.RepositoryURI, cfg.AddOnIRSAFargate.RepositoryAccountID) { + if !strings.Contains(cfg.AddOnIRSAFargate.RepositoryURI, cfg.AddOnIRSAFargate.RepositoryAccountID) { return fmt.Errorf("AddOnIRSAFargate.RepositoryURI %q does not have AddOnIRSAFargate.RepositoryAccountID %q", cfg.AddOnIRSAFargate.RepositoryURI, cfg.AddOnIRSAFargate.RepositoryAccountID) } if cfg.AddOnIRSAFargate.RepositoryImageTag == "" { diff --git a/eksconfig/add-on-irsa.go b/eksconfig/add-on-irsa.go index 51c9e2a64..d5ffe321e 100644 --- a/eksconfig/add-on-irsa.go +++ b/eksconfig/add-on-irsa.go @@ -119,7 +119,7 @@ func (cfg *Config) validateAddOnIRSA() error { if cfg.AddOnIRSA.RepositoryURI == "" { return errors.New("AddOnIRSA.RepositoryURI empty") } - if strings.Contains(cfg.AddOnIRSA.RepositoryURI, cfg.AddOnIRSA.RepositoryAccountID) { + if !strings.Contains(cfg.AddOnIRSA.RepositoryURI, cfg.AddOnIRSA.RepositoryAccountID) { return fmt.Errorf("AddOnIRSA.RepositoryURI %q does not have AddOnIRSA.RepositoryAccountID %q", cfg.AddOnIRSA.RepositoryURI, cfg.AddOnIRSA.RepositoryAccountID) } if cfg.AddOnIRSA.RepositoryImageTag == "" { diff --git a/eksconfig/default.yaml b/eksconfig/default.yaml index 7eb9730bd..503bcaf14 100644 --- a/eksconfig/default.yaml +++ b/eksconfig/default.yaml @@ -21,7 +21,7 @@ log-level: info log-outputs: - stderr - /home/ANT.AMAZON.COM/leegyuho/go/src/github.com/aws/aws-k8s-tester/eksconfig/default.log -name: eks-2020051515-icyz2siqheib +name: eks-2020051516-reinventplqq on-failure-delete: true on-failure-delete-wait-seconds: 120 parameters: @@ -38,7 +38,7 @@ parameters: role-cfn-stack-id: "" role-create: true role-managed-policy-arns: null - role-name: eks-2020051515-icyz2siqheib-role + role-name: eks-2020051516-reinventplqq-role role-service-principals: null signing-name: eks tags: null @@ -51,7 +51,7 @@ partition: aws region: us-west-2 remote-access-commands-output-path: /home/ANT.AMAZON.COM/leegyuho/go/src/github.com/aws/aws-k8s-tester/eksconfig/default.ssh.sh remote-access-key-create: true -remote-access-key-name: eks-2020051515-icyz2siqheib-key-nodes +remote-access-key-name: eks-2020051516-reinventplqq-key-nodes remote-access-private-key-path: /home/ANT.AMAZON.COM/leegyuho/.ssh/kube_aws_rsa s3-bucket-create: false s3-bucket-create-keep: false diff --git a/eksconfig/env_test.go b/eksconfig/env_test.go index 084c27eea..6af56792d 100644 --- a/eksconfig/env_test.go +++ b/eksconfig/env_test.go @@ -266,6 +266,8 @@ func TestEnv(t *testing.T) { defer os.Unsetenv("AWS_K8S_TESTER_EKS_ADD_ON_FARGATE_ROLE_MANAGED_POLICY_ARNS") os.Setenv("AWS_K8S_TESTER_EKS_ADD_ON_FARGATE_PROFILE_NAME", "hello") defer os.Unsetenv("AWS_K8S_TESTER_EKS_ADD_ON_FARGATE_PROFILE_NAME") + os.Setenv("AWS_K8S_TESTER_EKS_ADD_ON_FARGATE_REPOSITORY_ACCOUNT_ID", "uri") + defer os.Unsetenv("AWS_K8S_TESTER_EKS_ADD_ON_FARGATE_REPOSITORY_ACCOUNT_ID") os.Setenv("AWS_K8S_TESTER_EKS_ADD_ON_FARGATE_REPOSITORY_NAME", "fargate-repo-name") defer os.Unsetenv("AWS_K8S_TESTER_EKS_ADD_ON_FARGATE_REPOSITORY_NAME") os.Setenv("AWS_K8S_TESTER_EKS_ADD_ON_FARGATE_REPOSITORY_URI", "fargate-repo-uri") @@ -285,6 +287,8 @@ func TestEnv(t *testing.T) { defer os.Unsetenv("AWS_K8S_TESTER_EKS_ADD_ON_IRSA_ROLE_MANAGED_POLICY_ARNS") os.Setenv("AWS_K8S_TESTER_EKS_ADD_ON_IRSA_S3_KEY", "hello") defer os.Unsetenv("AWS_K8S_TESTER_EKS_ADD_ON_IRSA_S3_KEY") + os.Setenv("AWS_K8S_TESTER_EKS_ADD_ON_IRSA_REPOSITORY_ACCOUNT_ID", "uri") + defer os.Unsetenv("AWS_K8S_TESTER_EKS_ADD_ON_IRSA_REPOSITORY_ACCOUNT_ID") os.Setenv("AWS_K8S_TESTER_EKS_ADD_ON_IRSA_REPOSITORY_NAME", "irsa-repo-name") defer os.Unsetenv("AWS_K8S_TESTER_EKS_ADD_ON_IRSA_REPOSITORY_NAME") os.Setenv("AWS_K8S_TESTER_EKS_ADD_ON_IRSA_REPOSITORY_URI", "irsa-repo-uri") @@ -308,6 +312,8 @@ func TestEnv(t *testing.T) { defer os.Unsetenv("AWS_K8S_TESTER_EKS_ADD_ON_IRSA_FARGATE_S3_KEY") os.Setenv("AWS_K8S_TESTER_EKS_ADD_ON_IRSA_FARGATE_PROFILE_NAME", "hello") defer os.Unsetenv("AWS_K8S_TESTER_EKS_ADD_ON_IRSA_FARGATE_PROFILE_NAME") + os.Setenv("AWS_K8S_TESTER_EKS_ADD_ON_IRSA_FARGATE_REPOSITORY_ACCOUNT_ID", "uri") + defer os.Unsetenv("AWS_K8S_TESTER_EKS_ADD_ON_IRSA_FARGATE_REPOSITORY_ACCOUNT_ID") os.Setenv("AWS_K8S_TESTER_EKS_ADD_ON_IRSA_FARGATE_REPOSITORY_NAME", "irsa-fargate-repo-name") defer os.Unsetenv("AWS_K8S_TESTER_EKS_ADD_ON_IRSA_FARGATE_REPOSITORY_NAME") os.Setenv("AWS_K8S_TESTER_EKS_ADD_ON_IRSA_FARGATE_REPOSITORY_URI", "irsa-fargate-repo-uri") @@ -336,6 +342,8 @@ func TestEnv(t *testing.T) { defer os.Unsetenv("AWS_K8S_TESTER_EKS_ADD_ON_HOLLOW_NODES_REMOTE_NAMESPACE") os.Setenv("AWS_K8S_TESTER_EKS_ADD_ON_HOLLOW_NODES_REMOTE_NODES", "333") defer os.Unsetenv("AWS_K8S_TESTER_EKS_ADD_ON_HOLLOW_NODES_REMOTE_NODES") + os.Setenv("AWS_K8S_TESTER_EKS_ADD_ON_HOLLOW_NODES_REMOTE_REPOSITORY_ACCOUNT_ID", "uri") + defer os.Unsetenv("AWS_K8S_TESTER_EKS_ADD_ON_HOLLOW_NODES_REMOTE_REPOSITORY_ACCOUNT_ID") os.Setenv("AWS_K8S_TESTER_EKS_ADD_ON_HOLLOW_NODES_REMOTE_REPOSITORY_NAME", "hollow-nodes-repo-name") defer os.Unsetenv("AWS_K8S_TESTER_EKS_ADD_ON_HOLLOW_NODES_REMOTE_REPOSITORY_NAME") os.Setenv("AWS_K8S_TESTER_EKS_ADD_ON_HOLLOW_NODES_REMOTE_REPOSITORY_URI", "hollow-nodes-repo-uri") @@ -352,6 +360,8 @@ func TestEnv(t *testing.T) { defer os.Unsetenv("AWS_K8S_TESTER_EKS_ADD_ON_CLUSTER_LOADER_REMOTE_ENABLE") os.Setenv("AWS_K8S_TESTER_EKS_ADD_ON_CLUSTER_LOADER_REMOTE_DURATION", "7m30s") defer os.Unsetenv("AWS_K8S_TESTER_EKS_ADD_ON_CLUSTER_LOADER_REMOTE_DURATION") + os.Setenv("AWS_K8S_TESTER_EKS_ADD_ON_CLUSTER_LOADER_REMOTE_REPOSITORY_ACCOUNT_ID", "uri") + defer os.Unsetenv("AWS_K8S_TESTER_EKS_ADD_ON_CLUSTER_LOADER_REMOTE_REPOSITORY_ACCOUNT_ID") os.Setenv("AWS_K8S_TESTER_EKS_ADD_ON_CLUSTER_LOADER_REMOTE_REPOSITORY_NAME", "cluster-loader-repo-name") defer os.Unsetenv("AWS_K8S_TESTER_EKS_ADD_ON_CLUSTER_LOADER_REMOTE_REPOSITORY_NAME") os.Setenv("AWS_K8S_TESTER_EKS_ADD_ON_CLUSTER_LOADER_REMOTE_REPOSITORY_URI", "cluster-loader-repo-uri") @@ -829,6 +839,9 @@ func TestEnv(t *testing.T) { if cfg.AddOnFargate.ProfileName != "hello" { t.Fatalf("unexpected cfg.AddOnFargate.ProfileName %q", cfg.AddOnFargate.ProfileName) } + if cfg.AddOnFargate.RepositoryAccountID != "uri" { + t.Fatalf("unexpected cfg.AddOnFargate.RepositoryAccountID %v", cfg.AddOnFargate.RepositoryAccountID) + } if cfg.AddOnFargate.RepositoryName != "fargate-repo-name" { t.Fatalf("unexpected cfg.AddOnFargate.RepositoryName %v", cfg.AddOnFargate.RepositoryName) } @@ -858,6 +871,9 @@ func TestEnv(t *testing.T) { if cfg.AddOnIRSA.S3Key != "hello" { t.Fatalf("unexpected cfg.AddOnIRSA.S3Key %q", cfg.AddOnIRSA.S3Key) } + if cfg.AddOnIRSA.RepositoryAccountID != "uri" { + t.Fatalf("unexpected cfg.AddOnIRSA.RepositoryAccountID %v", cfg.AddOnIRSA.RepositoryAccountID) + } if cfg.AddOnIRSA.RepositoryName != "irsa-repo-name" { t.Fatalf("unexpected cfg.AddOnIRSA.RepositoryName %v", cfg.AddOnIRSA.RepositoryName) } @@ -894,6 +910,9 @@ func TestEnv(t *testing.T) { if cfg.AddOnIRSAFargate.ProfileName != "hello" { t.Fatalf("unexpected cfg.AddOnIRSAFargate.ProfileName %q", cfg.AddOnIRSAFargate.ProfileName) } + if cfg.AddOnIRSAFargate.RepositoryAccountID != "uri" { + t.Fatalf("unexpected cfg.AddOnIRSAFargate.RepositoryAccountID %v", cfg.AddOnIRSAFargate.RepositoryAccountID) + } if cfg.AddOnIRSAFargate.RepositoryName != "irsa-fargate-repo-name" { t.Fatalf("unexpected cfg.AddOnIRSAFargate.RepositoryName %v", cfg.AddOnIRSAFargate.RepositoryName) } @@ -933,6 +952,9 @@ func TestEnv(t *testing.T) { if cfg.AddOnHollowNodesRemote.Namespace != "test-hollow-nodes-namespace" { t.Fatalf("unexpected cfg.AddOnHollowNodesRemote.Namespace %v", cfg.AddOnHollowNodesRemote.Namespace) } + if cfg.AddOnHollowNodesRemote.RepositoryAccountID != "uri" { + t.Fatalf("unexpected cfg.AddOnHollowNodesRemote.RepositoryAccountID %v", cfg.AddOnHollowNodesRemote.RepositoryAccountID) + } if cfg.AddOnHollowNodesRemote.RepositoryName != "hollow-nodes-repo-name" { t.Fatalf("unexpected cfg.AddOnHollowNodesRemote.RepositoryName %v", cfg.AddOnHollowNodesRemote.RepositoryName) } @@ -956,6 +978,9 @@ func TestEnv(t *testing.T) { if cfg.AddOnClusterLoaderRemote.Duration != 7*time.Minute+30*time.Second { t.Fatalf("unexpected cfg.AddOnClusterLoaderRemote.Duration %v", cfg.AddOnClusterLoaderRemote.Duration) } + if cfg.AddOnClusterLoaderRemote.RepositoryAccountID != "uri" { + t.Fatalf("unexpected cfg.AddOnClusterLoaderRemote.RepositoryAccountID %v", cfg.AddOnClusterLoaderRemote.RepositoryAccountID) + } if cfg.AddOnClusterLoaderRemote.RepositoryName != "cluster-loader-repo-name" { t.Fatalf("unexpected cfg.AddOnClusterLoaderRemote.RepositoryName %v", cfg.AddOnClusterLoaderRemote.RepositoryName) }