Skip to content

Include python wheel packages when moving downloaded dependencies archives#5647

Merged
pchila merged 1 commit intoelastic:mainfrom
pchila:fix-unified-release
Oct 1, 2024
Merged

Include python wheel packages when moving downloaded dependencies archives#5647
pchila merged 1 commit intoelastic:mainfrom
pchila:fix-unified-release

Conversation

@pchila
Copy link
Member

@pchila pchila commented Oct 1, 2024

What does this PR do?

This commit modifies movePackagesToArchive() function to include python wheel packages introduced with commit 701f8b9 .
This solves an issue when packaging docker images using a DROP_PATH env var: prior to this change, the python wheel archives present in DROP_PATH were not moved to <DROP PATH>/archive/<platform> failing to create an image for which the Dockerfile expects to install the python wheel package

Why is it important?

To have a successful docker image creation during unified build processes.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in ./changelog/fragments using the changelog tool
  • I have added an integration test or an E2E test

Disruptive User Impact

How to test this PR locally

Package the docker image "service" for elastic agent using a DROP_PATH (and optionally a manifest), for example:

AGENT_DROP_PATH=./build/agentdrop MANIFEST_URL=https://snapshots.elastic.co/9.0.0-3ca48ed8/agent-package/agent-artifacts-9.0.0-SNAPSHOT.json SNAPSHOT=true PLATFORMS="linux/amd64" PACKAGES="docker" DOCKER_VARIANT="service" mage -v downloadManifest packageUsingDRA

Related issues

Questions to ask yourself

  • How are we going to support this in production?
  • How are we going to measure its adoption?
  • How are we going to debug this?
  • What are the metrics I should take care of?
  • ...

…hives

This commit modifies movePackagesToArchive() function to include python
wheel packages introduced with commit 701f8b9 .
This solves an issue when packaging docker images using a DROP_PATH env
var: prior to this change, the python wheel archives present in
DROP_PATH were not moved to `<DROP PATH>/archive/<platform>` failing to
create an image for which the Dockerfile expects to install the python
wheel package
@pchila pchila added the Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team label Oct 1, 2024
@pchila pchila self-assigned this Oct 1, 2024
@pchila pchila requested a review from a team as a code owner October 1, 2024 10:35
@elasticmachine
Copy link
Contributor

Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane)

@mergify
Copy link
Contributor

mergify bot commented Oct 1, 2024

This pull request does not have a backport label. Could you fix it @pchila? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-./d./d is the label to automatically backport to the 8./d branch. /d is the digit

@mergify
Copy link
Contributor

mergify bot commented Oct 1, 2024

backport-v8.x has been added to help with the transition to the new branch 8.x.
If you don't need it please use backport-skip label and remove the backport-8.x label.

@mergify mergify bot added the backport-8.x Automated backport to the 8.x branch with mergify label Oct 1, 2024
@elastic-sonarqube
Copy link

Quality Gate passed Quality Gate passed

Issues
0 New issues
0 Fixed issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarQube

Copy link
Contributor

@blakerouse blakerouse left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this. Packaging process is complicated.

Copy link
Contributor

@blakerouse blakerouse left a comment

Choose a reason for hiding this comment

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

Actually, I have an open question. Does this mean that the .zip is being included into all docker images? I wanted it to only add that zip in the -service variant. It should not increase the size of all docker containers.

@pchila
Copy link
Member Author

pchila commented Oct 1, 2024

Actually, I have an open question. Does this mean that the .zip is being included into all docker images? I wanted it to only add that zip in the -service variant. It should not increase the size of all docker containers.

Just tested generating all docker image variants with this fix: only elastic-agent-service image contains the connector but it's a bit hacky.
All docker images include all flattened dependencies (extracted in the flat directory by calling flattenDependencies()): in case of the connectors, there's an explicit removal of those packages from the flat dir, so the package remains only in the archives directory where the Dockerfile picks it up.

For example, launching

AGENT_DROP_PATH=./build/agentdrop MANIFEST_URL=https://snapshots.elastic.co/9.0.0-3ca48ed8/agent-package/agent-artifacts-9.0.0-SNAPSHOT.json SNAPSHOT=true PLATFORMS="linux/amd64" PACKAGES="docker" mage -v downloadManifest packageUsingDRA

results in these packaging directories (one per docker image variant)

➜  elastic-agent git:(fix-unified-release) ✗ tree -L 1  build/package/
build/package/
├── elastic-agent
├── elastic-agent-cloud
├── elastic-agent-complete
├── elastic-agent-complete-wolfi
├── elastic-agent-service
├── elastic-agent-ubi
└── elastic-agent-wolfi

7 directories, 0 files

If we search for connectors we find them only in the elastic-agent-service variant

➜  elastic-agent git:(fix-unified-release) ✗ find  build/package/ -name 'connectors*'
build/package/elastic-agent-service/elastic-agent-linux-amd64.docker/docker-build/beat/data/service/connectors-9.0.0-SNAPSHOT.zip
build/package/elastic-agent-service/elastic-agent-linux-amd64.docker/docker-build/beat/data/elastic-agent-0ebada/components/connectors
build/package/elastic-agent-service/elastic-agent-linux-amd64.docker/docker-build/beat/data/elastic-agent-0ebada/components/connectors.spec.yml

as specified by the agent_docker_service_spec where the .zip file is taken directly from the archives directory of the respective architecture name

  # service build is based on previous cloud variant
  - &agent_docker_service_spec
    docker_variant: 'service'
    files:
      'data/service/connectors-{{ beat_version }}{{if .Snapshot}}-SNAPSHOT{{end}}.zip':
        source: '{{.AgentDropPath}}/archives/{{.GOOS}}-{{.AgentArchName}}.tar.gz/connectors-{{ beat_version }}{{if .Snapshot}}-SNAPSHOT{{end}}.zip'
        mode: 0755
      'data/{{.BeatName}}-{{ commit_short }}/components/connectors':
        source: '{{ elastic_beats_dir }}/dev-tools/packaging/files/linux/connectors.sh'
        mode: 0755
      'data/{{.BeatName}}-{{ commit_short }}/components/connectors.spec.yml':
        source: '{{ elastic_beats_dir }}/specs/connectors.spec.yml'
        mode: 0644

@pchila
Copy link
Member Author

pchila commented Oct 1, 2024

Thanks for fixing this. Packaging process is complicated.

Indeed. 😃

@pchila pchila merged commit 23621df into elastic:main Oct 1, 2024
mergify bot pushed a commit that referenced this pull request Oct 1, 2024
…hives (#5647)

This commit modifies movePackagesToArchive() function to include python
wheel packages introduced with commit 701f8b9 .
This solves an issue when packaging docker images using a DROP_PATH env
var: prior to this change, the python wheel archives present in
DROP_PATH were not moved to `<DROP PATH>/archive/<platform>` failing to
create an image for which the Dockerfile expects to install the python
wheel package

(cherry picked from commit 23621df)

# Conflicts:
#	magefile.go
blakerouse pushed a commit that referenced this pull request Oct 1, 2024
…hives (#5647)

This commit modifies movePackagesToArchive() function to include python
wheel packages introduced with commit 701f8b9 .
This solves an issue when packaging docker images using a DROP_PATH env
var: prior to this change, the python wheel archives present in
DROP_PATH were not moved to `<DROP PATH>/archive/<platform>` failing to
create an image for which the Dockerfile expects to install the python
wheel package
pierrehilbert pushed a commit that referenced this pull request Oct 14, 2024
#5634)

* Add elastic-agent-service container to packaging (#5349)

Adds the elastic-agent-service container with the py-connectors component enabled.

(cherry picked from commit 701f8b9)

# Conflicts:
#	dev-tools/mage/manifest/manifest.go

* Update manifest.go

Fix conflicts caused by mergify

* Include python wheel packages when moving downloaded dependencies archives (#5647)

This commit modifies movePackagesToArchive() function to include python
wheel packages introduced with commit 701f8b9 .
This solves an issue when packaging docker images using a DROP_PATH env
var: prior to this change, the python wheel archives present in
DROP_PATH were not moved to `<DROP PATH>/archive/<platform>` failing to
create an image for which the Dockerfile expects to install the python
wheel package

* Fix docker image build when multiple platforms are specified (#5658)

Force merging to unblock the unified release process

---------

Co-authored-by: Blake Rouse <blake.rouse@elastic.co>
Co-authored-by: Julien Lind <julien.lind@elastic.co>
Co-authored-by: Paolo Chilà <paolo.chila@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-8.x Automated backport to the 8.x branch with mergify skip-changelog Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants