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

Ensure that primary workloads should be restarted when its config was updated #2054

Merged
merged 1 commit into from
Jun 9, 2021

Conversation

nghialv
Copy link
Member

@nghialv nghialv commented Jun 9, 2021

What this PR does / why we need it:

This PR ensures that all workload resources (Deployment) will have an additional annotation pipecd.dev/config-hash with the value is the hash of its referencing congimaps/secrets.

template:
    metadata:
      annotations:
        pipecd.dev/config-hash: 6hc7646589

This adding makes all workloads to be restarted automatically when one of its configs was changed.

About the drift detector, it is ignoring all added labels/annotations so no diff will be introduced by this adding.

Which issue(s) this PR fixes:

Fixes #

Does this PR introduce a user-facing change?:

Ensure that primary workloads should be restarted when its config was updated

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 32.33%. This pull request increases coverage by 0.11%.

File Function Base Head Diff
pkg/app/piped/cloudprovider/kubernetes/deployment.go FindReferencingConfigMapsInDeployment -- 0.00% +0.00%
pkg/app/piped/cloudprovider/kubernetes/deployment.go FindReferencingSecretsInDeployment -- 0.00% +0.00%
pkg/app/piped/cloudprovider/kubernetes/hasher.go HashManifests -- 84.00% +84.00%
pkg/app/piped/cloudprovider/kubernetes/hasher.go encodeHash -- 90.91% +90.91%
pkg/app/piped/cloudprovider/kubernetes/hasher.go encodeConfigMap -- 66.67% +66.67%
pkg/app/piped/cloudprovider/kubernetes/hasher.go encodeSecret -- 71.43% +71.43%
pkg/app/piped/executor/kubernetes/kubernetes.go annotateConfigHash -- 52.94% +52.94%
pkg/app/piped/executor/kubernetes/kubernetes.go annotateConfigHashToDeployment -- 0.00% +0.00%
pkg/app/piped/cloudprovider/kubernetes/manifest.go ParseManifests 81.82% 90.91% +9.09%
pkg/app/piped/cloudprovider/kubernetes/resourcekey.go ResourceKey.IsSecret 40.00% 80.00% +40.00%
pkg/app/piped/executor/kubernetes/primary.go deployExecutor.ensurePrimaryRollout 56.52% 55.56% -0.97%
pkg/app/piped/executor/kubernetes/rollback.go rollbackExecutor.ensureRollback 0.00% 0.00% +0.00%
pkg/app/piped/executor/kubernetes/sync.go deployExecutor.ensureSync 47.22% 46.15% -1.07%

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 32.68%. This pull request increases coverage by 0.45%.

File Function Base Head Diff
pkg/app/piped/cloudprovider/kubernetes/deployment.go FindReferencingConfigMapsInDeployment -- 90.91% +90.91%
pkg/app/piped/cloudprovider/kubernetes/deployment.go FindReferencingSecretsInDeployment -- 90.91% +90.91%
pkg/app/piped/cloudprovider/kubernetes/hasher.go HashManifests -- 84.00% +84.00%
pkg/app/piped/cloudprovider/kubernetes/hasher.go encodeHash -- 90.91% +90.91%
pkg/app/piped/cloudprovider/kubernetes/hasher.go encodeConfigMap -- 66.67% +66.67%
pkg/app/piped/cloudprovider/kubernetes/hasher.go encodeSecret -- 71.43% +71.43%
pkg/app/piped/executor/kubernetes/kubernetes.go annotateConfigHash -- 52.94% +52.94%
pkg/app/piped/executor/kubernetes/kubernetes.go annotateConfigHashToDeployment -- 0.00% +0.00%
pkg/app/piped/cloudprovider/kubernetes/manifest.go ParseManifests 81.82% 90.91% +9.09%
pkg/app/piped/cloudprovider/kubernetes/resourcekey.go ResourceKey.IsSecret 40.00% 80.00% +40.00%
pkg/app/piped/executor/kubernetes/primary.go deployExecutor.ensurePrimaryRollout 56.52% 55.56% -0.97%
pkg/app/piped/executor/kubernetes/rollback.go rollbackExecutor.ensureRollback 0.00% 0.00% +0.00%
pkg/app/piped/executor/kubernetes/sync.go deployExecutor.ensureSync 47.22% 46.15% -1.07%

@pipecd-bot
Copy link
Collaborator

TODO

The following ISSUES will be created once got merged. If you want me to skip creating the issue, you can use /todo skip command.

Details

1. Change the way to detect whether an APIVersion is built-in or not

https://github.com/pipe-cd/pipe/blob/49e67d3d36dce8abfa249fa913afc51e332365f7/pkg/app/piped/cloudprovider/kubernetes/resourcekey.go#L273-L276

This was created by todo plugin since "TODO:" was found in 49e67d3 when #2054 was merged. cc: @nghialv.

2. Anotate config hash into other workload kinds such as DaemonSet, StatefulSet...

https://github.com/pipe-cd/pipe/blob/49e67d3d36dce8abfa249fa913afc51e332365f7/pkg/app/piped/executor/kubernetes/kubernetes.go#L505-L508

This was created by todo plugin since "TODO:" was found in 49e67d3 when #2054 was merged. cc: @nghialv.

@pipecd-bot pipecd-bot removed the size/XL label Jun 9, 2021
@nghialv nghialv changed the title [WIP] Ensure that primary workloads should be restarted when its config was updated Ensure that primary workloads should be restarted when its config was updated Jun 9, 2021
@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 32.96%. This pull request increases coverage by 0.73%.

File Function Base Head Diff
pkg/app/piped/cloudprovider/kubernetes/deployment.go FindReferencingConfigMapsInDeployment -- 90.91% +90.91%
pkg/app/piped/cloudprovider/kubernetes/deployment.go FindReferencingSecretsInDeployment -- 90.91% +90.91%
pkg/app/piped/cloudprovider/kubernetes/hasher.go HashManifests -- 84.00% +84.00%
pkg/app/piped/cloudprovider/kubernetes/hasher.go encodeHash -- 90.91% +90.91%
pkg/app/piped/cloudprovider/kubernetes/hasher.go encodeConfigMap -- 66.67% +66.67%
pkg/app/piped/cloudprovider/kubernetes/hasher.go encodeSecret -- 71.43% +71.43%
pkg/app/piped/executor/kubernetes/kubernetes.go annotateConfigHash -- 94.12% +94.12%
pkg/app/piped/executor/kubernetes/kubernetes.go annotateConfigHashToDeployment -- 76.92% +76.92%
pkg/app/piped/cloudprovider/kubernetes/resourcekey.go ResourceKey.IsDeployment 0.00% 80.00% +80.00%
pkg/app/piped/cloudprovider/kubernetes/resourcekey.go ResourceKey.IsSecret 40.00% 80.00% +40.00%
pkg/app/piped/executor/kubernetes/primary.go deployExecutor.ensurePrimaryRollout 56.52% 55.56% -0.97%
pkg/app/piped/executor/kubernetes/rollback.go rollbackExecutor.ensureRollback 0.00% 0.00% +0.00%
pkg/app/piped/executor/kubernetes/sync.go deployExecutor.ensureSync 47.22% 46.15% -1.07%
pkg/app/piped/cloudprovider/kubernetes/manifest.go ParseManifests 81.82% 90.91% +9.09%

@khanhtc1202
Copy link
Member

Way to go 🚀
/approve

@pipecd-bot
Copy link
Collaborator

APPROVE

This pull request is APPROVED by khanhtc1202.

Approvers can cancel the approval by writing /approve cancel in a comment. Any additional commits also will change this pull request to be not-approved.

@nghialv
Copy link
Member Author

nghialv commented Jun 9, 2021

/changelog

@pipecd-bot
Copy link
Collaborator

CHANGELOG

@nghialv: Changelog has been generated in response to this comment.

Details

Changelog since v0.9.15

Notable Changes

  • Ensure that primary workloads should be restarted when its config was updated (#2054)
  • Add the ability to display deployment without environment (#2045)
  • Fix showing deleted environments on deployments/applications' filter list (#2044)
  • Fix success alerts appear when deleting an environment returns failed. (#2041)
  • Make it possible to delete environment from web client (#2031)
  • The operator now can see the number of application of projects (#2015)
  • Show Application Counts by default (#2001)
  • Fix broken layout at some pages on small screens (#1977)

Internal Changes

  • ECS progressive deployment preparation (#2050)
  • New stages sample for ECS progressive RFC (#2052)
  • Create a multi-valued composite index for ProjectId and EnvIds (#2051)
  • Disable EnvIds column (#2049)
  • Unify component story writing style (#2048)
  • Support contains operator for MySQL (#2042)
  • Add notes on how to apply changes on the dev cluster (#2046)
  • Don't use Deleted as a filtering field (#2043)
  • Do not show deleted/disabled environments/pipeds (#2040)
  • Fix drift detector to treat zero and unspecified values as equal (#2037)
  • Using array-contains instead of array-contains-any (#2034)
  • Ensure to delete environment gracefully (#2029)
  • Add delete environment rpc to auth list (#2032)
  • Fix previous taskset remained on rollback failed ECS deployment (#2030)
  • Add dedicated operator type for datastore (#2028)
  • Fix applications fetching at the Application List page (#2019)
  • Ensure to reload alerting_rules file when changed (#2023)
  • Update eslint-plugin-react-hooks version (#2025)
  • Bump Bazel from 4.0.0 to 4.1.0 (#2024)
  • Add TaskSetDefinition as required configuration for ECS deployment (#2021)
  • Add web API to delete/disable environment (#2016)
  • Ignore prom-rules from rendering targets (#2018)
  • RFC for PipeCD ECS Application (#1998)
  • Update typescript to v4.3 (#2014)
  • Add Alertmanager configuration (#1994)
  • Reimplement ECS Sync with EXTERNAL deployment controller (#2007)
  • Remove unused fields in WebAPI struct (#2008)
  • Add web tests for the Application Counts (#2006)
  • Enable insight collector for application count by default (#2004)
  • Use tag to specify default value of config (#2003)
  • Update yup version (#1999)
  • Add hands-on tutorial guide in Japanese (#1991)
  • Refine ecs cloud provider (#1996)
  • Fix piped deployment to use the created service account only if it was created (#1993)
  • Update web API to return the real data of application counts (#1990)
  • Fix cron expression because the newer library does not allow specifying the second field (#1989)
  • Update release note v0.9.14 (#1988)
  • Add more log entries to insight collector (#1987)
  • Fix typo in the doc (#1986)
  • Refactor type of redux hooks (#1981)
  • Fix type error for web mock utils (#1978)
  • ECS Sync strategy refinement (#1982)
  • Add mention for actions-event-register within the doc (#1985)
  • Run cron job for insight collector only if it was enabled (#1984)
  • Refactor and redesign insight collector (#1980)
  • Add ECS deployment config template (#1979)
  • Unify the value placeholders in the docs (#1976)
  • Allow kubeconfig to be added to the secret (#1965)

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

Successfully merging this pull request may close these issues.

3 participants