Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(eks): reuse chart name as chart dir for helmchart deployment from OCI repository #23392

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def helm_handler(event, context):

if repository is not None and repository.startswith('oci://'):
tmpdir = tempfile.TemporaryDirectory()
chart_dir = get_chart_from_oci(tmpdir.name, release, repository, version)
chart_dir = get_chart_from_oci(tmpdir.name, repository, version)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's worth mentioning exactly why this does what it does, for those less familiar with helm and its specifics. Can you put a comment above this line explaining why we need the repository here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put extensive explanation above the rpartition line. This will be "good enough"?

chart = chart_dir

helm('upgrade', release, chart, repository, values_file, namespace, version, wait, timeout, create_namespace)
Expand Down Expand Up @@ -123,7 +123,7 @@ def get_oci_cmd(repository, version):
return cmnd


def get_chart_from_oci(tmpdir, release, repository = None, version = None):
def get_chart_from_oci(tmpdir, repository = None, version = None):

cmnd = get_oci_cmd(repository, version)

Expand All @@ -135,7 +135,9 @@ def get_chart_from_oci(tmpdir, release, repository = None, version = None):
output = subprocess.check_output(cmnd, stderr=subprocess.STDOUT, cwd=tmpdir, shell=True)
logger.info(output)

return os.path.join(tmpdir, release)
# effectively returns "$tmpDir/$lastPartOfOCIUrl", because this is how helm pull saves OCI artifact.
# Eg. if we have oci://9999999999.dkr.ecr.us-east-1.amazonaws.com/foo/bar/pet-service repository, helm saves artifact under $tmpDir/pet-service
return os.path.join(tmpdir, repository.rpartition('/')[-1])
except subprocess.CalledProcessError as exc:
output = exc.output
if b'Broken pipe' in output:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def helm_handler(event, context):

if repository is not None and repository.startswith('oci://'):
tmpdir = tempfile.TemporaryDirectory()
chart_dir = get_chart_from_oci(tmpdir.name, release, repository, version)
chart_dir = get_chart_from_oci(tmpdir.name, repository, version)
chart = chart_dir

helm('upgrade', release, chart, repository, values_file, namespace, version, wait, timeout, create_namespace)
Expand Down Expand Up @@ -123,7 +123,7 @@ def get_oci_cmd(repository, version):
return cmnd


def get_chart_from_oci(tmpdir, release, repository = None, version = None):
def get_chart_from_oci(tmpdir, repository = None, version = None):

cmnd = get_oci_cmd(repository, version)

Expand All @@ -135,7 +135,7 @@ def get_chart_from_oci(tmpdir, release, repository = None, version = None):
output = subprocess.check_output(cmnd, stderr=subprocess.STDOUT, cwd=tmpdir, shell=True)
logger.info(output)

return os.path.join(tmpdir, release)
return os.path.join(tmpdir, repository.rpartition('/')[-1])
except subprocess.CalledProcessError as exc:
output = exc.output
if b'Broken pipe' in output:
Expand Down
Binary file not shown.

This file was deleted.

Loading