Skip to content

Conversation

@shmsr
Copy link
Member

@shmsr shmsr commented Oct 15, 2023

Migrate a batch of packages from v1/v2 to v3 package-spec. Used the following scripts and some manual changes to generate the changes in this PR:

yq_hack.zsh

#!/bin/bash set -e set -u set -o pipefail set -x pushd $1 find data_stream -type f -path "*fields*" -name "*.yml" -exec yq e -i "del .[].release" {} \; find data_stream -type f -path "*fields*" -name "ecs.yml" -exec yq e -i "unique_by(.name)" {} \; find data_stream -type f -path "*fields*" -name "*.yml" -exec yq e -i "del .[].fields.[].required" {} \; yq e -i 'del .release' manifest.yml yq e -i "with(select(.license != null); .conditions.elastic.subscription = .license) | del .license" manifest.yml popd git add -u $1/ git commit -m "[$1]: migration with yq" 

ecs-update.zsh

#!/bin/bash set -u set -o pipefail set -x echo "-- executing ecs-update for $1 --" ecs-update -format-version=3.0.0 -fix-dotted-yaml-keys -add-owner-type -owner elastic/obs-infraobs-integrations -v -skip-format=true $1 if (( $? )) then echo "-- write validation for $1 --" pushd $1 go run ../scripting/write_validation.go popd # Try again? git checkout . ecs-update -format-version=3.0.0 -fix-dotted-yaml-keys -add-owner-type -owner elastic/obs-infraobs-integrations -v -skip-format=true $1 fi 

And another Go program to write the validation.yml by parsing the elastic-package lint errors.

Then I hooked this scripts to run with:

$ pkgs=($(cat .github/CODEOWNERS | grep '@elastic/obs-infraobs-integrations' | cut -d ' ' -f 1 | cut -d '/' -f 3 | sort | uniq)) $ for ((idx=16; idx<=30; idx++)) do scripting/yq_hack.zsh $pkgs[idx] done
$ for ((idx=16; idx<=30; idx++)) do scripting/ecs_update.zsh $pkgs[idx] || break done

Another variation of the above script:

$ for ((idx=31; idx<=48; idx++)) do case $pkgs[idx] in "tomcat" | "salesforce" | "redis") echo "-- skip $pkgs[idx] --";; "websphere_application_server" | "system" | "statsd_input" | "sql_input" | "springboot" | "rabbitmq" | "postgresql" | "prometheus_input" | "oracle_weblogic" | "php_fpm" | "oracle") echo "-- done $pkgs[idx] --";; *) scripting/ecs_update.zsh $pkgs[idx] || break;; esac done

As I am creating a batch of 18 packages here, I am using a for loop. In case the migration is not possible for some packages, I put it in the first case to skip them.

Proposed commit message

Migrate packages owned by obs-infraobs-integrations but few couldn't be migrated. Marking them as follows:

  • oracle
  • oracle_weblogic
  • php_fpm
  • postgresql
  • prometheus_input
  • rabbitmq
  • redis
  • redisenterprise
  • salesforce
  • spring_boot
  • sql_input
  • statsd_input
  • system
  • tomcat
  • traefik
  • vsphere
  • websphere_application_server
  • zookeeper

Please see the comment #8203 (comment) in this PR itself to understand why some packages couldn't be migrated and also learn about the challenges faced when migrating.

Checklist

  • I have reviewed tips for building integrations and this pull request is aligned with them.
  • I have verified that all data streams collect metrics or logs.
  • I have added an entry to my package's changelog.yml file.
  • I have verified that Kibana version constraints are current according to guidelines.

Author's Checklist

  • [ ]

How to test this PR locally

Related issues

Relates to #8170
Relates to #8171

Screenshots

shmsr added 30 commits October 16, 2023 00:06
The format_version in the package manifest changed from 1.0.0 to 3.0.0. Removed dotted YAML keys from package manifest. Added 'owner.type: elastic' to package manifest. [git-generate] go run github.com/andrewkroh/go-examples/ecs-update@latest -v -format-version=3.0.0 -skip-format -fix-dotted-yaml-keys -add-owner-type packages/oracle
The format_version in the package manifest changed from 1.0.0 to 3.0.0. Removed dotted YAML keys from package manifest. Added 'owner.type: elastic' to package manifest. [git-generate] go run github.com/andrewkroh/go-examples/ecs-update@latest -v -format-version=3.0.0 -fix-dotted-yaml-keys -add-owner-type packages/oracle_weblogic
The format_version in the package manifest changed from 2.0.0 to 3.0.0. Removed dotted YAML keys from package manifest. Added 'owner.type: elastic' to package manifest. [git-generate] go run github.com/andrewkroh/go-examples/ecs-update@latest -v -format-version=3.0.0 -fix-dotted-yaml-keys -add-owner-type packages/php_fpm
The format_version in the package manifest changed from 1.0.0 to 3.0.0. Removed dotted YAML keys from package manifest. Added 'owner.type: elastic' to package manifest. [git-generate] go run github.com/andrewkroh/go-examples/ecs-update@latest -v -format-version=3.0.0 -fix-dotted-yaml-keys -add-owner-type packages/postgresql
The format_version in the package manifest changed from 2.0.0 to 3.0.0. Removed dotted YAML keys from package manifest. Added 'owner.type: elastic' to package manifest. [git-generate] go run github.com/andrewkroh/go-examples/ecs-update@latest -v -format-version=3.0.0 -fix-dotted-yaml-keys -add-owner-type packages/prometheus_input
The format_version in the package manifest changed from 1.0.0 to 3.0.0. Removed dotted YAML keys from package manifest. Added 'owner.type: elastic' to package manifest. [git-generate] go run github.com/andrewkroh/go-examples/ecs-update@latest -v -format-version=3.0.0 -fix-dotted-yaml-keys -add-owner-type packages/rabbitmq
The format_version in the package manifest changed from 1.0.0 to 3.0.0. Removed dotted YAML keys from package manifest. Added 'owner.type: elastic' to package manifest. [git-generate] go run github.com/andrewkroh/go-examples/ecs-update@latest -v -format-version=3.0.0 -fix-dotted-yaml-keys -add-owner-type packages/redisenterprise
The format_version in the package manifest changed from 1.0.0 to 3.0.0. Removed dotted YAML keys from package manifest. Added 'owner.type: elastic' to package manifest. [git-generate] go run github.com/andrewkroh/go-examples/ecs-update@latest -v -format-version=3.0.0 -fix-dotted-yaml-keys -add-owner-type packages/spring_boot
The format_version in the package manifest changed from 2.0.0 to 3.0.0. Removed dotted YAML keys from package manifest. Added 'owner.type: elastic' to package manifest. [git-generate] go run github.com/andrewkroh/go-examples/ecs-update@latest -v -format-version=3.0.0 -fix-dotted-yaml-keys -add-owner-type packages/sql_input
The format_version in the package manifest changed from 2.0.0 to 3.0.0. Removed dotted YAML keys from package manifest. Added 'owner.type: elastic' to package manifest. [git-generate] go run github.com/andrewkroh/go-examples/ecs-update@latest -v -format-version=3.0.0 -fix-dotted-yaml-keys -add-owner-type packages/statsd_input
The format_version in the package manifest changed from 1.0.0 to 3.0.0. Added 'owner.type: elastic' to package manifest. [git-generate] go run github.com/andrewkroh/go-examples/ecs-update@latest -v -format-version=3.0.0 -fix-dotted-yaml-keys -add-owner-type packages/system
The format_version in the package manifest changed from 1.0.0 to 3.0.0. Removed dotted YAML keys from package manifest. Added 'owner.type: elastic' to package manifest. [git-generate] go run github.com/andrewkroh/go-examples/ecs-update@latest -v -format-version=3.0.0 -fix-dotted-yaml-keys -add-owner-type packages/traefik
The format_version in the package manifest changed from 1.0.0 to 3.0.0. Removed dotted YAML keys from package manifest. Added 'owner.type: elastic' to package manifest. [git-generate] go run github.com/andrewkroh/go-examples/ecs-update@latest -v -format-version=3.0.0 -fix-dotted-yaml-keys -add-owner-type packages/vsphere
The format_version in the package manifest changed from 1.0.0 to 3.0.0. Removed dotted YAML keys from package manifest. Added 'owner.type: elastic' to package manifest. [git-generate] go run github.com/andrewkroh/go-examples/ecs-update@latest -v -format-version=3.0.0 -fix-dotted-yaml-keys -add-owner-type packages/websphere_application_server
The format_version in the package manifest changed from 1.0.0 to 3.0.0. Removed dotted YAML keys from package manifest. Added 'owner.type: elastic' to package manifest. [git-generate] go run github.com/andrewkroh/go-examples/ecs-update@latest -v -format-version=3.0.0 -fix-dotted-yaml-keys -add-owner-type packages/zookeeper
@shmsr
Copy link
Member Author

shmsr commented Oct 25, 2023

Pulling out statsd_input and sql_input because of the mapping-related ambiguities. Need to discuss the mappings in more detail and then commit the changes for both packages.

@tommyers-elastic tommyers-elastic merged commit da0fc7a into elastic:main Oct 25, 2023
@shmsr shmsr deleted the migrate-infraobs-ps-v3-batch-3-serverless branch October 25, 2023 10:08
@elasticmachine
Copy link

Package oracle - 1.22.0 containing this change is available at https://epr.elastic.co/search?package=oracle

@elasticmachine
Copy link

Package oracle_weblogic - 1.3.0 containing this change is available at https://epr.elastic.co/search?package=oracle_weblogic

@elasticmachine
Copy link

Package php_fpm - 1.1.0 containing this change is available at https://epr.elastic.co/search?package=php_fpm

@elasticmachine
Copy link

Package postgresql - 1.17.0 containing this change is available at https://epr.elastic.co/search?package=postgresql

@elasticmachine
Copy link

Package prometheus_input - 0.2.0 containing this change is available at https://epr.elastic.co/search?package=prometheus_input

@elasticmachine
Copy link

Package rabbitmq - 1.11.0 containing this change is available at https://epr.elastic.co/search?package=rabbitmq

@elasticmachine
Copy link

Package redisenterprise - 0.6.0 containing this change is available at https://epr.elastic.co/search?package=redisenterprise

@elasticmachine
Copy link

Package spring_boot - 0.13.0 containing this change is available at https://epr.elastic.co/search?package=spring_boot

@elasticmachine
Copy link

Package traefik - 1.11.0 containing this change is available at https://epr.elastic.co/search?package=traefik

@elasticmachine
Copy link

Package vsphere - 1.9.0 containing this change is available at https://epr.elastic.co/search?package=vsphere

@elasticmachine
Copy link

Package websphere_application_server - 1.1.0 containing this change is available at https://epr.elastic.co/search?package=websphere_application_server

@elasticmachine
Copy link

Package zookeeper - 1.10.0 containing this change is available at https://epr.elastic.co/search?package=zookeeper

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment