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

Implement announcements as data-driven content #25769

Merged

Conversation

sftim
Copy link
Contributor

@sftim sftim commented Dec 22, 2020

Rather than configuring announcements in the config.toml, add a mechanism to handle these as data driven content.
This change allows announcements to have an expiry date and / or a “do not show until” date. You can also have multiple announcements, for example to have a Kubecon announcement that takes priority but only until the end of the conference.

Part of the implementation for issue #25759. Preview (but it doesn't show any current announcement).

/kind feature
/area web-development

/hold
because to make the expiry date mechanism work, we should also set up triggered builds. That'll be a separate pull request.

@k8s-ci-robot k8s-ci-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/feature Categorizes issue or PR as related to a new feature. area/web-development Issues or PRs related to the kubernetes.io's infrastructure, design, or build processes cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Dec 22, 2020
@k8s-ci-robot k8s-ci-robot added the sig/docs Categorizes an issue or PR as relevant to SIG Docs. label Dec 22, 2020
@netlify
Copy link

netlify bot commented Dec 22, 2020

✔️ Deploy preview for kubernetes-io-master-staging ready!

🔨 Explore the source changes: 0b6280f

🔍 Inspect the deploy logs: https://app.netlify.com/sites/kubernetes-io-master-staging/deploys/5ff712162a9b520007bf08da

😎 Browse the preview: https://deploy-preview-25769--kubernetes-io-master-staging.netlify.app

@sftim
Copy link
Contributor Author

sftim commented Dec 22, 2020

@kbhawkey & @onlydole - if either of you have time to review this, I'd welcome your thoughts.

@sftim
Copy link
Contributor Author

sftim commented Dec 22, 2020

BTW we can't add an OWNERS file inside /data/announcements because Hugo wants to parse all those files as, er, data.

@sftim sftim force-pushed the 20201222_data_driven_announcements branch from 9f54245 to 9e14354 Compare December 22, 2020 22:49
Copy link
Member

@onlydole onlydole left a comment

Choose a reason for hiding this comment

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

A big +1 for time bound announcements! This is a great implementation and improvement, @sftim! Thank you for working on this 🌟

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: onlydole

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 22, 2020
{{ if .Page.Param "announcement" }}
<section lang="en" id="fp-announcement" style="background-color:{{ .Page.Param "announcement_bg" }}">
<aside >
{{ $announcementShown := false }}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I considered refactoring this to be a single layout or partial that sets a different ID for the front page, or even making the HTML the same for both cases and using CSS to adjust styling. I decided that'd be best saved for a different PR; this one already has an potential impact on every page on the site(!) so let's keep it narrow.

@sftim
Copy link
Contributor Author

sftim commented Dec 22, 2020

(forced a Netlify retry after a Hugo concurrency error)

@sftim
Copy link
Contributor Author

sftim commented Dec 22, 2020

The other part of this change is PR #25771: set up GitHub Actions to trigger a deploy for this website, twice per day.

@kbhawkey
Copy link
Contributor

👀

{{ $announcementShown := false }}

{{ $announcements := $.Site.Data.announcements }}
{{ range sort $announcements "spec.priority" "desc" }}
Copy link
Contributor

@kbhawkey kbhawkey Dec 23, 2020

Choose a reason for hiding this comment

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

@sftim, Some initial feedback/questions about the data and how to use this content:

  • You envision a number of unique, reusable announcement files stored as data. Each file must be parsed in these partial templates in order to find the single announcement to publish? Any contributor can create a data file and have their announcement published based on the dates set in the file?
  • Do you need to set a priority? Seems complicated and possibly error prone. Could you use a boolean (publish = true)? How many announcements can you publish at one time?
  • It might be nice to have a base data file for all announcements and then have other announcements
    override fields as needed.
  • I see an overlap of code in the two partial templates. Could you write another template that is used by both templates?
  • If these are defaults, style="background-color: #3371e3; color: #fff;, could add to a base (announcement) data file?
  • How will the announcement be removed? Could the announcement have start and expiration dates? Is that described in the fields: notAfter and notBefore? When an announcement expires, the "default" or base announcement (could be nothing) is displayed.
  • Can the announcement message be localized?
  • Will a periodic job read data files (or some other job configuration files) to determine what/when to publish (blog page)?

Copy link
Contributor Author

@sftim sftim Dec 23, 2020

Choose a reason for hiding this comment

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

You envision a number of unique, reusable announcement files stored as data. Each file must be parsed in these partial templates in order to find the single announcement to publish? Any contributor can create a data file and have their announcement published based on the dates set in the file?

I could add a note to the website contributor guide about how to set and review announcements. Maybe that'd work.
Only the steering committee can approve these announcements (see issue #25759 for details). This PR doesn't implement any enforcement mechanism for details messages.

Do you need to set a priority? Seems complicated and possibly error prone.

We have had announcements override other announcements (eg: KubeCon, overriding the current banner on the topic of Black Lives Matter). To me it seems like the override case is easier than the alternative: splitting the outer announcement into two and having three defined announcements that just avoid overlapping.

It might be nice to have a base data file for all announcements and then have other announcements
override fields as needed.

There's one required field, .spec.message. I don't think there's a sensible default to set for that.
As with the current implementation, the default is not to show an announcement.

I see an overlap of code in the two partial templates. Could you write another template that is used by both templates?

I explained my thinking in #25769 (comment)

If these are defaults, style="background-color: #3371e3; color: #fff;, could add to a base (announcement) data file?

That sounds like more complexity for a really niche case. I envisage an implementation of that covering an override mechanism for every other field to ensure a override mechanism for one. I don't think it's justified, especially as CSS is the easiest field to define overrides for (it's kind of built-in).

How will the announcement be removed?

Removal is optional; it'll improve site build time but I suspect not by much.

Could the announcement have start and expiration dates? Is that described in the fields: notAfter and notBefore?

Yes. Those fields are optional.

When an announcement expires, the "default" or base announcement (could be nothing) is displayed.

As with the current implementation, the default is not to show an announcement.

Can the announcement message be localized?

I haven't implemented this. Instead, as with the current implementation, we mark the HTML elements for the announcement as English (overriding any page-level setting, and helping any web crawlers that care).

Will a periodic job read data files (or some other job configuration files) to determine what/when to publish (blog page)?

For blog articles, Hugo has built-in support for not publishing articles before their publication date. PR #25771 implements an automatic build trigger.
Those two mechanisms combined would make blog articles go live when ready (we use a similar mechanism for https://www.scalefactory.com/blog/).
This PR together with #25771 would make announcements go live or disappear as needed. See that PR for details about the approach.

Copy link
Member

Choose a reason for hiding this comment

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

reverse-sorting by start date seems like it would be a simpler than a separate priority field, and I think it would do what you want in the case of a long-lived announcement being temporarily overridden by a short-lived announcement

Can the announcement message be localized?

I also had this question, though the current localization had very limited utilization (only korean localized it, looks like), and the short-lived nature of announcements seem unlikely to mesh well with slower translation cycles.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

reverse-sorting by start date

There could be some gotchas around sorting on start date; Hugo date parsing and handling is there, but it is a bit raw. New Hugo releases are adding useful time and date features so the topic is definitely getting attention.

To be honest I already implemented priority and I known that'll work. The start date thing seems like it could be a surprise to people who want to work out which announcement will show when a current one elapses, whereas a priority value is easy to teach.

Copy link
Member

Choose a reason for hiding this comment

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

ok, I don't feel strongly. I don't really expect there to be more than 1-2 at any given time

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess the site will not substitute an "empty" section when there are no announcements?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kbhawkey examples of the priority field:

---
priority: 10
dateConstraints:
  startTime: 2020-01-01T00:00:00
  endTime: 2022-07-01T00:00:00
message: |-
  Kubernetes all through 2020 _and_ the first half of 2021.  

and

---
priority: 20
dateConstraints:
  startTime: 2021-03-20T09:00:00
  endTime: 2021-04-02T00:00:00
style: >-
  color: #fff; background: #505;
title: KubeCon Offworld 2021
message: |-
  Kubecon Offworld 2021 will be held on the planet Marklar from the first of April
  to the first of April.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The Kubecon banner would override the “Kubernetes all through 2020 and the first half of 2021.” banner for the configured duration.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess the site will not substitute an "empty" section when there are no announcements?

If there is no active announcement then there's no section#announcement emitted; that's the same as what the current mechanism does.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I understand that you want to sort by priority instead of looking for a "publish" field.

@sftim
Copy link
Contributor Author

sftim commented Dec 23, 2020

BTW, merging this PR as it stands removes the existing banner. I can / will add another commit that retains it, when that's useful to do.

Comment on lines 10 to 12
apiVersion: docs.k8s.io/v1alpha1
kind: Announcement
spec:
Copy link
Member

Choose a reason for hiding this comment

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

does this do anything currently? if not, suggest removing it... it'll just get copy/pasted and not add much value

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The example.yaml? It's an example.

If you mean .spec then you can't omit it with the current code. IMO it makes the Hugo layout code a bit nicer because I can {{ with .spec }} to bring just those fields into scope.

If you mean the apiVersion and kind then the current code enforces that you are using this particular format, but we can remove that validation if it's not useful.

Copy link
Member

@liggitt liggitt Dec 23, 2020

Choose a reason for hiding this comment

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

the apiVersion/kind/spec bits... I didn't see any enforcement there, so it didn't seem like it was accomplishing anything

a flat structure seemed easier to read, but maybe that's just me:

# priority is required
# Largest number wins tie break if there are multiple announcements
priority: 0
# start/stop are required, and must be in format YYYY-MM-DDTHH:MM:SS
startDateTime: "2020-01-01T00:00:00"
stopDateTime: "2020-04-01T00:00:00"
# message is required
message: |-
  Marklar marklar marklar marklar marklar.
  Marklar marklar.
  [Marklar](https://en.wikipedia.org/wiki/Starvin%27_Marvin_in_Space#Plot)!
# title is optional
title: Sample announcement
# style is optional; if using, set both color and background
style: "color: #fff; background: #000;"

Copy link
Contributor

Choose a reason for hiding this comment

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

does this do anything currently? if not, suggest removing it... it'll just get copy/pasted and not add much value

+1 for removing any unused fields

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, I can try to simplify it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, I did have validation in before but must have left that out.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's too bad that the title and message are not localized. I assume you can use a template in the data file.
I have not thought this through ...

[announcement]
[announcement.<name>]
title = "Kubernetes Europe"
message = "Come to Kubecon"

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Dec 23, 2020
@liggitt
Copy link
Member

liggitt commented Dec 23, 2020

this still is looking at the old config value:

{{- if .Site.Params.announcement }}
<link rel="stylesheet" href="{{ "css/announcement.css" | relURL }}">
{{- end }}

@sftim
Copy link
Contributor Author

sftim commented Dec 23, 2020

{{- if .Site.Params.announcement }}
<link rel="stylesheet" href="{{ "css/announcement.css" | relURL }}">
{{- end }}

Ah, good spot.

@sftim sftim force-pushed the 20201222_data_driven_announcements branch from 538dbe0 to 728e590 Compare December 23, 2020 19:11
# 🛈 Changes require approval from @kubernetes/steering-committee

# This is just an example. For the actual announcements, see
# announcements.yaml
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason to have this file (template and docs) and a separate file for the announcement data?
What do you think about combining the instructions and template with the data?

Copy link
Member

Choose a reason for hiding this comment

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

What do you think about combining the instructions and template with the data?

Agree, especially if the data has to be a in a single list in a single file.

Copy link
Contributor

Choose a reason for hiding this comment

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

It is possible to have multiple files, though, I find it easier if the data is in one place or presented as a single view.

@sftim
Copy link
Contributor Author

sftim commented Jan 7, 2021

I probably won't have much time to spend on improvements to this PR. If it's pretty much good enough to merge, let's ship it and be prepared to follow up with any important tweaks.

@sftim sftim force-pushed the 20201222_data_driven_announcements branch from da1f784 to 9c0f9fa Compare January 7, 2021 08:39
sftim and others added 2 commits January 7, 2021 08:44
This change allows announcements to have an expiry date and / or a
“do not show until” date.
Separating this out also leaves room for future changes to enforce
a set of approvers.

Co-Authored-By: Karen Bradshaw <[email protected]>
@sftim sftim force-pushed the 20201222_data_driven_announcements branch from 9c0f9fa to 2bdc11d Compare January 7, 2021 08:56
@sftim
Copy link
Contributor Author

sftim commented Jan 7, 2021

/hold cancel

the automatic builds from PR #25771 are now working

This PR looks ready to supersede the implementation from PR #16210.

ℹ️ I have updated to include the existing banner text. As the new mechanism enforces a future expiry date, I picked one. Once this merges, further changes to announcements need authorization from by @kubernetes/steering-committee.

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 7, 2021

# leave the "announcements" key in place
announcements:
- startTime: 2020-06-04T23:04:39
Copy link
Contributor

@kbhawkey kbhawkey Jan 7, 2021

Choose a reason for hiding this comment

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

@sftim,
Is there a good reason to keep the existing announcement or should this PR only include the example template?
I don't see a strong case to place an announcement with this PR.
An announcement can be added in a separate PR (and approved separately by the Steering Committee).
This change is about changing the way the announcements are created and approved by setting up the announcements in a data file and processing the delivery of the announcements.

@sftim
Copy link
Contributor Author

sftim commented Jan 7, 2021

Is there a good reason to keep the existing announcement or should this PR only include the example template?

I said I'd revise this PR to retain the existing announcement.
If we merge this without migrating the current configuration, this PR removes the existing announcement. That removal is a decision for someone else.

@kbhawkey
Copy link
Contributor

kbhawkey commented Jan 7, 2021

Is there a good reason to keep the existing announcement or should this PR only include the example template?

I said I'd revise this PR to retain the existing announcement.
If we merge this without migrating the current configuration, this PR removes the existing announcement. That removal is a decision for someone else.

You are referring to this,
"BTW, merging this PR as it stands removes the existing banner. I can / will add another commit that retains it, when that's useful to do."

I think that is confusing. I read through this PR (many times) and found that you only proposed sample data.
Perhaps your intention has always been to keep the existing announcement, but that you forgot to put the
data back.

@liggitt
Copy link
Member

liggitt commented Jan 7, 2021

I probably won't have much time to spend on improvements to this PR. If it's pretty much good enough to merge, let's ship it and be prepared to follow up with any important tweaks.

I agree.

Is there a good reason to keep the existing announcement or should this PR only include the example template?

I said I'd revise this PR to retain the existing announcement.
If we merge this without migrating the current configuration, this PR removes the existing announcement. That removal is a decision for someone else.

Per the announcement policy, the current banner, re-enabled on 11/23/2020, should have an expiry of 12/14/2020.

@sftim
Copy link
Contributor Author

sftim commented Jan 7, 2021

I'll revise the expiry date, thanks @liggitt

@sftim
Copy link
Contributor Author

sftim commented Jan 7, 2021

Actually not much point adding an expired banner!

@sftim sftim force-pushed the 20201222_data_driven_announcements branch from 2bdc11d to 0b6280f Compare January 7, 2021 13:52
@@ -1,11 +1,5 @@
# i18n strings for the English (main) site.
# NOTE: Please keep the entries in alphabetical order when editing
[announcement_title]
other = "Black lives matter."

Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Could add this announcement data into the announcement template.

Copy link
Member

Choose a reason for hiding this comment

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

see discussion of current announcement data in #25769 (comment)

@kbhawkey
Copy link
Contributor

kbhawkey commented Jan 7, 2021

@sftim , thanks for working on this.
/lgtm
Hold for reviews
/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 7, 2021
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 7, 2021
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 89addbd4d5f5fd0a18f1972923ea91592af4f3c2

@liggitt
Copy link
Member

liggitt commented Jan 7, 2021

/lgtm

@sftim
Copy link
Contributor Author

sftim commented Jan 7, 2021

This looks reviewed to me. #25769 (comment) is an LGTMing review from a steering committee member, and https://github.com/kubernetes/website/pulls#pullrequestreview-557411184 is an approving review from a SIG Docs tech lead.

/unhold

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 7, 2021
@k8s-ci-robot k8s-ci-robot merged commit 20afe7f into kubernetes:master Jan 7, 2021
@sftim sftim deleted the 20201222_data_driven_announcements branch January 7, 2021 17:08
@sftim
Copy link
Contributor Author

sftim commented Mar 28, 2021

Also see PR #27274

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/web-development Issues or PRs related to the kubernetes.io's infrastructure, design, or build processes cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. sig/docs Categorizes an issue or PR as relevant to SIG Docs. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants