Skip to content

Revision should be snapshot-in-time of application code more strictly #5821

Closed

Description

@nak3

In what area(s)?

/kind spec
/kind proposal

Current problem

Knative resolves image tag to digest, but the revision has the image digest in status field, not spec. Because of that, if the image is updated and revision is reconciled, the image digest in revision is also updated. Hence, the deployment (application code) is not always immutable against the revision. Because of that, if the image is updated and revision is restored from the backup, the image digest in revision is also updated. Hence, the deployment (application code) is not always immutable against the revision

Scenario of current problem

1. Build&Push the image

docker push gcr.io/foo/helloworld

2. Deploy KSvc with the image

(in the revision)

spec:
  containers:
  - image: gcr.io/foo/helloworld-go

status:
  imageDigest: gcr.io/foo/helloworld-go@sha256:5ea96ba4b872685ff4ddb5cd8d1a97ec18c18fae79ee8df0d29f446c5efe5f50

(in the deployment)

          image: gcr.io/foo/helloworld-go@sha256:5ea96ba4b872685ff4ddb5cd8d1a97ec18c18fae79ee8df0d29f446c5efe5f50

3. Update the application e.g (PORT env value is mandatory now)

	port, found := os.LookupEnv("PORT")
	if !found {
		panic("You did not set PORT env")
	}

4. push the image (to same tag)

docker push gcr.io/foo/helloworld

5. Let revision be reconciled

kubectl delete rev --all

6. imageDigest in revisions is updated

(in the revision)

spec:
  containers:
  - image: gcr.io/foo/helloworld-go

status:
  imageDigest: gcr.io/foo/helloworld-go@sha256:277edb551883591edf75385788449886eb0addb5246a60082802c42faaab3847

(in the deployment)

          image: gcr.io/foo/helloworld-go@sha256:277edb551883591edf75385788449886eb0addb5246a60082802c42faaab3847

Now, the revisions is spoiled due to missing env value.

Describe the feature/expectation

  • We expect the revisions use the application code when created.
  • According to the specification docs, the revision is snapshot-in-time of application code

https://github.com/knative/docs/blob/master/docs/serving/spec/knative-api-specification-1.0.md#revision

The Knative Revision represents a stateless, autoscaling snapshot-in-time of application code and configuration.

  • Note, if the revision is not reconciled, it still uses old image digest as expected. (But it is fragile.)

Proposal

The image digest should be set in Revision's spec field instead of status.

Activity

  1. added
    kind/feature
    on Oct 17, 2019
  2. knative-prow-robot commented on Oct 17, 2019

    @knative-prow-robot
    Contributor

    @nak3: The label(s) kind/proposal cannot be applied. These labels are supported: ``

    Details

    In response to this:

    In what area(s)?

    /kind spec
    /kind proposal

    Current problem

    Knative resolves image tag to digest, but the revision has the image digest in status field, not spec. Because of that, if the image is updated and revision is reconciled, the image digest in revision is also updated. Hence, the deployment (application code) is not always immutable against the revision.

    Scenario of current problem

    1. Build&Push the image

    docker push gcr.io/foo/helloworld
    

    2. Deploy KSvc with the image

    (in the revision)

    spec:
     containers:
     - image: gcr.io/foo/helloworld-go
    
    status:
     imageDigest: gcr.io/foo/helloworld-go@sha256:5ea96ba4b872685ff4ddb5cd8d1a97ec18c18fae79ee8df0d29f446c5efe5f50
    

    (in the deployment)

             image: gcr.io/foo/helloworld-go@sha256:5ea96ba4b872685ff4ddb5cd8d1a97ec18c18fae79ee8df0d29f446c5efe5f50
    

    3. Update the application e.g (PORT env value is mandatory now)

      port, found := os.LookupEnv("PORT")
      if !found {
      	panic("You did not set PORT env")
      }
    

    4. push the image (to same tag)

    docker push gcr.io/foo/helloworld
    

    5. Let revision be reconciled

    kubectl delete rev --all
    

    6. imageDigest in revisions is updated

    (in the revision)

    spec:
     containers:
     - image: gcr.io/foo/helloworld-go
    
    status:
     imageDigest: gcr.io/foo/helloworld-go@sha256:277edb551883591edf75385788449886eb0addb5246a60082802c42faaab3847
    

    (in the deployment)

             image: gcr.io/foo/helloworld-go@sha256:277edb551883591edf75385788449886eb0addb5246a60082802c42faaab3847
    

    Now, all old revisions are spoiled due to missing env value.

    Describe the feature/expectation

    • When we revert old revisions, we expect the revisions still use the application code when created.
    • According to the specification docs, the revision is snapshot-in-time of application code

    https://github.com/knative/docs/blob/master/docs/serving/spec/knative-api-specification-1.0.md#revision

    The Knative Revision represents a stateless, autoscaling snapshot-in-time of application code and configuration.

    • Note, if the revision is not reconciled, it still uses old image digest as expected. (But it is fragile.)

    Proposal

    The image digest should be set in Revision's spec field instead of status.

    Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

  3. added
    kind/spec
    on Oct 17, 2019
  4. knative-prow-robot commented on Oct 17, 2019

    @knative-prow-robot
    Contributor

    @nak3: The label(s) kind/proposal cannot be applied. These labels are supported: ``

    Details

    In response to this:

    In what area(s)?

    /kind spec
    /kind proposal

    Current problem

    Knative resolves image tag to digest, but the revision has the image digest in status field, not spec. Because of that, if the image is updated and revision is reconciled, the image digest in revision is also updated. Hence, the deployment (application code) is not always immutable against the revision.

    Scenario of current problem

    1. Build&Push the image

    docker push gcr.io/foo/helloworld
    

    2. Deploy KSvc with the image

    (in the revision)

    spec:
     containers:
     - image: gcr.io/foo/helloworld-go
    
    status:
     imageDigest: gcr.io/foo/helloworld-go@sha256:5ea96ba4b872685ff4ddb5cd8d1a97ec18c18fae79ee8df0d29f446c5efe5f50
    

    (in the deployment)

             image: gcr.io/foo/helloworld-go@sha256:5ea96ba4b872685ff4ddb5cd8d1a97ec18c18fae79ee8df0d29f446c5efe5f50
    

    3. Update the application e.g (PORT env value is mandatory now)

      port, found := os.LookupEnv("PORT")
      if !found {
      	panic("You did not set PORT env")
      }
    

    4. push the image (to same tag)

    docker push gcr.io/foo/helloworld
    

    5. Let revision be reconciled

    kubectl delete rev --all
    

    6. imageDigest in revisions is updated

    (in the revision)

    spec:
     containers:
     - image: gcr.io/foo/helloworld-go
    
    status:
     imageDigest: gcr.io/foo/helloworld-go@sha256:277edb551883591edf75385788449886eb0addb5246a60082802c42faaab3847
    

    (in the deployment)

             image: gcr.io/foo/helloworld-go@sha256:277edb551883591edf75385788449886eb0addb5246a60082802c42faaab3847
    

    Now, the revisions is spoiled due to missing env value.

    Describe the feature/expectation

    • We expect the revisions use the application code when created.
    • According to the specification docs, the revision is snapshot-in-time of application code

    https://github.com/knative/docs/blob/master/docs/serving/spec/knative-api-specification-1.0.md#revision

    The Knative Revision represents a stateless, autoscaling snapshot-in-time of application code and configuration.

    • Note, if the revision is not reconciled, it still uses old image digest as expected. (But it is fragile.)

    Proposal

    The image digest should be set in Revision's spec field instead of status.

    Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

  5. savitaashture commented on Oct 18, 2019

    @savitaashture
    Contributor

    /assign

  6. vagababov commented on Oct 18, 2019

    @vagababov
    Contributor

    @savitaashture I think this might require a pass/talk at the WG meeting first.
    /cc @dgerd

  7. added this to the Needs Triage milestone on Oct 23, 2019
  8. savitaashture commented on Nov 11, 2019

    @savitaashture
    Contributor

    @dgerd can we discuss about this in the coming WG meeting?

  9. markusthoemmes commented on Nov 11, 2019

    @markusthoemmes
    Contributor

    I'm not quite parsing the issue here. You're removing the revision and thus all information about the digest we picked at that point in time. Our code will generate a new revision. You're proposing that creating that new revision should have the same contents as the revision you just deleted?

    As you mentioned, revisions are an immutable snapshot. If you're removing that snapshot though, I don't see how we'd easily regenerate the state you lost by deleting it in the first place. Can you elaborate on that?

  10. nak3 commented on Nov 11, 2019

    @nak3
    ContributorAuthor

    Yes, you are correct. My steps-5 above

    1. Let revision be reconciled

    It actually re-generated the revision. So, my report was asking like creating that new revision should have the same contents as the revision you just deleted which is not possible for immutable revision.

    With said, I still wanted to know if the image digest in status field is appropriate or not as I originally proposed:

    The image digest should be set in Revision's spec field instead of status.

    For example, if we wanted to take the backup of Knative Service, we need the backup including Revision's status field. Is that something users need to care? (I think that some users stripped out with the status information when taking the backup.)

  11. markusthoemmes commented on Nov 11, 2019

    @markusthoemmes
    Contributor

    @nak3 yeah I suppose we could stick the digest into the container of the spec directly. Not sure why we're not doing this currently 🤔

  12. knative-housekeeping-robot commented on Feb 9, 2020

    @knative-housekeeping-robot

    Issues go stale after 90 days of inactivity.
    Mark the issue as fresh by adding the comment /remove-lifecycle stale.
    Stale issues rot after an additional 30 days of inactivity and eventually close.
    If this issue is safe to close now please do so by adding the comment /close.

    Send feedback to Knative Productivity Slack channel or file an issue in knative/test-infra.

    /lifecycle stale

  13. added
    lifecycle/stale
    on Feb 9, 2020
  14. knative-housekeeping-robot commented on Mar 11, 2020

    @knative-housekeeping-robot

    Stale issues rot after 30 days of inactivity.
    Mark the issue as fresh by adding the comment /remove-lifecycle rotten.
    Rotten issues close after an additional 30 days of inactivity.
    If this issue is safe to close now please do so by adding the comment /close.

    Send feedback to Knative Productivity Slack channel or file an issue in knative/test-infra.

    /lifecycle rotten

  15. added
    lifecycle/rotten
    and removed
    lifecycle/stale
    on Mar 11, 2020
  16. knative-housekeeping-robot commented on Apr 10, 2020

    @knative-housekeeping-robot

    Rotten issues close after 30 days of inactivity.
    Reopen the issue with /reopen.
    Mark the issue as fresh by adding the comment /remove-lifecycle rotten.

    Send feedback to Knative Productivity Slack channel or file an issue in knative/test-infra.

    /close

  17. knative-prow-robot commented on Apr 10, 2020

    @knative-prow-robot
    Contributor

    @knative-housekeeping-robot: Closing this issue.

    Details

    In response to this:

    Rotten issues close after 30 days of inactivity.
    Reopen the issue with /reopen.
    Mark the issue as fresh by adding the comment /remove-lifecycle rotten.

    Send feedback to Knative Productivity Slack channel or file an issue in knative/test-infra.

    /close

    Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

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

Metadata

Metadata

Assignees

Labels

kind/featurekind/speclifecycle/rotten

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions