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: fixed security-bootstrapper Docker volume init semantics #4085

Merged
merged 2 commits into from
Jul 11, 2022

Conversation

vli11
Copy link
Contributor

@vli11 vli11 commented Jul 7, 2022

fixes: #3851
Signed-off-by: Valina Li valina.li@intel.com

If your build fails due to your commit message not passing the build checks, please review the guidelines here: https://github.com/edgexfoundry/edgex-go/blob/main/.github/Contributing.md

PR Checklist

Please check if your PR fulfills the following requirements:

  • I am not introducing a breaking change (if you are, flag in conventional commit message with BREAKING CHANGE: describing the break)
  • I am not introducing a new dependency (add notes below if you are)
  • I have added unit tests for the new feature or bug fix (if not, why?) NA; only Dockerfile, entrypoint.sh changed
  • I have fully tested (add details below) this the new feature or bug fix (if not, why?)
  • I have opened a PR for the related docs change (if not, why?) NA; because it is fix for a WA

Testing Instructions

New Dependency Instructions (If applicable)

@lenny-goodell
Copy link
Member

@vli11 , please complete the PR checklist with a why comment for those items not checked. Can simply be N/A because ...

@jim-wang-intel jim-wang-intel added tech-debt issue_type denoting refactoring to improve design or removal of temporary workarounds and removed bug Something isn't working labels Jul 7, 2022

RUN apk add --update --no-cache dumb-init su-exec

ENV SECURITY_INIT_DIR /edgex-init
ARG BOOTSTRAP_REDIS_DIR=${SECURITY_INIT_DIR}/bootstrap-redis
ENV SECURITY_INIT_STAGING_DIR /edgex-init-staging
Copy link
Member

Choose a reason for hiding this comment

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

@bnevis-i , @jim-wang-intel , Isn't this a breaking change? i.e. the ENV name change now requires end user to change the name?? Also the change to /edgex-init-staging is breaking.

End users/adopters will have existing compose files working with the previous release and should just be able to change the version of images to bump to the next release.

Copy link
Contributor

Choose a reason for hiding this comment

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

good point, @lenny-intel , i guess we could still keep the original ENV SECURITY_INIT_DIR untouched. but we are adding a staging directory so that we can remove the work-around in Kubernetes' world. cc: @vli11

Copy link
Member

Choose a reason for hiding this comment

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

Yep, that is probably the better approach, i.e. support both old and new way and then in 3.0 remove old way.

Copy link
Collaborator

Choose a reason for hiding this comment

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

SECURITY_INIT_DIR was only ever used locally, so I don't think it will break anything to change it. But I have other problems with the PR that I will detail. However, I think it should it should be left as it was and add the new one.

@vli11
Copy link
Contributor Author

vli11 commented Jul 7, 2022

I have not added unit tests for this bug fix because NA; only Dockerfile, entrypoint.sh changed

@vli11
Copy link
Contributor Author

vli11 commented Jul 7, 2022

I have NOT opened a PR for the related docs change because it is fix for a WA

@lenny-goodell
Copy link
Member

@vli11 , looking for you to edit the PR description and add those comment where it says (if not, why?)

example:

  • I have added unit tests for the new feature or bug fix (if not, why?) NA; only Dockerfile, entrypoint.sh changed

@vli11
Copy link
Contributor Author

vli11 commented Jul 7, 2022

@vli11 , looking for you to edit the PR description and add those comment where it says (if not, why?)

example:

* [ ]  I have added unit tests for the new feature or bug fix (if not, why?) **NA; only Dockerfile, entrypoint.sh changed**

DONE


# Expose the file directory as a volume since there's long-running state
VOLUME ${SECURITY_INIT_DIR}
VOLUME ${SECURITY_INIT_STAGING_DIR}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove VOLUME line. No longer needed


RUN apk add --update --no-cache dumb-init su-exec

ENV SECURITY_INIT_DIR /edgex-init
ARG BOOTSTRAP_REDIS_DIR=${SECURITY_INIT_DIR}/bootstrap-redis
ENV SECURITY_INIT_STAGING_DIR /edgex-init-staging
Copy link
Collaborator

Choose a reason for hiding this comment

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

SECURITY_INIT_DIR was only ever used locally, so I don't think it will break anything to change it. But I have other problems with the PR that I will detail. However, I think it should it should be left as it was and add the new one.

Comment on lines 45 to 46
RUN mkdir -p ${SECURITY_INIT_STAGING_DIR} \
&& mkdir -p /edgex-init \
Copy link
Collaborator

Choose a reason for hiding this comment

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

mkdir -p ${BOOTSTRAP_REDIS_DIR} is the only thing needed; it will create any parent directories as needed; remove the others.

&& mkdir -p ${BOOTSTRAP_REDIS_DIR}

WORKDIR ${SECURITY_INIT_DIR}
WORKDIR ${SECURITY_INIT_STAGING_DIR}
Copy link
Collaborator

Choose a reason for hiding this comment

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

ok

Comment on lines 52 to 53
COPY --from=builder /edgex-go/cmd/security-bootstrapper/entrypoint-scripts/ ${SECURITY_INIT_STAGING_DIR}/
RUN chmod +x ${SECURITY_INIT_STAGING_DIR}/*.sh
Copy link
Collaborator

Choose a reason for hiding this comment

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

ok

@@ -59,10 +60,10 @@ COPY --from=builder /edgex-go/cmd/security-bootstrapper/res/configuration.toml .
COPY --from=builder /edgex-go/cmd/security-bootstrapper/res-bootstrap-redis/configuration.toml ${BOOTSTRAP_REDIS_DIR}/res/

# copy Consul ACL related configs
COPY --from=builder /edgex-go/cmd/security-bootstrapper/consul-acl/ ${SECURITY_INIT_DIR}/consul-bootstrapper/
COPY --from=builder /edgex-go/cmd/security-bootstrapper/consul-acl/ ${SECURITY_INIT_STAGING_DIR}/consul-bootstrapper/
Copy link
Collaborator

Choose a reason for hiding this comment

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

ok

@@ -37,6 +37,7 @@ EDGEX_USER_ID=${EDGEX_USER:-$DEFAULT_EDGEX_USER_ID}
# which then injecting into all other related containers on other services' entrypoint scripts
# if the executable is not 'security-bootstrapper'; then we consider it not running the bootstrapping process
# for the user may just want to debug into the container shell itself
cp -rpd /edgex-init-staging/* /edgex-init/
Copy link
Collaborator

Choose a reason for hiding this comment

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

This cp should use the env vars defined in the dockerfile. Copy from STAGING_DIR to INIT_DIR.

@vli11
Copy link
Contributor Author

vli11 commented Jul 7, 2022

@lenny-intel @jim-wang-intel all are updated, please review again

@jim-wang-intel
Copy link
Contributor

@vli11 i think you lost your Dockerfile changes.... please do not squash the commits before others finish your change reviews...

fixes: edgexfoundry#3851
Signed-off-by: Valina Li <valina.li@intel.com>
bnevis-i
bnevis-i previously approved these changes Jul 7, 2022
Copy link
Collaborator

@bnevis-i bnevis-i left a comment

Choose a reason for hiding this comment

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

LGTM.

Signed-off-by: Valina Li <valina.li@intel.com>
@sonarcloud
Copy link

sonarcloud bot commented Jul 7, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

Copy link
Contributor

@jim-wang-intel jim-wang-intel left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@lenny-goodell lenny-goodell left a comment

Choose a reason for hiding this comment

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

LGTM, but deferring to @bnevis-i & @jim-wang-intel for approval.

@bnevis-i
Copy link
Collaborator

bnevis-i commented Jul 8, 2022

LGTM, but deferring to @bnevis-i & @jim-wang-intel for approval.

@lenny-intel can you dismiss your review?

@jim-wang-intel
Copy link
Contributor

recheck

@jim-wang-intel
Copy link
Contributor

Hi @ernestojeda how do we do a ci/cd re-build? .. want to re-run the build to see if this is just intermittent issue

@ernestojeda
Copy link
Contributor

recheck

@ernestojeda
Copy link
Contributor

Hi @ernestojeda how do we do a ci/cd re-build? .. want to re-run the build to see if this is just intermittent issue

"recheck" is correct. However, you may not have the correct permissions, so Jenkins might have ignored.

@jim-wang-intel
Copy link
Contributor

Hi @ernestojeda how do we do a ci/cd re-build? .. want to re-run the build to see if this is just intermittent issue

"recheck" is correct. However, you may not have the correct permissions, so Jenkins might have ignored.

weird, it used to be working for me though...

@vli11 vli11 merged commit ad21f98 into edgexfoundry:main Jul 11, 2022
@vli11 vli11 deleted the 3851 branch July 11, 2022 22:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
security-services tech-debt issue_type denoting refactoring to improve design or removal of temporary workarounds
Projects
None yet
Development

Successfully merging this pull request may close these issues.

security-bootstrapper relies on undoccumented Docker volume init semantics
5 participants